Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Stream_Modules.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // Stream_Modules.cpp
00003 // $Id: Stream_Modules.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:22 chad Exp $
00004 
00005 #ifndef ACE_STREAM_MODULES_C
00006 #define ACE_STREAM_MODULES_C
00007 
00008 #include "ace/Stream_Modules.h"
00009 
00010 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00011 # pragma once
00012 #endif /* ACE_LACKS_PRAGMA_ONCE */
00013 
00014 ACE_RCSID(ace, Stream_Modules, "$Id: Stream_Modules.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:22 chad Exp $")
00015 
00016 ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Head)
00017 
00018 template <ACE_SYNCH_DECL>
00019 ACE_Stream_Head<ACE_SYNCH_USE>::ACE_Stream_Head (void)
00020 {
00021   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::ACE_Stream_Head");
00022 }
00023 
00024 template <ACE_SYNCH_DECL>
00025 ACE_Stream_Head<ACE_SYNCH_USE>::~ACE_Stream_Head (void)
00026 {
00027   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::~ACE_Stream_Head");
00028 }
00029 
00030 template <ACE_SYNCH_DECL> void
00031 ACE_Stream_Head<ACE_SYNCH_USE>::dump (void) const
00032 {
00033   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::dump");
00034 }
00035 
00036 // ACE_Module that act as the head and tail of a Stream.
00037 
00038 template <ACE_SYNCH_DECL> int
00039 ACE_Stream_Head<ACE_SYNCH_USE>::open (void *)
00040 {
00041   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::open");
00042   return 0;
00043 }
00044 
00045 template <ACE_SYNCH_DECL> int
00046 ACE_Stream_Head<ACE_SYNCH_USE>::close (u_long)
00047 {
00048   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::close");
00049   return 0;
00050 }
00051 
00052 template <ACE_SYNCH_DECL> int
00053 ACE_Stream_Head<ACE_SYNCH_USE>::svc (void)
00054 {
00055   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::svc");
00056   return -1;
00057 }
00058 
00059 template <ACE_SYNCH_DECL> int
00060 ACE_Stream_Head<ACE_SYNCH_USE>::control (ACE_Message_Block *mb)
00061 {
00062   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::control");
00063   ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr ();
00064   ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd;
00065 
00066   switch (cmd = ioc->cmd ())
00067     {
00068     case ACE_IO_Cntl_Msg::SET_LWM:
00069     case ACE_IO_Cntl_Msg::SET_HWM:
00070       this->water_marks (cmd, *(size_t *) mb->cont ()->rd_ptr ());
00071       ioc->rval (0);
00072       break;
00073     default:
00074       return 0;
00075     }
00076   return ioc->rval ();
00077 }
00078 
00079 // Performs canonical flushing at the ACE_Stream Head.
00080 
00081 template <ACE_SYNCH_DECL> int
00082 ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush (ACE_Message_Block *mb)
00083 {
00084   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush");
00085   char *cp = mb->rd_ptr ();
00086 
00087   if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHR))
00088     {
00089       this->flush (ACE_Task_Flags::ACE_FLUSHALL);
00090       ACE_CLR_BITS (*cp, ACE_Task_Flags::ACE_FLUSHR);
00091     }
00092 
00093   if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHW))
00094     return this->reply (mb);
00095   else
00096     mb->release ();
00097   return 0;
00098 }
00099 
00100 template <ACE_SYNCH_DECL> int
00101 ACE_Stream_Head<ACE_SYNCH_USE>::put (ACE_Message_Block *mb,
00102                                      ACE_Time_Value *tv)
00103 {
00104   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::put");
00105   int res = 0;
00106 
00107   if (mb->msg_type () == ACE_Message_Block::MB_IOCTL
00108       && (res = this->control (mb)) == -1)
00109     return res;
00110 
00111   if (this->is_writer ())
00112     return this->put_next (mb, tv);
00113   else // this->is_reader ()
00114     {
00115       switch (mb->msg_type ())
00116         {
00117         case ACE_Message_Block::MB_FLUSH:
00118           return this->canonical_flush (mb);
00119         default:
00120           break;
00121         }
00122 
00123       return this->putq (mb, tv);
00124     }
00125 }
00126 
00127 template <ACE_SYNCH_DECL> int
00128 ACE_Stream_Head<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[])
00129 {
00130   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::init");
00131   return 0;
00132 }
00133 
00134 template <ACE_SYNCH_DECL> int
00135 ACE_Stream_Head<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const
00136 {
00137   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::info");
00138   const ACE_TCHAR *name = this->name ();
00139 
00140   if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0)
00141     return -1;
00142   else
00143     ACE_OS::strsncpy (*strp, name, length);
00144   return ACE_static_cast (int, ACE_OS_String::strlen (name));
00145 }
00146 
00147 template <ACE_SYNCH_DECL> int
00148 ACE_Stream_Head<ACE_SYNCH_USE>::fini (void)
00149 {
00150   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::fini");
00151   return 0;
00152 }
00153 
00154 ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Tail)
00155 
00156 template <ACE_SYNCH_DECL>
00157 ACE_Stream_Tail<ACE_SYNCH_USE>::ACE_Stream_Tail (void)
00158 {
00159   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::ACE_Stream_Tail");
00160 }
00161 
00162 template <ACE_SYNCH_DECL>
00163 ACE_Stream_Tail<ACE_SYNCH_USE>::~ACE_Stream_Tail (void)
00164 {
00165   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::~ACE_Stream_Tail");
00166 }
00167 
00168 template <ACE_SYNCH_DECL> void
00169 ACE_Stream_Tail<ACE_SYNCH_USE>::dump (void) const
00170 {
00171   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::dump");
00172 }
00173 
00174 template <ACE_SYNCH_DECL> int
00175 ACE_Stream_Tail<ACE_SYNCH_USE>::open (void *)
00176 {
00177   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::open");
00178   return 0;
00179 }
00180 
00181 template <ACE_SYNCH_DECL> int
00182 ACE_Stream_Tail<ACE_SYNCH_USE>::close (u_long)
00183 {
00184   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::close");
00185   return 0;
00186 }
00187 
00188 template <ACE_SYNCH_DECL> int
00189 ACE_Stream_Tail<ACE_SYNCH_USE>::svc (void)
00190 {
00191   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::svc");
00192   return -1;
00193 }
00194 
00195 template <ACE_SYNCH_DECL> int
00196 ACE_Stream_Tail<ACE_SYNCH_USE>::control (ACE_Message_Block *mb)
00197 {
00198   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::control");
00199   ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr ();
00200   ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd;
00201 
00202   switch (cmd = ioc->cmd ())
00203     {
00204     case ACE_IO_Cntl_Msg::SET_LWM:
00205     case ACE_IO_Cntl_Msg::SET_HWM:
00206       {
00207         size_t wm_size = *(size_t *) mb->cont ()->rd_ptr ();
00208 
00209         this->water_marks (cmd, wm_size);
00210         this->sibling ()->water_marks (cmd, wm_size);
00211         ioc->rval (0);
00212         break;
00213       }
00214     default:
00215       mb->msg_type (ACE_Message_Block::MB_IOCNAK);
00216     }
00217   return this->reply (mb);
00218 }
00219 
00220 // Perform flush algorithm as though we were the driver.
00221 
00222 template <ACE_SYNCH_DECL> int
00223 ACE_Stream_Tail<ACE_SYNCH_USE>::canonical_flush (ACE_Message_Block *mb)
00224 {
00225   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::canonical_flush");
00226   char *cp = mb->rd_ptr ();
00227 
00228   if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHW))
00229     {
00230       this->flush (ACE_Task_Flags::ACE_FLUSHALL);
00231       ACE_CLR_BITS (*cp, ACE_Task_Flags::ACE_FLUSHW);
00232     }
00233 
00234   if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHR))
00235     {
00236       this->sibling ()->flush (ACE_Task_Flags::ACE_FLUSHALL);
00237       return this->reply (mb);
00238     }
00239   else
00240     mb->release ();
00241 
00242   return 0;
00243 }
00244 
00245 template <ACE_SYNCH_DECL> int
00246 ACE_Stream_Tail<ACE_SYNCH_USE>::put (ACE_Message_Block *mb,
00247                                    ACE_Time_Value *)
00248 {
00249   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::put");
00250 
00251   if (this->is_writer ())
00252     {
00253       switch (mb->msg_type ())
00254         {
00255         case ACE_Message_Block::MB_IOCTL:
00256           return this->control (mb);
00257           /* NOTREACHED */
00258         default:
00259           mb->release ();
00260           return 0;
00261           /* NOTREACHED */
00262         }
00263     }
00264 
00265   return -1;
00266 }
00267 
00268 template <ACE_SYNCH_DECL> int
00269 ACE_Stream_Tail<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[])
00270 {
00271   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::init");
00272   return 0;
00273 }
00274 
00275 template <ACE_SYNCH_DECL> int
00276 ACE_Stream_Tail<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const
00277 {
00278   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::info");
00279   const ACE_TCHAR *name = this->name ();
00280 
00281   if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0)
00282     return -1;
00283   else
00284     ACE_OS::strsncpy (*strp, name, length);
00285   return ACE_static_cast (int, ACE_OS_String::strlen (name));
00286 }
00287 
00288 template <ACE_SYNCH_DECL> int
00289 ACE_Stream_Tail<ACE_SYNCH_USE>::fini (void)
00290 {
00291   ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::fini");
00292   return 0;
00293 }
00294 
00295 ACE_ALLOC_HOOK_DEFINE(ACE_Thru_Task)
00296 
00297 template <ACE_SYNCH_DECL>
00298 ACE_Thru_Task<ACE_SYNCH_USE>::ACE_Thru_Task (void)
00299 {
00300   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::ACE_Thru_Task");
00301 }
00302 
00303 template <ACE_SYNCH_DECL>
00304 ACE_Thru_Task<ACE_SYNCH_USE>::~ACE_Thru_Task (void)
00305 {
00306   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::~ACE_Thru_Task");
00307 }
00308 
00309 template <ACE_SYNCH_DECL> void
00310 ACE_Thru_Task<ACE_SYNCH_USE>::dump (void) const
00311 {
00312   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::dump");
00313 }
00314 
00315 template <ACE_SYNCH_DECL> int
00316 ACE_Thru_Task<ACE_SYNCH_USE>::open (void *)
00317 {
00318   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::open");
00319   return 0;
00320 }
00321 
00322 template <ACE_SYNCH_DECL> int
00323 ACE_Thru_Task<ACE_SYNCH_USE>::close (u_long)
00324 {
00325   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::close");
00326   return 0;
00327 }
00328 
00329 template <ACE_SYNCH_DECL> int
00330 ACE_Thru_Task<ACE_SYNCH_USE>::svc (void)
00331 {
00332   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::svc");
00333   return -1;
00334 }
00335 
00336 template <ACE_SYNCH_DECL> int
00337 ACE_Thru_Task<ACE_SYNCH_USE>::put (ACE_Message_Block *msg,
00338                                  ACE_Time_Value *tv)
00339 {
00340   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::put");
00341   return this->put_next (msg, tv);
00342 }
00343 
00344 template <ACE_SYNCH_DECL> int
00345 ACE_Thru_Task<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[])
00346 {
00347   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::init");
00348   return 0;
00349 }
00350 
00351 template <ACE_SYNCH_DECL> int
00352 ACE_Thru_Task<ACE_SYNCH_USE>::info (ACE_TCHAR **strp,
00353                                     size_t length) const
00354 {
00355   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::info");
00356   const ACE_TCHAR *name = this->name ();
00357 
00358   if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0)
00359     return -1;
00360   else
00361     ACE_OS::strsncpy (*strp, name, length);
00362   return ACE_static_cast (int, ACE_OS_String::strlen (name));
00363 }
00364 
00365 template <ACE_SYNCH_DECL> int
00366 ACE_Thru_Task<ACE_SYNCH_USE>::fini (void)
00367 {
00368   ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::fini");
00369   return 0;
00370 }
00371 
00372 #endif /* ACE_STREAM_MODULES_C */

Generated on Mon Jun 16 11:21:30 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002