Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Name_Request_Reply.h

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

Generated on Mon Jun 16 11:20:28 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002