3 // $Id: Token_Request_Reply.inl 80826 2008-03-04 14:51:23Z wotte $
5 #if defined (ACE_HAS_TOKENS_LIBRARY)
7 #include "ace/Truncate.h"
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 // = Set/get the length of the encoded/decoded message.
14 ACE_Token_Request::length (void) const
16 return ntohl (this->transfer_.length_);
20 ACE_Token_Request::length (ACE_UINT32 l)
22 this->transfer_.length_ = htonl (l);
25 // = Set/get the type of the message.
27 ACE_Token_Request::token_type (void) const
29 return (int) ntohl (this->transfer_.token_type_);
33 ACE_Token_Request::token_type (int t)
35 this->transfer_.token_type_ = htonl ((ACE_UINT32) t);
38 // = Set/get the type of the message.
40 ACE_Token_Request::proxy_type (void) const
42 return (int) ntohl (this->transfer_.proxy_type_);
46 ACE_Token_Request::proxy_type (int t)
48 this->transfer_.proxy_type_ = htonl ((ACE_UINT32) t);
51 // = Set/get the type of the message.
53 ACE_Token_Request::operation_type (void) const
55 return ntohl (this->transfer_.operation_type_);
59 ACE_Token_Request::operation_type (ACE_UINT32 t)
61 this->transfer_.operation_type_ = htonl (t);
64 // = Set/get the requeue position
66 ACE_Token_Request::requeue_position (void) const
68 return ntohl (this->transfer_.requeue_position_);
72 ACE_Token_Request::requeue_position (ACE_UINT32 rq)
74 this->transfer_.requeue_position_ = htonl (rq);
77 // = Set/get the requeue position
79 ACE_Token_Request::notify (void) const
81 return ntohl (this->transfer_.notify_);
85 ACE_Token_Request::notify (ACE_UINT32 rq)
87 this->transfer_.notify_ = htonl (rq);
90 // = Set/get the blocking semantics.
91 ACE_INLINE ACE_Synch_Options &
92 ACE_Token_Request::options (void) const
94 return (ACE_Synch_Options &) options_;
98 ACE_Token_Request::options (const ACE_Synch_Options &opt)
100 // fight the friggin const from hell
101 ACE_Synch_Options *options = (ACE_Synch_Options *) &opt;
103 transfer_.use_timeout_ = options->operator[](ACE_Synch_Options::USE_TIMEOUT);
104 if (transfer_.use_timeout_ == 1)
106 transfer_.usec_ = options->timeout ().usec ();
107 if (options->timeout ().sec () > (time_t) ACE_UINT32_MAX)
108 transfer_.sec_ = ACE_UINT32_MAX;
110 transfer_.sec_ = static_cast<ACE_UINT32> (options->timeout ().sec ());
119 // = Set/get the name of the token.
120 ACE_INLINE ACE_TCHAR *
121 ACE_Token_Request::token_name (void) const
127 ACE_Token_Request::token_name (const ACE_TCHAR *token_name,
128 const ACE_TCHAR *client_id)
130 size_t token_name_length = ACE_OS::strlen (token_name) + 1; // Add 1 for '\0'.
131 size_t client_id_length = ACE_OS::strlen (client_id) + 1; // Add 1 for '\0'.
133 // Set up pointers and copy token_name and client_id into request.
134 token_name_ = this->transfer_.data_;
135 client_id_ = &this->token_name_[token_name_length + 1]; // Add 1 for ':';
136 client_id_[-1] = ACE_TEXT (':'); // Insert the ':' before this->clientId_.
138 (void) ACE_OS::memcpy (this->token_name_,
140 token_name_length * sizeof (ACE_TCHAR));
141 (void) ACE_OS::memcpy (this->client_id_,
143 client_id_length * sizeof (ACE_TCHAR));
145 // Fixed length header size
146 size_t len = ACE_TOKEN_REQUEST_HEADER_SIZE;
148 // ... then add in the amount of the variable-sized portion.
149 len += token_name_length + client_id_length + 1;
150 this->length (ACE_Utils::truncate_cast<ACE_UINT32> (len));
153 // = Set/get the id of the client.
154 ACE_INLINE ACE_TCHAR *
155 ACE_Token_Request::client_id (void) const
157 return this->client_id_;
160 // ************************************************************
161 // ************************************************************
162 // ************************************************************
164 // = Set/get the length of the encoded/decoded message.
165 ACE_INLINE ACE_UINT32
166 ACE_Token_Reply::length (void) const
168 return ntohl (this->transfer_.length_);
172 ACE_Token_Reply::length (ACE_UINT32 l)
174 this->transfer_.length_ = htonl (l);
177 // = Set/get the errno of a failed reply.
178 ACE_INLINE ACE_UINT32
179 ACE_Token_Reply::errnum (void) const
181 return ntohl (this->transfer_.errno_);
185 ACE_Token_Reply::errnum (ACE_UINT32 e)
187 this->transfer_.errno_ = htonl (e);
190 // = Set/get the length of the encoded/decoded message.
191 ACE_INLINE ACE_UINT32
192 ACE_Token_Reply::arg (void) const
194 return ntohl (this->transfer_.arg_);
198 ACE_Token_Reply::arg (ACE_UINT32 arg)
200 this->transfer_.arg_ = htonl (arg);
203 ACE_END_VERSIONED_NAMESPACE_DECL
205 #endif /* ACE_HAS_TOKENS_LIBRARY */