Revert to Current Include Style
[ACE_TAO.git] / ACE / ace / Name_Request_Reply.h
blobb11f8747bc2adc01b241a124e1dfc778843d921e
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Name_Request_Reply.h
7 * Define the format used to exchange messages between the
8 * ACE_Name Server and its clients.
10 * @author Gerhard Lenzer
11 * @author Douglas C. Schmidt
12 * @author Prashant Jain
14 //=============================================================================
17 #ifndef ACE_NAME_REQUEST_REPLY_H
18 #define ACE_NAME_REQUEST_REPLY_H
20 #include /**/ "ace/pre.h"
22 #include "ace/Basic_Types.h"
24 #if !defined (ACE_LACKS_PRAGMA_ONCE)
25 # pragma once
26 #endif /* ACE_LACKS_PRAGMA_ONCE */
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 class ACE_Time_Value;
32 /**
33 * @class ACE_Name_Request
35 * @brief Message format for delivering requests to the ACE_Name Server.
37 * This class is implemented to minimize data copying. In
38 * particular, all marshaling is done in situ...
40 class ACE_Export ACE_Name_Request
42 public:
43 /// Request message types.
44 enum Constants
46 BIND = 01,
47 REBIND = 02,
48 RESOLVE = 03,
49 UNBIND = 04,
50 LIST_NAMES = 05,
51 LIST_VALUES = 015,
52 LIST_TYPES = 025,
53 LIST_NAME_ENTRIES = 06,
54 LIST_VALUE_ENTRIES = 016,
55 LIST_TYPE_ENTRIES = 026,
56 MAX_ENUM = 11,
57 MAX_LIST = 3,
59 // Mask for bitwise operation used for table lookup
60 /// Mask for lookup of operation
61 OP_TABLE_MASK = 07,
62 /// Mask for lookup of list_operation
63 LIST_OP_MASK = 030,
65 /// Class-specific constant values.
66 MAX_NAME_LENGTH = MAXPATHLEN + 1
69 /// Default constructor.
70 ACE_Name_Request (void);
72 /// Create a ACE_Name_Request message.
73 ACE_Name_Request (ACE_INT32 msg_type, // Type of request.
74 const ACE_WCHAR_T name[], //
75 const ACE_UINT32 name_length,
76 const ACE_WCHAR_T value[],
77 const ACE_UINT32 value_length,
78 const char type[],
79 const ACE_UINT32 type_length,
80 ACE_Time_Value *timeout = 0); // Max time willing to wait for request.
82 /// Initialize length_ in order to ensure correct byte ordering
83 /// before a request is sent.
84 void init (void);
86 // = Set/get the length of the encoded/decoded message.
87 ACE_UINT32 length (void) const;
88 void length (ACE_UINT32);
90 // = Set/get the type of the message.
91 ACE_INT32 msg_type (void) const;
92 void msg_type (ACE_INT32);
94 // = Set/get the blocking semantics.
95 ACE_UINT32 block_forever (void) const;
96 void block_forever (ACE_UINT32);
98 // = Set/get the timeout.
99 ACE_Time_Value timeout (void) const;
100 void timeout (const ACE_Time_Value timeout);
102 // = Set/get the name
103 const ACE_WCHAR_T *name (void) const;
104 void name (const ACE_WCHAR_T *);
106 // = Set/get the value
107 const ACE_WCHAR_T *value (void) const;
108 void value (const ACE_WCHAR_T *);
110 // = Set/get the type
111 const char *type (void) const;
112 void type (const char *);
114 // = Set/get the len of name
115 ACE_UINT32 name_len (void) const;
116 void name_len (ACE_UINT32);
118 // = Set/get the len of value
119 ACE_UINT32 value_len (void) const;
120 void value_len (ACE_UINT32);
122 // = Set/get the len of type
123 ACE_UINT32 type_len (void) const;
124 void type_len (ACE_UINT32);
126 /// Encode the message before transmission.
127 int encode (void *&);
129 /// Decode message after reception.
130 int decode (void);
132 /// Print out the values of the message for debugging purposes.
133 void dump () const;
135 private:
136 // = The 5 fields in the <Transfer> struct are transmitted to the server.
137 // The remaining 2 fields are not tranferred -- they are used only on
138 // the server-side to simplify lookups.
140 struct Transfer
142 /// Length of entire request.
143 ACE_UINT32 length_;
145 /// Type of the request (i.e., <BIND>, <REBIND>, <RESOLVE>, and <UNBIND>).
146 ACE_UINT32 msg_type_;
148 /// Indicates if we should block forever. If 0, then <secTimeout_>
149 /// and <usecTimeout_> indicates how long we should wait.
150 ACE_UINT32 block_forever_;
152 /// Max seconds willing to wait for name if not blocking forever.
153 ACE_UINT64 sec_timeout_;
155 /// Max micro seconds to wait for name if not blocking forever.
156 ACE_UINT32 usec_timeout_;
158 /// Len of name in bytes
159 ACE_UINT32 name_len_;
161 /// Len of value in bytes
162 ACE_UINT32 value_len_;
164 /// Len of type in bytes
165 ACE_UINT32 type_len_;
167 /// The data portion contains the <name_>
168 /// followed by the <value_>
169 /// followed by the <type_>.
170 ACE_WCHAR_T data_[MAX_NAME_LENGTH + MAXPATHLEN + MAXPATHLEN + 2];
173 /// Transfer buffer.
174 Transfer transfer_;
176 /// Pointer to the beginning of the name in this->data_.
177 ACE_WCHAR_T *name_;
179 /// Pointer to the beginning of the value in this->data_;
180 ACE_WCHAR_T *value_;
182 /// Pointer to the beginning of the type in this->data_;
183 char *type_;
187 * @class ACE_Name_Reply
189 * @brief Message format for delivering replies from the ACE_Name Server.
191 * This class is implemented to minimize data copying. In
192 * particular, all marshaling is done in situ...
194 class ACE_Export ACE_Name_Reply
196 public:
197 enum Constants
199 /// Class-specific constant values.
200 MAX_NAME_LENGTH = MAXPATHLEN + 1
203 /// Default constructor.
204 ACE_Name_Reply (void);
206 /// Create a ACE_Name_Reply message.
207 ACE_Name_Reply (ACE_UINT32 type, ACE_UINT32 err); // Type of reply.
209 /// Initialize length_ in order to ensure correct byte ordering
210 /// before a reply is sent.
211 void init (void);
213 // = Set/get the length of the encoded/decoded message.
214 ACE_UINT32 length (void) const;
215 void length (ACE_UINT32);
217 // = Set/get the type of the message.
218 ACE_INT32 msg_type (void) const;
219 void msg_type (ACE_INT32);
221 // = Set/get the status of the reply (0 == success, -1 == failure).
222 ACE_INT32 status (void) const;
223 void status (ACE_INT32);
225 // = Set/get the errno of a failed reply.
226 ACE_UINT32 errnum (void) const;
227 void errnum (ACE_UINT32);
229 /// Encode the message before transfer.
230 int encode (void *&);
232 /// Decode a message after reception.
233 int decode (void);
235 /// Print out the values of the message for debugging purposes.
236 void dump () const;
238 private:
239 // = The 3 fields in the <Transfer> struct are transmitted to the server.
241 struct Transfer
243 /// Length of entire reply.
244 ACE_UINT32 length_;
246 /// Type of the reply, i.e., success (0) or failure (-1).
247 ACE_INT32 type_;
249 /// Indicates why error occurred if <this->type_> == failure (-1).
250 /// Typical reasons include: @c ETIME (if the client timed out after
251 /// waiting for the name).
252 ACE_UINT32 errno_;
255 /// Transfer buffer.
256 Transfer transfer_;
259 ACE_END_VERSIONED_NAMESPACE_DECL
261 #include /**/ "ace/post.h"
263 #endif /* ACE_NAME_REQUEST_REPLY_H */