Queued_Data.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file Queued_Data.h
00006  *
00007  *  $Id: Queued_Data.h 79705 2007-09-24 07:45:37Z johnnyw $
00008  *
00009  *  @author Balachandran Natarajan <bala@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef TAO_QUEUED_DATA_H
00014 #define TAO_QUEUED_DATA_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "tao/Pluggable_Messaging_Utils.h"
00019 #include "tao/GIOP_Message_State.h"
00020 #include "ace/Message_Block.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 class ACE_Allocator;
00028 ACE_END_VERSIONED_NAMESPACE_DECL
00029 
00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 /**
00033  * @class TAO_Queued_Data
00034  *
00035  * @brief Represents a node in the queue of incoming messages.
00036  *
00037  * This class contains necessary information about a message that is
00038  * stored in the queue. Such a node can be used by the incoming thread
00039  * from the reactor to dequeue and process the message by sending it
00040  * to the higher layers of the ORB.
00041  *
00042  * The ACE_Message_Block contained within this class may contain a chain
00043  * of message blocks (usually when GIOP fragments are involved).  In that
00044  * case consolidate () needs to be called prior to being sent to higher
00045  * layers of the ORB when the GIOP fragment chain is complete.
00046  */
00047 class TAO_Export TAO_Queued_Data
00048 {
00049 public:
00050   /// Default Constructor
00051   TAO_Queued_Data (ACE_Allocator *alloc = 0);
00052 
00053   /// Constructor.
00054   TAO_Queued_Data (ACE_Message_Block *mb, ACE_Allocator *alloc = 0);
00055 
00056   /// Copy constructor.
00057   TAO_Queued_Data (const TAO_Queued_Data &qd);
00058 
00059   /// Creation of a node in the queue.
00060   static TAO_Queued_Data* make_queued_data (
00061                                     ACE_Allocator *message_buffer_alloc = 0,
00062                                     ACE_Allocator *input_cdr_alloc = 0,
00063                                     ACE_Data_Block *db = 0);
00064 
00065   /// Deletion of a node from the queue.
00066   static void release (TAO_Queued_Data *qd);
00067 
00068   /// Duplicate ourselves. This creates a copy of ourselves on the
00069   /// heap and returns a pointer to the duplicated node.
00070   static TAO_Queued_Data* duplicate (TAO_Queued_Data &qd);
00071 
00072   /// Consolidate this fragments chained message blocks into one.
00073   /// @return -1 if consolidation failed, eg out or memory, otherwise 0
00074   int consolidate (void);
00075 
00076   /// Get missing data
00077   size_t missing_data (void) const;
00078 
00079   /// Set missing data
00080   void missing_data (size_t data);
00081 
00082   /// Get the GIOP version
00083   TAO_GIOP_Message_Version const &giop_version (void) const;
00084 
00085   /// Get byte_order
00086   CORBA::Octet byte_order (void) const;
00087 
00088   /// Get more fragments
00089   CORBA::Octet more_fragments (void) const;
00090 
00091   /// Get message type
00092   GIOP::MsgType msg_type (void) const;
00093 
00094   /// Get next
00095   TAO_Queued_Data *next (void) const;
00096 
00097   /// Set next
00098   void next (TAO_Queued_Data* qd);
00099 
00100   /// Get message block
00101   ACE_Message_Block *msg_block (void) const;
00102 
00103   /// Set message block
00104   void msg_block (ACE_Message_Block *mb);
00105 
00106   /// Set the state
00107   void state (const TAO_GIOP_Message_State& state);
00108 
00109   const TAO_GIOP_Message_State& state (void) const;
00110 
00111 private:
00112 
00113   /// The message block that contains the message.
00114   ACE_Message_Block *msg_block_;
00115 
00116   /*!
00117     @name Missing Data details
00118 
00119     The \a missing_data_ member contains the number of bytes of
00120     data missing from \a msg_block_.
00121    */
00122   //@{
00123   /*! Data missing in the above message that hasn't been read or processed yet,
00124       the value TAO_MISSING_DATA_UNDEFINED indicates it hasn't been processed yet,
00125       otherwise greater or equal zero. */
00126   size_t missing_data_;
00127   //@}
00128 
00129   /// State of this queued data
00130   TAO_GIOP_Message_State state_;
00131 
00132   /// Pounter to the next element in the queue.
00133   TAO_Queued_Data *next_;
00134 
00135   /// Replace the datablock with a one allocated on the heap or
00136   /// allocator
00137   static void replace_data_block (ACE_Message_Block &mb);
00138 
00139   /// The allocator used to allocate this class.
00140   ACE_Allocator *allocator_;
00141 };
00142 
00143 TAO_END_VERSIONED_NAMESPACE_DECL
00144 
00145 #if defined (__ACE_INLINE__)
00146 # include "tao/Queued_Data.inl"
00147 #endif /* __ACE_INLINE__ */
00148 
00149 #include /**/ "ace/post.h"
00150 #endif /*TAO_QUEUED_DATA_H*/

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7