Classes | Public Types | Public Member Functions | Private Attributes

ACE_Name_Request Class Reference

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

#include <Name_Request_Reply.h>

Collaboration diagram for ACE_Name_Request:
Collaboration graph
[legend]

List of all members.

Classes

struct  Transfer

Public Types

enum  Constants {
  BIND = 01, REBIND = 02, RESOLVE = 03, UNBIND = 04,
  LIST_NAMES = 05, LIST_VALUES = 015, LIST_TYPES = 025, LIST_NAME_ENTRIES = 06,
  LIST_VALUE_ENTRIES = 016, LIST_TYPE_ENTRIES = 026, MAX_ENUM = 11, MAX_LIST = 3,
  OP_TABLE_MASK = 07, LIST_OP_MASK = 030, MAX_NAME_LENGTH = MAXPATHLEN + 1
}
 

Request message types.

More...

Public Member Functions

 ACE_Name_Request (void)
 Default constructor.
 ACE_Name_Request (ACE_INT32 msg_type, const ACE_WCHAR_T name[], const ACE_UINT32 name_length, const ACE_WCHAR_T value[], const ACE_UINT32 value_length, const char type[], const ACE_UINT32 type_length, ACE_Time_Value *timeout=0)
 Create a ACE_Name_Request message.
void init (void)
ACE_UINT32 length (void) const
void length (ACE_UINT32)
ACE_INT32 msg_type (void) const
void msg_type (ACE_INT32)
ACE_UINT32 block_forever (void) const
void block_forever (ACE_UINT32)
ACE_Time_Value timeout (void) const
void timeout (const ACE_Time_Value timeout)
const ACE_WCHAR_T * name (void) const
void name (const ACE_WCHAR_T *)
const ACE_WCHAR_T * value (void) const
void value (const ACE_WCHAR_T *)
const char * type (void) const
void type (const char *)
ACE_UINT32 name_len (void) const
void name_len (ACE_UINT32)
ACE_UINT32 value_len (void) const
void value_len (ACE_UINT32)
ACE_UINT32 type_len (void) const
void type_len (ACE_UINT32)
int encode (void *&)
 Encode the message before transmission.
int decode (void)
 Decode message after reception.
void dump (void) const
 Print out the values of the message for debugging purposes.

Private Attributes

Transfer transfer_
 Transfer buffer.
ACE_WCHAR_T * name_
 Pointer to the beginning of the name in this->data_.
ACE_WCHAR_T * value_
 Pointer to the beginning of the value in this->data_;.
char * type_
 Pointer to the beginning of the type in this->data_;.

Detailed Description

Message format for delivering requests to the ACE_Name Server.

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

Definition at line 42 of file Name_Request_Reply.h.


Member Enumeration Documentation

Request message types.

Enumerator:
BIND 
REBIND 
RESOLVE 
UNBIND 
LIST_NAMES 
LIST_VALUES 
LIST_TYPES 
LIST_NAME_ENTRIES 
LIST_VALUE_ENTRIES 
LIST_TYPE_ENTRIES 
MAX_ENUM 
MAX_LIST 
OP_TABLE_MASK 

Mask for lookup of operation.

LIST_OP_MASK 

Mask for lookup of list_operation.

MAX_NAME_LENGTH 

Class-specific constant values.

Definition at line 46 of file Name_Request_Reply.h.

  {
    BIND = 01,
    REBIND = 02,
    RESOLVE = 03,
    UNBIND  = 04,
    LIST_NAMES = 05,
    LIST_VALUES = 015,
    LIST_TYPES = 025,
    LIST_NAME_ENTRIES = 06,
    LIST_VALUE_ENTRIES = 016,
    LIST_TYPE_ENTRIES = 026,
    MAX_ENUM = 11,
    MAX_LIST = 3,

    // Mask for bitwise operation used for table lookup
    /// Mask for lookup of operation
    OP_TABLE_MASK = 07,
    /// Mask for lookup of list_operation
    LIST_OP_MASK = 030,

    /// Class-specific constant values.
    MAX_NAME_LENGTH = MAXPATHLEN + 1
  };


Constructor & Destructor Documentation

ACE_Name_Request::ACE_Name_Request ( void   ) 

Default constructor.

ACE_Name_Request::ACE_Name_Request ( ACE_INT32  msg_type,
const ACE_WCHAR_T  name[],
const ACE_UINT32  name_length,
const ACE_WCHAR_T  value[],
const ACE_UINT32  value_length,
const char  type[],
const ACE_UINT32  type_length,
ACE_Time_Value timeout = 0 
)

Create a ACE_Name_Request message.

Definition at line 25 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::ACE_Name_Request");
  this->msg_type (t);
  this->name_len (name_length);
  this->value_len (value_length);
  this->type_len (type_length);

  // If timeout is a NULL pointer, then block forever...
  if (timeout == 0)
    {
      this->transfer_.block_forever_ = 1;
      this->transfer_.sec_timeout_   = 0;
      this->transfer_.usec_timeout_  = 0;
    }
  else // Do a "timed wait."
    {
      this->block_forever (0);
      // Keep track of how long client is willing to wait.
      this->transfer_.sec_timeout_ = timeout->sec ();
      this->transfer_.usec_timeout_ = timeout->usec ();
    }

  // Set up pointers and copy name value and type into request.
  this->name_ = this->transfer_.data_;
  this->value_  = &this->name_[name_length / sizeof (ACE_WCHAR_T) ];
  this->type_  = (char *)(&this->value_[value_length / sizeof (ACE_WCHAR_T)]); //

  (void) ACE_OS::memcpy (this->name_,
                         name,
                         name_length);
  (void) ACE_OS::memcpy (this->value_,
                         value,
                         value_length);
  (void) ACE_OS::memcpy (this->type_,
                         type,
                         type_length);

  // Compute size of the fixed portion of the message...
  size_t len = sizeof this->transfer_ - sizeof this->transfer_.data_;

  // ... then add in the amount of the variable-sized portion.
  len += name_length + value_length + type_length ;

  this->length (static_cast<ACE_UINT32> (len));
}


Member Function Documentation

ACE_UINT32 ACE_Name_Request::block_forever ( void   )  const

Definition at line 172 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::block_forever");
  return this->transfer_.block_forever_;
}

void ACE_Name_Request::block_forever ( ACE_UINT32  bs  ) 

Definition at line 179 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::block_forever");
  this->transfer_.block_forever_ = bs;
}

int ACE_Name_Request::decode ( void   ) 

Decode message after reception.

Definition at line 297 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::decode");
  // Decode the fixed-sized portion first.
  this->transfer_.block_forever_ = ACE_NTOHL (this->transfer_.block_forever_);
  this->transfer_.usec_timeout_  = ACE_NTOHL (this->transfer_.usec_timeout_);
#if defined (ACE_LITTLE_ENDIAN)
  ACE_UINT64 secs = this->transfer_.sec_timeout_;
  ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.sec_timeout_);
#endif
  this->transfer_.length_ = ACE_NTOHL (this->transfer_.length_);
  this->transfer_.msg_type_ = ACE_NTOHL (this->transfer_.msg_type_);
  this->transfer_.name_len_ = ACE_NTOHL (this->transfer_.name_len_);
  this->transfer_.value_len_ = ACE_NTOHL (this->transfer_.value_len_);
  this->transfer_.type_len_ = ACE_NTOHL (this->transfer_.type_len_);

  size_t nv_data_len =
    (this->transfer_.name_len_ + this->transfer_.value_len_)
    / sizeof (ACE_WCHAR_T);

  for (size_t i = 0; i < nv_data_len; i++)
    this->transfer_.data_[i] =
      ACE_NTOHS (this->transfer_.data_[i]);

  this->name_ = this->transfer_.data_;
  this->value_ = &this->name_[this->transfer_.name_len_ / sizeof (ACE_WCHAR_T)];
  this->type_ = (char *)(&this->value_[this->transfer_.value_len_ / sizeof (ACE_WCHAR_T)]);
  this->type_[this->transfer_.type_len_] = '\0';

  // Decode the variable-sized portion.
  return 0;
}

void ACE_Name_Request::dump ( void   )  const

Print out the values of the message for debugging purposes.

Definition at line 333 of file Name_Request_Reply.cpp.

{
#if defined (ACE_HAS_DUMP)
  ACE_TRACE ("ACE_Name_Request::dump");
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("*******\nlength = %d\n"),
              this->length ()));
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("message-type = ")));

  switch (this->msg_type ())
    {
    case ACE_Name_Request::BIND:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("BIND\n")));
      break;
    case ACE_Name_Request::REBIND:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("REBIND\n")));
      break;
    case ACE_Name_Request::RESOLVE:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("RESOLVE\n")));
      break;
    case ACE_Name_Request::UNBIND:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("UNBIND\n")));
      break;
    case ACE_Name_Request::LIST_NAMES:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("LIST_NAMES\n")));
      break;
    case ACE_Name_Request::LIST_VALUES:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("LIST_VALUES\n")));
      break;
    case ACE_Name_Request::LIST_TYPES:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("LIST_TYPES\n")));
      break;
    case ACE_Name_Request::LIST_NAME_ENTRIES:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("LIST_NAME_ENTRIES\n")));
      break;
    case ACE_Name_Request::LIST_VALUE_ENTRIES:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("LIST_VALUE_ENTRIES\n")));
      break;
    case ACE_Name_Request::LIST_TYPE_ENTRIES:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("LIST_TYPE_ENTRIES\n")));
      break;
    default:
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("<unknown type> = %d\n"),
                  this->msg_type ()));
      break;
    }

  if (this->block_forever ())
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("blocking forever\n")));
  else
    {
#if !defined (ACE_NLOGGING)
      ACE_Time_Value tv = this->timeout ();
#endif /* ! ACE_NLOGGING */
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("waiting for %d secs and %d usecs\n"),
                  tv.sec (),
                  tv.usec ()));
    }
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("*******\nname_len = %d\n"),
              this->name_len ()));
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("*******\nvalue_len = %d\n"),
              this->value_len ()));

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("+++++++\n")));
#endif /* ACE_HAS_DUMP */
}

int ACE_Name_Request::encode ( void *&  buf  ) 

Encode the message before transmission.

Definition at line 262 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::encode");
  // Compute the length *before* doing the marshaling.

  ACE_UINT32 len = this->length ();

  size_t nv_data_len =
    (this->transfer_.name_len_ + this->transfer_.value_len_)
    / sizeof (ACE_WCHAR_T);

  for (size_t i = 0; i < nv_data_len; i++)
    this->transfer_.data_[i] =
      ACE_HTONS (this->transfer_.data_[i]);

  buf = (void *) &this->transfer_;
  this->transfer_.block_forever_ = ACE_HTONL (this->transfer_.block_forever_);
  this->transfer_.usec_timeout_  = ACE_HTONL (this->transfer_.usec_timeout_);
#if defined (ACE_LITTLE_ENDIAN)
  ACE_UINT64 secs = this->transfer_.sec_timeout_;
  ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.sec_timeout_);
#endif
  this->transfer_.length_ = ACE_HTONL (this->transfer_.length_);
  this->transfer_.msg_type_ = ACE_HTONL (this->transfer_.msg_type_);
  this->transfer_.name_len_ = ACE_HTONL (this->transfer_.name_len_);
  this->transfer_.value_len_ = ACE_HTONL (this->transfer_.value_len_);
  this->transfer_.type_len_ = ACE_HTONL (this->transfer_.type_len_);

  return len;
}

void ACE_Name_Request::init ( void   ) 

Initialize length_ in order to ensure correct byte ordering before a request is sent.

Definition at line 83 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::init");
  this->length (sizeof this->transfer_);
}

ACE_UINT32 ACE_Name_Request::length ( void   )  const

Definition at line 92 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::length");
  return this->transfer_.length_;
}

void ACE_Name_Request::length ( ACE_UINT32  l  ) 

Definition at line 99 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::length");
  this->transfer_.length_ = l;
}

ACE_INT32 ACE_Name_Request::msg_type ( void   )  const

Definition at line 108 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::msg_type");
  return this->transfer_.msg_type_;
}

void ACE_Name_Request::msg_type ( ACE_INT32  t  ) 

Definition at line 115 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::msg_type");
  this->transfer_.msg_type_ = t;
}

const ACE_WCHAR_T * ACE_Name_Request::name ( void   )  const

Definition at line 206 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::name");
  return this->name_;
}

void ACE_Name_Request::name ( const ACE_WCHAR_T *  t  ) 

Definition at line 213 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::name");
  (void) ACE_OS::memcpy (this->name_,
                         t,
                         this->name_len ());
}

ACE_UINT32 ACE_Name_Request::name_len ( void   )  const

Definition at line 124 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::name_len");
  return this->transfer_.name_len_;
}

void ACE_Name_Request::name_len ( ACE_UINT32  t  ) 

Definition at line 131 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::name_len");
  this->transfer_.name_len_ = t;
}

void ACE_Name_Request::timeout ( const ACE_Time_Value  timeout  ) 

Definition at line 196 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::timeout");
  this->transfer_.sec_timeout_ = timeout.sec ();
  this->transfer_.usec_timeout_ = timeout.usec ();
}

ACE_Time_Value ACE_Name_Request::timeout ( void   )  const

Definition at line 188 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::timeout");
  time_t sec = ACE_Utils::truncate_cast<time_t> (this->transfer_.sec_timeout_);
  return ACE_Time_Value (sec, this->transfer_.usec_timeout_);
}

void ACE_Name_Request::type ( const char *  c  ) 

Definition at line 250 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::type");
  ACE_OS::strsncpy (this->type_,
                    c,
                    sizeof this->type_);
}

const char * ACE_Name_Request::type ( void   )  const

Definition at line 243 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::type");
  return this->type_;
}

void ACE_Name_Request::type_len ( ACE_UINT32  t  ) 

Definition at line 163 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::type_len");
  this->transfer_.type_len_ = t;
}

ACE_UINT32 ACE_Name_Request::type_len ( void   )  const

Definition at line 156 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::type_len");
  return this->transfer_.type_len_;
}

void ACE_Name_Request::value ( const ACE_WCHAR_T *  c  ) 

Definition at line 231 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::value");

  (void) ACE_OS::memcpy (this->value_,
                         c,
                         this->value_len());
}

const ACE_WCHAR_T * ACE_Name_Request::value ( void   )  const

Definition at line 224 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::value");
  return this->value_;
}

void ACE_Name_Request::value_len ( ACE_UINT32  t  ) 

Definition at line 147 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::value_len");
  this->transfer_.value_len_ = t;
}

ACE_UINT32 ACE_Name_Request::value_len ( void   )  const

Definition at line 140 of file Name_Request_Reply.cpp.

{
  ACE_TRACE ("ACE_Name_Request::value_len");
  return this->transfer_.value_len_;
}


Member Data Documentation

ACE_WCHAR_T* ACE_Name_Request::name_ [private]

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

Definition at line 179 of file Name_Request_Reply.h.

Transfer buffer.

Definition at line 176 of file Name_Request_Reply.h.

char* ACE_Name_Request::type_ [private]

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

Definition at line 185 of file Name_Request_Reply.h.

ACE_WCHAR_T* ACE_Name_Request::value_ [private]

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

Definition at line 182 of file Name_Request_Reply.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines