Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / tao / Queued_Data.h
blobe7654cd1f750afd382fe2479d694f63fb46f0a0e
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 (void);
74 /// Get missing data
75 size_t missing_data (void) 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 (void) const;
83 /// Get byte_order
84 CORBA::Octet byte_order (void) const;
86 /// Get more fragments
87 CORBA::Boolean more_fragments (void) const;
89 /// Get message type
90 GIOP::MsgType msg_type (void) const;
92 /// Get next
93 TAO_Queued_Data *next (void) const;
95 /// Set next
96 void next (TAO_Queued_Data* qd);
98 /// Get message block
99 ACE_Message_Block *msg_block (void) 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 (void) const;
110 private:
112 /// The message block that contains the message.
113 ACE_Message_Block *msg_block_;
116 @name Missing Data details
118 The \a missing_data_ member contains the number of bytes of
119 data missing from \a msg_block_.
121 //@{
122 /*! Data missing in the above message that hasn't been read or processed yet,
123 the value TAO_MISSING_DATA_UNDEFINED indicates it hasn't been processed yet,
124 otherwise greater or equal zero. */
125 size_t missing_data_;
126 //@}
128 /// State of this queued data
129 TAO_GIOP_Message_State state_;
131 /// Pounter to the next element in the queue.
132 TAO_Queued_Data *next_;
134 /// Replace the datablock with a one allocated on the heap or
135 /// allocator
136 static void replace_data_block (ACE_Message_Block &mb);
138 /// The allocator used to allocate this class.
139 ACE_Allocator *allocator_;
142 TAO_END_VERSIONED_NAMESPACE_DECL
144 #if defined (__ACE_INLINE__)
145 # include "tao/Queued_Data.inl"
146 #endif /* __ACE_INLINE__ */
148 #include /**/ "ace/post.h"
149 #endif /*TAO_QUEUED_DATA_H*/