Name_Request_Reply.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Name_Request_Reply.h
00006  *
00007  *  Name_Request_Reply.h,v 4.23 2005/10/28 16:14:53 ossama Exp
00008  *
00009  *   Define the format used to exchange messages between the
00010  *   ACE_Name Server and its clients.
00011  *
00012  *  @author Gerhard Lenzer
00013  *  @author Douglas C. Schmidt
00014  *  @author Prashant Jain
00015  */
00016 //=============================================================================
00017 
00018 
00019 #ifndef ACE_NAME_REQUEST_REPLY_H
00020 #define ACE_NAME_REQUEST_REPLY_H
00021 
00022 #include /**/ "ace/pre.h"
00023 
00024 #include "ace/Basic_Types.h"
00025 
00026 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00027 # pragma once
00028 #endif /* ACE_LACKS_PRAGMA_ONCE */
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 class ACE_Time_Value;
00033 
00034 /**
00035  * @class ACE_Name_Request
00036  *
00037  * @brief Message format for delivering requests to the ACE_Name Server.
00038  *
00039  * This class is implemented to minimize data copying.  In
00040  * particular, all marshaling is done in situ...
00041  */
00042 class ACE_Export ACE_Name_Request
00043 {
00044 public:
00045   /// Request message types.
00046   enum Constants
00047   {
00048     BIND = 01,
00049     REBIND = 02,
00050     RESOLVE = 03,
00051     UNBIND  = 04,
00052     LIST_NAMES = 05,
00053     LIST_VALUES = 015,
00054     LIST_TYPES = 025,
00055     LIST_NAME_ENTRIES = 06,
00056     LIST_VALUE_ENTRIES = 016,
00057     LIST_TYPE_ENTRIES = 026,
00058     MAX_ENUM = 11,
00059     MAX_LIST = 3,
00060 
00061     // Mask for bitwise operation used for table lookup
00062     /// Mask for lookup of operation
00063     OP_TABLE_MASK = 07,
00064     /// Mask for lookup of list_operation
00065     LIST_OP_MASK = 030,
00066 
00067     /// Class-specific constant values.
00068     MAX_NAME_LENGTH = MAXPATHLEN + 1
00069   };
00070 
00071   /// Default constructor.
00072   ACE_Name_Request (void);
00073 
00074   /// Create a ACE_Name_Request message.
00075   ACE_Name_Request (ACE_INT32 msg_type, // Type of request.
00076                     const ACE_WCHAR_T name[], //
00077                     const ACE_UINT32 name_length,
00078                     const ACE_WCHAR_T value[],
00079                     const ACE_UINT32 value_length,
00080                     const char type[],
00081                     const ACE_UINT32 type_length,
00082                     ACE_Time_Value *timeout = 0); // Max time willing to wait for request.
00083 
00084   /// Initialize length_ in order to ensure correct byte ordering
00085   /// before a request is sent.
00086   void init (void);
00087 
00088   // = Set/get the length of the encoded/decoded message.
00089   ACE_UINT32 length (void) const;
00090   void length (ACE_UINT32);
00091 
00092   // = Set/get the type of the message.
00093   ACE_INT32 msg_type (void) const;
00094   void msg_type (ACE_INT32);
00095 
00096   // = Set/get the blocking semantics.
00097   ACE_UINT32 block_forever (void) const;
00098   void block_forever (ACE_UINT32);
00099 
00100   // = Set/get the timeout.
00101   ACE_Time_Value timeout (void) const;
00102   void timeout (const ACE_Time_Value timeout);
00103 
00104   // = Set/get the name
00105   const ACE_WCHAR_T *name (void) const;
00106   void name (const ACE_WCHAR_T *);
00107 
00108   // = Set/get the value
00109   const ACE_WCHAR_T *value (void) const;
00110   void value (const ACE_WCHAR_T *);
00111 
00112   // = Set/get the type
00113   const char *type (void) const;
00114   void type (const char *);
00115 
00116   // = Set/get the len of name
00117   ACE_UINT32 name_len (void) const;
00118   void name_len (ACE_UINT32);
00119 
00120   // = Set/get the len of value
00121   ACE_UINT32 value_len (void) const;
00122   void value_len (ACE_UINT32);
00123 
00124   // = Set/get the len of type
00125   ACE_UINT32 type_len (void) const;
00126   void type_len (ACE_UINT32);
00127 
00128   /// Encode the message before transmission.
00129   int encode (void *&);
00130 
00131   /// Decode message after reception.
00132   int decode (void);
00133 
00134   /// Print out the values of the message for debugging purposes.
00135   void dump (void) const;
00136 
00137 private:
00138   // = The 5 fields in the <Transfer> struct are transmitted to the server.
00139   // The remaining 2 fields are not tranferred -- they are used only on
00140   // the server-side to simplify lookups.
00141 
00142   struct Transfer
00143   {
00144     /// Length of entire request.
00145     ACE_UINT32 length_;
00146 
00147     /// Type of the request (i.e., <BIND>, <REBIND>, <RESOLVE>, and <UNBIND>).
00148     ACE_UINT32 msg_type_;
00149 
00150     /// Indicates if we should block forever.  If 0, then <secTimeout_>
00151     /// and <usecTimeout_> indicates how long we should wait.
00152     ACE_UINT32 block_forever_;
00153 
00154     /// Max seconds willing to wait for name if not blocking forever.
00155     ACE_UINT32 sec_timeout_;
00156 
00157     /// Max micro seconds to wait for name if not blocking forever.
00158     ACE_UINT32 usec_timeout_;
00159 
00160     /// Len of name in bytes
00161     ACE_UINT32 name_len_;
00162 
00163     /// Len of value in bytes
00164     ACE_UINT32 value_len_;
00165 
00166     /// Len of type in bytes
00167     ACE_UINT32 type_len_;
00168 
00169     /// The data portion contains the <name_>
00170     /// followed by the <value_>
00171     /// followed by the <type_>.
00172     ACE_WCHAR_T data_[MAX_NAME_LENGTH + MAXPATHLEN + MAXPATHLEN + 2];
00173   };
00174 
00175   /// Transfer buffer.
00176   Transfer transfer_;
00177 
00178   /// Pointer to the beginning of the name in this->data_.
00179   ACE_WCHAR_T *name_;
00180 
00181   /// Pointer to the beginning of the value in this->data_;
00182   ACE_WCHAR_T *value_;
00183 
00184   /// Pointer to the beginning of the type in this->data_;
00185   char *type_;
00186 };
00187 
00188 /**
00189  * @class ACE_Name_Reply
00190  *
00191  * @brief Message format for delivering replies from the ACE_Name Server.
00192  *
00193  * This class is implemented to minimize data copying.  In
00194  * particular, all marshaling is done in situ...
00195  */
00196 class ACE_Export ACE_Name_Reply
00197 {
00198 public:
00199   enum Constants
00200   {
00201     /// Class-specific constant values.
00202     MAX_NAME_LENGTH = MAXPATHLEN + 1
00203   };
00204 
00205   /// Default constructor.
00206   ACE_Name_Reply (void);
00207 
00208   /// Create a <ACE_Name_Reply> message.
00209   ACE_Name_Reply (ACE_UINT32 type, ACE_UINT32 err); // Type of reply.
00210 
00211   /// Initialize length_ in order to ensure correct byte ordering
00212   /// before a reply is sent.
00213   void init (void);
00214 
00215   // = Set/get the length of the encoded/decoded message.
00216   ACE_UINT32 length (void) const;
00217   void length (ACE_UINT32);
00218 
00219   // = Set/get the type of the message.
00220   ACE_INT32 msg_type (void) const;
00221   void msg_type (ACE_INT32);
00222 
00223   // = Set/get the status of the reply (0 == success, -1 == failure).
00224   ACE_INT32 status (void) const;
00225   void status (ACE_INT32);
00226 
00227   // = Set/get the errno of a failed reply.
00228   ACE_UINT32 errnum (void) const;
00229   void errnum (ACE_UINT32);
00230 
00231   /// Encode the message before transfer.
00232   int encode (void *&);
00233 
00234   /// Decode a message after reception.
00235   int decode (void);
00236 
00237   /// Print out the values of the message for debugging purposes.
00238   void dump (void) const;
00239 
00240 private:
00241   // = The 3 fields in the <Transfer> struct are transmitted to the server.
00242 
00243   struct Transfer
00244   {
00245     /// Length of entire reply.
00246     ACE_UINT32 length_;
00247 
00248     /// Type of the reply, i.e., success (0) or failure (-1).
00249     ACE_INT32 type_;
00250 
00251     /// Indicates why error occurred if <this->type_> == failure (-1).
00252     /// Typical reasons include: <ETIME> (if the client timed out after
00253     /// waiting for the name).
00254     ACE_UINT32 errno_;
00255   };
00256 
00257   /// Transfer buffer.
00258   Transfer transfer_;
00259 };
00260 
00261 ACE_END_VERSIONED_NAMESPACE_DECL
00262 
00263 #include /**/ "ace/post.h"
00264 
00265 #endif /* ACE_NAME_REQUEST_REPLY_H */

Generated on Thu Nov 9 09:41:57 2006 for ACE by doxygen 1.3.6