Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tao / Queued_Data.h
blobc13e1a97b48c88e24752e7c2fb0e155d580eeb12
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Queued_Data.h
7 * @author Balachandran Natarajan <bala@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef TAO_QUEUED_DATA_H
12 #define TAO_QUEUED_DATA_H
14 #include /**/ "ace/pre.h"
16 #include "tao/Pluggable_Messaging_Utils.h"
17 #include "tao/GIOP_Message_State.h"
18 #include "ace/Message_Block.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
25 class ACE_Allocator;
26 ACE_END_VERSIONED_NAMESPACE_DECL
28 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
30 /**
31 * @class TAO_Queued_Data
33 * @brief Represents a node in the queue of incoming messages.
35 * This class contains necessary information about a message that is
36 * stored in the queue. Such a node can be used by the incoming thread
37 * from the reactor to dequeue and process the message by sending it
38 * to the higher layers of the ORB.
40 * The ACE_Message_Block contained within this class may contain a chain
41 * of message blocks (usually when GIOP fragments are involved). In that
42 * case consolidate () needs to be called prior to being sent to higher
43 * layers of the ORB when the GIOP fragment chain is complete.
45 class TAO_Export TAO_Queued_Data
47 public:
48 /// Default Constructor
49 TAO_Queued_Data (ACE_Allocator *alloc = 0);
51 /// Constructor.
52 TAO_Queued_Data (ACE_Message_Block *mb, ACE_Allocator *alloc = 0);
54 /// Copy constructor.
55 TAO_Queued_Data (const TAO_Queued_Data &qd);
57 /// Creation of a node in the queue.
58 static TAO_Queued_Data* make_queued_data (
59 ACE_Allocator *message_buffer_alloc = 0,
60 ACE_Allocator *input_cdr_alloc = 0,
61 ACE_Data_Block *db = 0);
63 /// Deletion of a node from the queue.
64 static void release (TAO_Queued_Data *qd);
66 /// Duplicate ourselves. This creates a copy of ourselves on the
67 /// heap and returns a pointer to the duplicated node.
68 static TAO_Queued_Data* duplicate (TAO_Queued_Data &qd);
70 /// Consolidate this fragments chained message blocks into one.
71 /// @return -1 if consolidation failed, eg out or memory, otherwise 0
72 int consolidate ();
74 /// Get missing data
75 size_t missing_data () const;
77 /// Set missing data
78 void missing_data (size_t data);
80 /// Get the GIOP version
81 TAO_GIOP_Message_Version const &giop_version () const;
83 /// Get byte_order
84 CORBA::Octet byte_order () const;
86 /// Get more fragments
87 CORBA::Boolean more_fragments () const;
89 /// Get message type
90 GIOP::MsgType msg_type () const;
92 /// Get next
93 TAO_Queued_Data *next () const;
95 /// Set next
96 void next (TAO_Queued_Data* qd);
98 /// Get message block
99 ACE_Message_Block *msg_block () const;
101 /// Set message block
102 void msg_block (ACE_Message_Block *mb);
104 /// Set the state
105 void state (const TAO_GIOP_Message_State& state);
107 /// Get the state
108 const TAO_GIOP_Message_State& state () const;
110 private:
111 /// The message block that contains the message.
112 ACE_Message_Block *msg_block_ {};
115 @name Missing Data details
117 The \a missing_data_ member contains the number of bytes of
118 data missing from \a msg_block_.
120 //@{
121 /*! Data missing in the above message that hasn't been read or processed yet,
122 the value TAO_MISSING_DATA_UNDEFINED indicates it hasn't been processed yet,
123 otherwise greater or equal zero. */
124 size_t missing_data_ {};
125 //@}
127 /// State of this queued data
128 TAO_GIOP_Message_State state_;
130 /// Pounter to the next element in the queue.
131 TAO_Queued_Data *next_ {};
133 /// Replace the datablock with a one allocated on the heap or
134 /// allocator
135 static void replace_data_block (ACE_Message_Block &mb);
137 /// The allocator used to allocate this class.
138 ACE_Allocator *allocator_ {};
141 TAO_END_VERSIONED_NAMESPACE_DECL
143 #if defined (__ACE_INLINE__)
144 # include "tao/Queued_Data.inl"
145 #endif /* __ACE_INLINE__ */
147 #include /**/ "ace/post.h"
148 #endif /*TAO_QUEUED_DATA_H*/