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 79012 2007-07-24 14:21:05Z 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   TAO_Pluggable_Message_Type 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 set_state (const TAO_GIOP_Message_State& state);
00108 
00109 private:
00110 
00111   /// The message block that contains the message.
00112   ACE_Message_Block *msg_block_;
00113 
00114   /*!
00115     @name Missing Data details
00116 
00117     The \a missing_data_ member contains the number of bytes of
00118     data missing from \a msg_block_.
00119    */
00120   //@{
00121   /*! Data missing in the above message that hasn't been read or processed yet,
00122       the value TAO_MISSING_DATA_UNDEFINED indicates it hasn't been processed yet,
00123       otherwise greater or equal zero. */
00124   size_t missing_data_;
00125   //@}
00126 
00127   /// State of this queued data
00128   TAO_GIOP_Message_State state_;
00129 
00130   /// Pounter to the next element in the queue.
00131   TAO_Queued_Data *next_;
00132 
00133   /// Replace the datablock with a one allocated on the heap or
00134   /// allocator
00135   static void replace_data_block (ACE_Message_Block &mb);
00136 
00137   /// The allocator used to allocate this class.
00138   ACE_Allocator *allocator_;
00139 };
00140 
00141 TAO_END_VERSIONED_NAMESPACE_DECL
00142 
00143 #if defined (__ACE_INLINE__)
00144 # include "tao/Queued_Data.inl"
00145 #endif /* __ACE_INLINE__ */
00146 
00147 #include /**/ "ace/post.h"
00148 #endif /*TAO_QUEUED_DATA_H*/

Generated on Sun Jan 27 13:07:36 2008 for TAO by doxygen 1.3.6