Stream_Modules.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Stream_Modules.h
00006  *
00007  *  Stream_Modules.h,v 4.23 2005/10/28 16:14:56 ossama Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 // This needs to go outside of the #if !defined() block.  Don't ask...
00014 #include "ace/Task.h"
00015 
00016 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00017 # pragma once
00018 #endif /* ACE_LACKS_PRAGMA_ONCE */
00019 
00020 #ifndef ACE_STREAM_MODULES
00021 #define ACE_STREAM_MODULES
00022 #include /**/ "ace/pre.h"
00023 
00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 /**
00027  * @class ACE_Stream_Head
00028  *
00029  * @brief Standard task that acts as reader or writer at the head of
00030  *        an ACE_Stream.
00031  *
00032  * A ACE_Message_Block sent to this task (via its put() hook) triggers
00033  * actions depending on the block type and whether the task is acting as
00034  * a reader or a writer. If the block is of type ACE_Message_Block::MB_IOCTL,
00035  * the block's is assumed to contain (beginning at its rd_ptr()) an
00036  * ACE_IO_Cntl_Msg object and is processed accordingly. This is usually
00037  * used to set the task's message queue high water and/or low water marks.
00038  *
00039  * When the block is not ACE_Message_Block::MB_IOCTL, processing depends on
00040  * the ACE_Stream_Head's role in the module:
00041  *
00042  * - Reader: If the block is of type ACE_Message_Block::MB_FLUSH, the
00043  *           canonical_flush() method is called.
00044  *           (@see ACE_Stream::canonical_flush().) If the block is any other
00045  *           type, it is queued on this task's message queue. It would thus
00046  *           be available to caller's reading blocks from the containing
00047  *           stream.
00048  * - Writer: The block is passed to the next module in the stream.
00049  */
00050 template <ACE_SYNCH_DECL>
00051 class ACE_Stream_Head : public ACE_Task<ACE_SYNCH_USE>
00052 {
00053 public:
00054   /// Construction
00055   ACE_Stream_Head (void);
00056 
00057   /// Destruction
00058   ~ACE_Stream_Head (void);
00059 
00060   // = ACE_Task hooks
00061   virtual int open (void *a = 0);
00062   virtual int close (u_long flags = 0);
00063   virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0);
00064   virtual int svc (void);
00065 
00066   // = Dynamic linking hooks
00067   virtual int init (int argc, ACE_TCHAR *argv[]);
00068   virtual int info (ACE_TCHAR **info_string, size_t length) const;
00069   virtual int fini (void);
00070 
00071   /// Dump the state of an object.
00072   void dump (void) const;
00073 
00074   /// Declare the dynamic allocation hooks.
00075   ACE_ALLOC_HOOK_DECLARE;
00076 
00077 private:
00078   /// Performs canonical flushing at the ACE_Stream Head.
00079   int control (ACE_Message_Block *);
00080   int canonical_flush (ACE_Message_Block *);
00081 };
00082 
00083 /**
00084  * @class ACE_Stream_Tail
00085  *
00086  * @brief Standard module that acts as the head of a stream.
00087  */
00088 template <ACE_SYNCH_DECL>
00089 class ACE_Stream_Tail : public ACE_Task<ACE_SYNCH_USE>
00090 {
00091 public:
00092   /// Construction
00093   ACE_Stream_Tail (void);
00094 
00095   /// Destruction
00096   ~ACE_Stream_Tail (void);
00097 
00098   // = ACE_Task hooks
00099   virtual int open (void *a = 0);
00100   virtual int close (u_long flags = 0);
00101   virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0);
00102   virtual int svc (void);
00103 
00104   // = Dynamic linking hooks
00105   virtual int init (int argc, ACE_TCHAR *argv[]);
00106   virtual int info (ACE_TCHAR **info_string, size_t length) const;
00107   virtual int fini (void);
00108 
00109   /// Dump the state of an object.
00110   void dump (void) const;
00111 
00112   /// Declare the dynamic allocation hooks.
00113   ACE_ALLOC_HOOK_DECLARE;
00114 
00115 private:
00116   /// Performs canonical flushing at the ACE_Stream tail.
00117   int control (ACE_Message_Block *);
00118   int canonical_flush (ACE_Message_Block *);
00119 };
00120 
00121 /**
00122  * @class ACE_Thru_Task
00123  *
00124  * @brief Standard module that acts as a "no op", simply passing on all
00125  * data to its adjacent neighbor.
00126  */
00127 template <ACE_SYNCH_DECL>
00128 class ACE_Thru_Task : public ACE_Task<ACE_SYNCH_USE>
00129 {
00130 public:
00131   /// Construction
00132   ACE_Thru_Task (void);
00133 
00134   /// Destruction
00135   ~ACE_Thru_Task (void);
00136 
00137   // = ACE_Task hooks
00138   virtual int open (void *a = 0);
00139   virtual int close (u_long flags = 0);
00140   virtual int put (ACE_Message_Block *msg, ACE_Time_Value * = 0);
00141   virtual int svc (void);
00142 
00143   // = Dynamic linking hooks
00144   virtual int init (int argc, ACE_TCHAR *argv[]);
00145   virtual int info (ACE_TCHAR **info_string, size_t length) const;
00146   virtual int fini (void);
00147 
00148   /// Dump the state of an object.
00149   void dump (void) const;
00150 
00151   /// Declare the dynamic allocation hooks.
00152   ACE_ALLOC_HOOK_DECLARE;
00153 };
00154 
00155 ACE_END_VERSIONED_NAMESPACE_DECL
00156 
00157 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00158 #include "ace/Stream_Modules.cpp"
00159 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00160 
00161 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00162 #pragma implementation ("Stream_Modules.cpp")
00163 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00164 
00165 #include /**/ "ace/post.h"
00166 #endif /* ACE_STREAM_MODULES */

Generated on Thu Nov 9 09:42:05 2006 for ACE by doxygen 1.3.6