Token_Request_Reply.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // $Id: Token_Request_Reply.inl 80826 2008-03-04 14:51:23Z wotte $
00004 
00005 #if defined (ACE_HAS_TOKENS_LIBRARY)
00006 
00007 #include "ace/Truncate.h"
00008 
00009 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00010 
00011 // = Set/get the length of the encoded/decoded message.
00012 
00013 ACE_INLINE ACE_UINT32
00014 ACE_Token_Request::length (void) const
00015 {
00016   return ntohl (this->transfer_.length_);
00017 }
00018 
00019 ACE_INLINE void
00020 ACE_Token_Request::length (ACE_UINT32 l)
00021 {
00022   this->transfer_.length_ = htonl (l);
00023 }
00024 
00025 // = Set/get the type of the message.
00026 ACE_INLINE int
00027 ACE_Token_Request::token_type (void) const
00028 {
00029   return (int) ntohl (this->transfer_.token_type_);
00030 }
00031 
00032 ACE_INLINE void
00033 ACE_Token_Request::token_type (int t)
00034 {
00035   this->transfer_.token_type_ = htonl ((ACE_UINT32) t);
00036 }
00037 
00038 // = Set/get the type of the message.
00039 ACE_INLINE int
00040 ACE_Token_Request::proxy_type (void) const
00041 {
00042   return (int) ntohl (this->transfer_.proxy_type_);
00043 }
00044 
00045 ACE_INLINE void
00046 ACE_Token_Request::proxy_type (int t)
00047 {
00048   this->transfer_.proxy_type_ = htonl ((ACE_UINT32) t);
00049 }
00050 
00051 // = Set/get the type of the message.
00052 ACE_INLINE ACE_UINT32
00053 ACE_Token_Request::operation_type (void) const
00054 {
00055   return ntohl (this->transfer_.operation_type_);
00056 }
00057 
00058 ACE_INLINE void
00059 ACE_Token_Request::operation_type (ACE_UINT32 t)
00060 {
00061   this->transfer_.operation_type_ = htonl (t);
00062 }
00063 
00064 // = Set/get the requeue position
00065 ACE_INLINE ACE_UINT32
00066 ACE_Token_Request::requeue_position (void) const
00067 {
00068   return ntohl (this->transfer_.requeue_position_);
00069 }
00070 
00071 ACE_INLINE void
00072 ACE_Token_Request::requeue_position (ACE_UINT32 rq)
00073 {
00074   this->transfer_.requeue_position_ = htonl (rq);
00075 }
00076 
00077 // = Set/get the requeue position
00078 ACE_INLINE ACE_UINT32
00079 ACE_Token_Request::notify (void) const
00080 {
00081   return ntohl (this->transfer_.notify_);
00082 }
00083 
00084 ACE_INLINE void
00085 ACE_Token_Request::notify (ACE_UINT32 rq)
00086 {
00087   this->transfer_.notify_ = htonl (rq);
00088 }
00089 
00090 // = Set/get the blocking semantics.
00091 ACE_INLINE ACE_Synch_Options &
00092 ACE_Token_Request::options (void) const
00093 {
00094   return (ACE_Synch_Options &) options_;
00095 }
00096 
00097 ACE_INLINE void
00098 ACE_Token_Request::options (const ACE_Synch_Options &opt)
00099 {
00100   // fight the friggin const from hell
00101   ACE_Synch_Options *options = (ACE_Synch_Options *) &opt;
00102 
00103   transfer_.use_timeout_ = options->operator[](ACE_Synch_Options::USE_TIMEOUT);
00104   if (transfer_.use_timeout_ == 1)
00105     {
00106       transfer_.usec_ = options->timeout ().usec ();
00107       if (options->timeout ().sec () > (time_t) ACE_UINT32_MAX)
00108         transfer_.sec_ = ACE_UINT32_MAX;
00109       else
00110         transfer_.sec_ = static_cast<ACE_UINT32> (options->timeout ().sec ());
00111     }
00112   else
00113     {
00114       transfer_.usec_ = 0;
00115       transfer_.sec_ = 0;
00116     }
00117 }
00118 
00119 // = Set/get the name of the token.
00120 ACE_INLINE ACE_TCHAR *
00121 ACE_Token_Request::token_name (void) const
00122 {
00123   return token_name_;
00124 }
00125 
00126 ACE_INLINE void
00127 ACE_Token_Request::token_name (const ACE_TCHAR *token_name,
00128                                const ACE_TCHAR *client_id)
00129 {
00130   size_t token_name_length = ACE_OS::strlen (token_name) + 1; // Add 1 for '\0'.
00131   size_t client_id_length = ACE_OS::strlen (client_id) + 1; // Add 1 for '\0'.
00132 
00133   // Set up pointers and copy token_name and client_id into request.
00134   token_name_ = this->transfer_.data_;
00135   client_id_  = &this->token_name_[token_name_length + 1]; // Add 1 for ':';
00136   client_id_[-1] = ACE_TEXT (':'); // Insert the ':' before this->clientId_.
00137 
00138   (void) ACE_OS::memcpy (this->token_name_,
00139                          token_name,
00140                          token_name_length * sizeof (ACE_TCHAR));
00141   (void) ACE_OS::memcpy (this->client_id_,
00142                          client_id,
00143                          client_id_length * sizeof (ACE_TCHAR));
00144 
00145   // Fixed length header size
00146   size_t len = ACE_TOKEN_REQUEST_HEADER_SIZE;
00147 
00148   // ... then add in the amount of the variable-sized portion.
00149   len += token_name_length + client_id_length + 1;
00150   this->length (ACE_Utils::truncate_cast<ACE_UINT32> (len));
00151 }
00152 
00153 // = Set/get the id of the client.
00154 ACE_INLINE ACE_TCHAR *
00155 ACE_Token_Request::client_id (void) const
00156 {
00157   return this->client_id_;
00158 }
00159 
00160 // ************************************************************
00161 // ************************************************************
00162 // ************************************************************
00163 
00164 // = Set/get the length of the encoded/decoded message.
00165 ACE_INLINE ACE_UINT32
00166 ACE_Token_Reply::length (void) const
00167 {
00168   return ntohl (this->transfer_.length_);
00169 }
00170 
00171 ACE_INLINE void
00172 ACE_Token_Reply::length (ACE_UINT32 l)
00173 {
00174   this->transfer_.length_ = htonl (l);
00175 }
00176 
00177 // = Set/get the errno of a failed reply.
00178 ACE_INLINE ACE_UINT32
00179 ACE_Token_Reply::errnum (void) const
00180 {
00181   return ntohl (this->transfer_.errno_);
00182 }
00183 
00184 ACE_INLINE void
00185 ACE_Token_Reply::errnum (ACE_UINT32 e)
00186 {
00187   this->transfer_.errno_ = htonl (e);
00188 }
00189 
00190 // = Set/get the length of the encoded/decoded message.
00191 ACE_INLINE ACE_UINT32
00192 ACE_Token_Reply::arg (void) const
00193 {
00194   return ntohl (this->transfer_.arg_);
00195 }
00196 
00197 ACE_INLINE void
00198 ACE_Token_Reply::arg (ACE_UINT32 arg)
00199 {
00200   this->transfer_.arg_ = htonl (arg);
00201 }
00202 
00203 ACE_END_VERSIONED_NAMESPACE_DECL
00204 
00205 #endif /* ACE_HAS_TOKENS_LIBRARY */

Generated on Tue Feb 2 17:18:43 2010 for ACE by  doxygen 1.4.7