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

ACE_Token_Request Class Reference

Message format for delivering requests to the ACE_Token Server. More...

#include <Token_Request_Reply.h>

Collaboration diagram for ACE_Token_Request:

Collaboration graph
[legend]
List of all members.

Public Types

enum  OPERATION {
  ACQUIRE, RELEASE, RENEW, REMOVE,
  TRY_ACQUIRE
}
 Operation types. More...


Public Methods

 ACE_Token_Request (void)
 Default constructor. More...

 ACE_Token_Request (int token_type, int proxy_type, ACE_UINT32 operation, const ACE_TCHAR token_name[], const ACE_TCHAR client_id[], const ACE_Synch_Options &options)
ACE_UINT32 length (void) const
 Get the length of the encoded/decoded message. More...

void length (ACE_UINT32)
 Set the length of the encoded/decoded message. More...

int proxy_type (void) const
 Get the type of proxy. More...

void proxy_type (int proxy_type)
 Set the type of proxy. More...

int token_type (void) const
 Get the type of token. More...

void token_type (int token_type)
 Set the type of token. More...

ACE_UINT32 operation_type (void) const
 Get the type of the operation. More...

void operation_type (ACE_UINT32)
 Set the type of the operation. More...

ACE_UINT32 requeue_position (void) const
 Get the requeue position. These should be used when renew is the operation type. More...

void requeue_position (ACE_UINT32)
 Set the requeue position. These should be used when renew is the operation type. More...

ACE_UINT32 notify (void) const
 Get notify. These should be used when acquire is the operation type. More...

void notify (ACE_UINT32)
 Set notify. These should be used when acquire is the operation type. More...

ACE_Synch_Optionsoptions (void) const
void options (const ACE_Synch_Options &options)
ACE_TCHARtoken_name (void) const
ACE_TCHARclient_id (void) const
void token_name (const ACE_TCHAR *token_name, const ACE_TCHAR *client_id)
int encode (void *&)
 Encode the message before transmission. More...

int decode (void)
 Decode message after reception. This must be called to set the internal options. More...

void dump (void) const
 Print out the values of the message for debugging purposes. More...


Private Attributes

ACE_Token_Request::Transfer transfer_
ACE_TCHARtoken_name_
 Pointer to the beginning of the token name in this->data_. More...

ACE_TCHARclient_id_
 Pointer to the beginning of the client id in this->data_;. More...

ACE_Synch_Options options_
 Holds arg, sec, usec, etc. More...


Detailed Description

Message format for delivering requests to the ACE_Token Server.

This class is implemented to minimize data copying. In particular, all marshaling is done in situ...

Definition at line 45 of file Token_Request_Reply.h.


Member Enumeration Documentation

enum ACE_Token_Request::OPERATION
 

Operation types.

Enumeration values:
ACQUIRE  Acquire the token.
RELEASE  Release the token.
RENEW  Renew the token.
REMOVE  Remove the token.
TRY_ACQUIRE 

Definition at line 49 of file Token_Request_Reply.h.

00050   {
00051     /// Acquire the token.
00052     ACQUIRE,
00053     /// Release the token.
00054     RELEASE,
00055     /// Renew the token.
00056     RENEW,
00057     /// Remove the token.
00058     REMOVE,
00059     // Try to acquire the token.
00060     TRY_ACQUIRE
00061   };


Constructor & Destructor Documentation

ACE_Token_Request::ACE_Token_Request void   
 

Default constructor.

Definition at line 16 of file Token_Request_Reply.cpp.

00017   : token_name_ (0),
00018     client_id_ (0)
00019 {
00020 }

ACE_Token_Request::ACE_Token_Request int    token_type,
int    proxy_type,
ACE_UINT32    operation,
const ACE_TCHAR    token_name[],
const ACE_TCHAR    client_id[],
const ACE_Synch_Options   options
 

token_type - MUTEX, RWLOCK proxy_type - MUTEX, RLOCK, WLOCK (acquires mean different things) operation - method token_name client_id options - we check USE_TIMEOUT and use the arg.

Definition at line 24 of file Token_Request_Reply.cpp.

References ACE_TCHAR, ACE_Token_Request::Transfer::arg_, client_id, ACE_Token_Request::Transfer::data_, ACE_OS_String::memset, notify, operation_type, options, proxy_type, requeue_position, token_name, token_type, and transfer_.

00030 {
00031   this->token_type (token_type);
00032   this->proxy_type (proxy_type);
00033   this->operation_type (operation_type);
00034   this->requeue_position (0);      // to avoid Purify UMR
00035   this->notify (0);                // to avoid Purify UMR
00036   transfer_.arg_ = 0;              // to avoid Purify UMR
00037   ACE_OS::memset (transfer_.data_, 0, sizeof transfer_.data_); // to avoid Purify UMR
00038   this->token_name (token_name, client_id);
00039   this->options (options);
00040 }


Member Function Documentation

ACE_TCHAR* ACE_Token_Request::client_id void    const
 

Referenced by ACE_Token_Request, and dump.

int ACE_Token_Request::decode void   
 

Decode message after reception. This must be called to set the internal options.

Definition at line 56 of file Token_Request_Reply.cpp.

References ACE_MAXTOKENNAMELEN, ACE_TOKEN_REQUEST_HEADER_SIZE, ACE_Token_Request::Transfer::arg_, client_id_, ACE_Token_Request::Transfer::data_, length, options_, ACE_Token_Request::Transfer::sec_, ACE_Synch_Options::set, ACE_OS_String::strlen, token_name_, transfer_, ACE_Synch_Options::USE_TIMEOUT, ACE_Token_Request::Transfer::use_timeout_, and ACE_Token_Request::Transfer::usec_.

00057 {
00058   this->token_name_ = this->transfer_.data_;
00059 
00060   options_.set (transfer_.use_timeout_ == 1 ? ACE_Synch_Options::USE_TIMEOUT : 0,
00061                 ACE_Time_Value (transfer_.sec_, transfer_.usec_),
00062                 (void *) transfer_.arg_);
00063 
00064   // Decode the variable-sized portion.
00065   int token_len = ACE_OS::strlen (this->token_name_);
00066 
00067   // Check to make sure this->tokenName_ isn't too long!
00068   if (token_len >= ACE_MAXTOKENNAMELEN)
00069     {
00070       errno = ENAMETOOLONG;
00071       return -1;
00072     }
00073   else // Skip this->tokenName_ + '\0' + ':'.
00074     this->client_id_ = 
00075       &this->token_name_[(token_len + 2) * sizeof (ACE_TCHAR)];
00076 
00077   // Fixed size header
00078   // token_name_ plus '\0'
00079   // ':'
00080   // client_id_ plus '\0'
00081   size_t data_size = ACE_TOKEN_REQUEST_HEADER_SIZE
00082                      + ACE_OS::strlen (this->token_name_) + 1
00083                      + ACE_OS::strlen (this->client_id_) + 1
00084                      + 1;
00085 
00086   // Make sure the message was correctly received and framed.
00087   return this->length () == data_size ? 0 : -1;
00088 }

void ACE_Token_Request::dump void    const
 

Print out the values of the message for debugging purposes.

Definition at line 93 of file Token_Request_Reply.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACQUIRE, client_id, LM_DEBUG, ACE_Tokens::MUTEX, operation_type, options, proxy_type, ACE_RW_Token::READER, RELEASE, RENEW, ACE_Synch_Options::timeout, token_name, token_type, ACE_Synch_Options::USE_TIMEOUT, and ACE_Time_Value::usec.

00094 {
00095   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00096   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("*******\nlength = %d\ntoken name = %s\nclient id = %s\n"),
00097              this->length (), this->token_name (), this->client_id ()));
00098   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("type = ")));
00099 
00100   if (this->token_type () == ACE_Tokens::MUTEX)
00101     ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("MUTEX\n")));
00102   else // == ACE_Tokens::RWLOCK
00103     {
00104       if (this->proxy_type () == ACE_RW_Token::READER)
00105         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("RLOCK\n")));
00106       else // == WRITER
00107         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("WLOCK\n")));
00108     }
00109 
00110   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("operation = ")));
00111   switch (this->operation_type ())
00112     {
00113     case ACE_Token_Request::ACQUIRE:
00114       ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("ACQUIRE\n")));
00115       break;
00116     case ACE_Token_Request::RELEASE:
00117       ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("RELEASE\n")));
00118       break;
00119     case ACE_Token_Request::RENEW:
00120       ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("RENEW\n")));
00121       break;
00122     default:
00123       ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("<unknown operation type> = %d\n"), this->operation_type ()));
00124       break;
00125     }
00126 
00127   if (this->options ()[ACE_Synch_Options::USE_TIMEOUT] == 0)
00128     ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("blocking forever\n")));
00129   else
00130     {
00131       ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("waiting for %d secs and %d usecs\n"),
00132                  this->options ().timeout ().sec (), this->options ().timeout ().usec ()));
00133     }
00134   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00135 }

int ACE_Token_Request::encode void *&   
 

Encode the message before transmission.

Definition at line 46 of file Token_Request_Reply.cpp.

References length, and transfer_.

Referenced by ACE_Remote_Token_Proxy::request_reply.

00047 {
00048   buf = (void *) &this->transfer_;
00049   return this->length ();
00050 }

void ACE_Token_Request::length ACE_UINT32   
 

Set the length of the encoded/decoded message.

ACE_UINT32 ACE_Token_Request::length void    const
 

Get the length of the encoded/decoded message.

Referenced by decode, and encode.

void ACE_Token_Request::notify ACE_UINT32   
 

Set notify. These should be used when acquire is the operation type.

ACE_UINT32 ACE_Token_Request::notify void    const
 

Get notify. These should be used when acquire is the operation type.

Referenced by ACE_Token_Request, and ACE_Remote_Token_Proxy::acquire.

void ACE_Token_Request::operation_type ACE_UINT32   
 

Set the type of the operation.

ACE_UINT32 ACE_Token_Request::operation_type void    const
 

Get the type of the operation.

Referenced by ACE_Token_Request, and dump.

void ACE_Token_Request::options const ACE_Synch_Options   options
 

ACE_Synch_Options& ACE_Token_Request::options void    const
 

Referenced by ACE_Token_Request, and dump.

void ACE_Token_Request::proxy_type int    proxy_type
 

Set the type of proxy.

int ACE_Token_Request::proxy_type void    const
 

Get the type of proxy.

Referenced by ACE_Token_Request, and dump.

void ACE_Token_Request::requeue_position ACE_UINT32   
 

Set the requeue position. These should be used when renew is the operation type.

ACE_UINT32 ACE_Token_Request::requeue_position void    const
 

Get the requeue position. These should be used when renew is the operation type.

Referenced by ACE_Token_Request, and ACE_Remote_Token_Proxy::renew.

void ACE_Token_Request::token_name const ACE_TCHAR   token_name,
const ACE_TCHAR   client_id
 

ACE_TCHAR* ACE_Token_Request::token_name void    const
 

Referenced by ACE_Token_Request, and dump.

void ACE_Token_Request::token_type int    token_type
 

Set the type of token.

int ACE_Token_Request::token_type void    const
 

Get the type of token.

Referenced by ACE_Token_Request, and dump.


Member Data Documentation

ACE_TCHAR* ACE_Token_Request::client_id_ [private]
 

Pointer to the beginning of the client id in this->data_;.

Definition at line 190 of file Token_Request_Reply.h.

Referenced by decode.

ACE_Synch_Options ACE_Token_Request::options_ [private]
 

Holds arg, sec, usec, etc.

Definition at line 193 of file Token_Request_Reply.h.

Referenced by decode.

ACE_TCHAR* ACE_Token_Request::token_name_ [private]
 

Pointer to the beginning of the token name in this->data_.

Definition at line 187 of file Token_Request_Reply.h.

Referenced by decode.

struct ACE_Token_Request::Transfer ACE_Token_Request::transfer_ [private]
 

Referenced by ACE_Token_Request, decode, and encode.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:58:32 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002