TAO_COIOP_Profile Class Reference

This class defines the protocol specific attributes required for locating ORBs over a TCP/IP network. More...

#include <COIOP_Profile.h>

Inheritance diagram for TAO_COIOP_Profile:

Inheritance graph
[legend]
Collaboration diagram for TAO_COIOP_Profile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual char object_key_delimiter (void) const
 TAO_COIOP_Profile (const ACE_Utils::UUID &uuid, const TAO::ObjectKey &object_key, const TAO_GIOP_Message_Version &version, TAO_ORB_Core *orb_core)
 TAO_COIOP_Profile (TAO_ORB_Core *orb_core)
 Profile constructor, default.

 ~TAO_COIOP_Profile (void)
 Destructor is to be called only through .

virtual char * to_string (void)
 Template methods. Please tao/Profile.h for documentation.

virtual int encode_endpoints (void)
virtual TAO_Endpointendpoint (void)
virtual CORBA::ULong endpoint_count (void) const
virtual CORBA::ULong hash (CORBA::ULong max)
void add_endpoint (TAO_COIOP_Endpoint *endp)

Static Public Member Functions

const char * prefix (void)
 Return the char string prefix.


Static Public Attributes

const char object_key_delimiter_ = '/'
 The object key delimiter that COIOP uses or expects.


Protected Member Functions

virtual int decode_profile (TAO_InputCDR &cdr)
 Template methods. Please see tao/Profile.h for documentation.

virtual void parse_string_i (const char *string)
virtual void create_profile_body (TAO_OutputCDR &cdr) const
virtual int decode_endpoints (void)
virtual CORBA::Boolean do_is_equivalent (const TAO_Profile *other_profile)

Protected Attributes

TAO_COIOP_Endpoint endpoint_
CORBA::ULong count_
 Number of endpoints in the list headed by .


Detailed Description

This class defines the protocol specific attributes required for locating ORBs over a TCP/IP network.

This class defines the COIOP profile as specified in the CORBA specification.

Definition at line 44 of file COIOP_Profile.h.


Constructor & Destructor Documentation

TAO_COIOP_Profile::TAO_COIOP_Profile const ACE_Utils::UUID uuid,
const TAO::ObjectKey object_key,
const TAO_GIOP_Message_Version version,
TAO_ORB_Core orb_core
 

Profile constructor, this is the most efficient since it doesn't require any address resolution processing.

Definition at line 33 of file COIOP_Profile.cpp.

References TAO_TAG_COIOP_PROFILE.

00037   : TAO_Profile (TAO_TAG_COIOP_PROFILE,
00038                  orb_core,
00039                  object_key,
00040                  version),
00041     endpoint_ (uuid),
00042     count_ (1)
00043 {
00044 }

TAO_COIOP_Profile::TAO_COIOP_Profile TAO_ORB_Core orb_core  ) 
 

Profile constructor, default.

Definition at line 46 of file COIOP_Profile.cpp.

References TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, and TAO_TAG_COIOP_PROFILE.

00047   : TAO_Profile (TAO_TAG_COIOP_PROFILE,
00048                  orb_core,
00049                  TAO_GIOP_Message_Version (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR)),
00050     endpoint_ (),
00051     count_ (1)
00052 {
00053 }

TAO_COIOP_Profile::~TAO_COIOP_Profile void   ) 
 

Destructor is to be called only through .

Definition at line 55 of file COIOP_Profile.cpp.

References endpoint(), and TAO_Endpoint::next().

00056 {
00057   // Clean up the list of endpoints since we own it.
00058   // Skip the head, since it is not dynamically allocated.
00059   TAO_Endpoint *tmp = 0;
00060 
00061   for (TAO_Endpoint *next = this->endpoint ()->next ();
00062        next != 0;
00063        next = tmp)
00064     {
00065       tmp = next->next ();
00066       delete next;
00067     }
00068 }


Member Function Documentation

void TAO_COIOP_Profile::add_endpoint TAO_COIOP_Endpoint endp  ) 
 

Add to this profile's list of endpoints (it is inserted next to the head of the list). This profiles takes ownership of .

Definition at line 201 of file COIOP_Profile.cpp.

References TAO_COIOP_Endpoint::next_.

Referenced by TAO_COIOP_Acceptor::create_shared_profile(), and decode_endpoints().

00202 {
00203   endp->next_ = this->endpoint_.next_;
00204   this->endpoint_.next_ = endp;
00205 
00206   this->count_++;
00207 }

void TAO_COIOP_Profile::create_profile_body TAO_OutputCDR cdr  )  const [protected, virtual]
 

Implements TAO_Profile.

Definition at line 254 of file COIOP_Profile.cpp.

References ACE_CString, ACE_ERROR, TAO_Tagged_Components::encode(), LM_ERROR, TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, TAO::Refcounted_ObjectKey::object_key(), TAO_Profile::tagged_components(), TAO_ENCAP_BYTE_ORDER, ACE_Utils::UUID::to_string(), TAO_COIOP_Endpoint::uuid_, ACE_OutputCDR::write_octet(), and ACE_OutputCDR::write_string().

00255 {
00256   encap.write_octet (TAO_ENCAP_BYTE_ORDER);
00257 
00258   // The GIOP version
00259   encap.write_octet (this->version_.major);
00260   encap.write_octet (this->version_.minor);
00261 
00262   // STRING hostname from profile
00263   const ACE_CString * uuid_str = this->endpoint_.uuid_.to_string();
00264   encap.write_string (uuid_str->c_str ());
00265 
00266   // OCTET SEQUENCE for object key
00267   if (this->ref_object_key_)
00268     encap << this->ref_object_key_->object_key ();
00269   else
00270     {
00271       ACE_ERROR ((LM_ERROR,
00272                   "(%P|%t) TAO - COIOP_Profile::create_profile_body "
00273                   "no object key marshalled \n"));
00274     }
00275 
00276   if (this->version_.major > 1
00277       || this->version_.minor > 0)
00278     this->tagged_components ().encode (encap);
00279 }

int TAO_COIOP_Profile::decode_endpoints void   )  [protected, virtual]
 

Implements TAO_Profile.

Definition at line 339 of file COIOP_Profile.cpp.

References ACE_NEW_RETURN, add_endpoint(), IOP::TaggedComponent::component_data, TAO_Tagged_Components::get_component(), TAO_Endpoint::priority(), ACE_InputCDR::reset_byte_order(), CORBA::string_dup(), and IOP::TaggedComponent::tag.

00340 {
00341   IOP::TaggedComponent tagged_component;
00342   tagged_component.tag = TAO_TAG_ENDPOINTS;
00343 
00344   if (this->tagged_components_.get_component (tagged_component))
00345     {
00346       const CORBA::Octet *buf =
00347         tagged_component.component_data.get_buffer ();
00348 
00349       TAO_InputCDR in_cdr (reinterpret_cast<const char*> (buf),
00350                            tagged_component.component_data.length ());
00351 
00352       // Extract the Byte Order.
00353       CORBA::Boolean byte_order;
00354       if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
00355         return -1;
00356       in_cdr.reset_byte_order (static_cast<int> (byte_order));
00357 
00358       // Extract endpoints sequence.
00359       TAO::COIOPEndpointSequence endpoints;
00360 
00361       if (! (in_cdr >> endpoints))
00362         return -1;
00363 
00364       // Get the priority of the first endpoint (head of the list.
00365       // It's other data is extracted as part of the standard profile
00366       // decoding.
00367       this->endpoint_.priority (endpoints[0].priority);
00368 
00369       // Use information extracted from the tagged component to
00370       // populate the profile.  Skip the first endpoint, since it is
00371       // always extracted through standard profile body.  Also, begin
00372       // from the end of the sequence to preserve endpoint order,
00373       // since <add_endpoint> method reverses the order of endpoints
00374       // in the list.
00375       for (CORBA::ULong i = endpoints.length () - 1;
00376            i > 0;
00377            --i)
00378         {
00379           TAO_COIOP_Endpoint *endpoint = 0;
00380           CORBA::String_var strvar = CORBA::string_dup (endpoints[i].uuid);
00381           ACE_Utils::UUID uuid1 (strvar.in());
00382           ACE_NEW_RETURN (endpoint,
00383                           TAO_COIOP_Endpoint (uuid1),
00384                           -1);
00385 
00386           this->add_endpoint (endpoint);
00387         }
00388     }
00389 
00390   return 0;
00391 }

int TAO_COIOP_Profile::decode_profile TAO_InputCDR cdr  )  [protected, virtual]
 

Template methods. Please see tao/Profile.h for documentation.

Implements TAO_Profile.

Definition at line 76 of file COIOP_Profile.cpp.

References ACE_DEBUG, ACE_TEXT, ACE_Utils::UUID::from_string(), ACE_InputCDR::good_bit(), LM_DEBUG, ACE_InputCDR::read_string(), TAO_debug_level, and TAO_COIOP_Endpoint::uuid_.

00077 {
00078   // @@ NOTE: This code is repeated thrice. Need to factor out in a
00079   // better manner.
00080   // Decode uuid into the <endpoint_>.
00081   CORBA::String_var uuid;
00082   if (cdr.read_string (uuid.out ()) == 0)
00083     {
00084       if (TAO_debug_level > 0)
00085         ACE_DEBUG ((LM_DEBUG,
00086                     ACE_TEXT ("TAO (%P|%t) COIOP_Profile::decode - ")
00087                     ACE_TEXT ("error while uuid")));
00088       return -1;
00089     }
00090 
00091   if (cdr.good_bit ())
00092     {
00093       this->endpoint_.uuid_.from_string (uuid.in());
00094 
00095       return 1;
00096     }
00097 
00098   return -1;
00099 }

CORBA::Boolean TAO_COIOP_Profile::do_is_equivalent const TAO_Profile other_profile  )  [protected, virtual]
 

Implements TAO_Profile.

Definition at line 139 of file COIOP_Profile.cpp.

References endpoint_, TAO_COIOP_Endpoint::is_equivalent(), and TAO_COIOP_Endpoint::next_.

00140 {
00141   const TAO_COIOP_Profile *op =
00142     dynamic_cast<const TAO_COIOP_Profile *> (other_profile);
00143 
00144   // Check endpoints equivalence.
00145   const TAO_COIOP_Endpoint *other_endp = &op->endpoint_;
00146   for (TAO_COIOP_Endpoint *endp = &this->endpoint_;
00147        endp != 0;
00148        endp = endp->next_)
00149     {
00150       if (endp->is_equivalent (other_endp))
00151         other_endp = other_endp->next_;
00152       else
00153         return false;
00154     }
00155 
00156   return true;
00157 }

int TAO_COIOP_Profile::encode_endpoints void   )  [virtual]
 

Implements TAO_Profile.

Definition at line 282 of file COIOP_Profile.cpp.

References ACE_CString, ACE_OutputCDR::begin(), IOP::TaggedComponent::component_data, ACE_Message_Block::cont(), ACE_Message_Block::length(), ACE_OS::memcpy(), TAO_COIOP_Endpoint::next_, TAO_Endpoint::priority(), ACE_Message_Block::rd_ptr(), TAO_Tagged_Components::set_component(), IOP::TaggedComponent::tag, TAO_ENCAP_BYTE_ORDER, ACE_Utils::UUID::to_string(), ACE_OutputCDR::total_length(), and TAO_COIOP_Endpoint::uuid_.

00283 {
00284   // Create a data structure and fill it with endpoint info for wire
00285   // transfer.
00286   // We include information for the head of the list
00287   // together with other endpoints because even though its addressing
00288   // info is transmitted using standard ProfileBody components, its
00289   // priority is not!
00290 
00291   TAO::COIOPEndpointSequence endpoints;
00292   endpoints.length (this->count_);
00293 
00294   const TAO_COIOP_Endpoint *endpoint = &this->endpoint_;
00295   for (CORBA::ULong i = 0;
00296        i < this->count_;
00297        ++i)
00298     {
00299       const ACE_CString* uuidstr = endpoint->uuid_.to_string();
00300       CORBA::String_var uuid (uuidstr->c_str());
00301       endpoints[i].uuid = uuid;
00302       endpoints[i].priority = endpoint->priority ();
00303 
00304       endpoint = endpoint->next_;
00305     }
00306 
00307   // Encode the data structure.
00308   TAO_OutputCDR out_cdr;
00309   if ((out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)
00310        == 0)
00311       || (out_cdr << endpoints) == 0)
00312     return -1;
00313   size_t length = out_cdr.total_length ();
00314 
00315   IOP::TaggedComponent tagged_component;
00316   tagged_component.tag = TAO_TAG_ENDPOINTS;
00317   tagged_component.component_data.length (static_cast<CORBA::ULong> (length));
00318   CORBA::Octet *buf =
00319     tagged_component.component_data.get_buffer ();
00320 
00321   for (const ACE_Message_Block *iterator = out_cdr.begin ();
00322        iterator != 0;
00323        iterator = iterator->cont ())
00324     {
00325       size_t i_length = iterator->length ();
00326       ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);
00327 
00328       buf += i_length;
00329     }
00330 
00331   // Add component with encoded endpoint data to this profile's
00332   // TaggedComponents.
00333   tagged_components_.set_component (tagged_component);
00334 
00335   return  0;
00336 }

TAO_Endpoint * TAO_COIOP_Profile::endpoint void   )  [virtual]
 

Implements TAO_Profile.

Definition at line 189 of file COIOP_Profile.cpp.

Referenced by TAO_COIOP_Acceptor::create_new_profile(), TAO_COIOP_Acceptor::create_shared_profile(), and ~TAO_COIOP_Profile().

00190 {
00191   return &this->endpoint_;
00192 }

CORBA::ULong TAO_COIOP_Profile::endpoint_count void   )  const [virtual]
 

Implements TAO_Profile.

Definition at line 195 of file COIOP_Profile.cpp.

00196 {
00197   return this->count_;
00198 }

CORBA::ULong TAO_COIOP_Profile::hash CORBA::ULong  max  )  [virtual]
 

Implements TAO_Profile.

Definition at line 160 of file COIOP_Profile.cpp.

References TAO_COIOP_Endpoint::hash(), TAO_Profile::hash_service_i(), TAO::unbounded_value_sequence< T >::length(), TAO_GIOP_Message_Version::minor, TAO_COIOP_Endpoint::next_, TAO::Refcounted_ObjectKey::object_key(), and TAO_Profile::tag().

00161 {
00162   // Get the hashvalue for all endpoints.
00163   CORBA::ULong hashval = 0;
00164   for (TAO_COIOP_Endpoint *endp = &this->endpoint_;
00165        endp != 0;
00166        endp = endp->next_)
00167     {
00168       hashval += endp->hash ();
00169     }
00170 
00171   hashval += this->version_.minor;
00172   hashval += this->tag ();
00173 
00174   const TAO::ObjectKey &ok =
00175     this->ref_object_key_->object_key ();
00176 
00177   if (ok.length () >= 4)
00178     {
00179       hashval += ok[1];
00180       hashval += ok[3];
00181     }
00182 
00183   hashval += this->hash_service_i (max);
00184 
00185   return hashval % max;
00186 }

char TAO_COIOP_Profile::object_key_delimiter void   )  const [virtual]
 

Implements TAO_Profile.

Definition at line 28 of file COIOP_Profile.cpp.

References object_key_delimiter_.

00029 {
00030   return TAO_COIOP_Profile::object_key_delimiter_;
00031 }

void TAO_COIOP_Profile::parse_string_i const char *  string  )  [protected, virtual]
 

Implements TAO_Profile.

Definition at line 102 of file COIOP_Profile.cpp.

References TAO::ObjectKey_Table::bind(), TAO::ObjectKey::decode_string_to_sequence(), ACE_Utils::UUID::from_string(), TAO_ORB_Core::object_key_table(), TAO_Profile::orb_core(), ACE_OS::strchr(), CORBA::string_alloc(), ACE_OS::strncpy(), and TAO_COIOP_Endpoint::uuid_.

00103 {
00104   // Pull off the "hostname:port/" part of the objref
00105   // Copy the string because we are going to modify it...
00106   const char *okd =
00107     ACE_OS::strchr (ior, this->object_key_delimiter_);
00108 
00109   if (okd == 0 || okd == ior)
00110     {
00111       // No object key delimiter or no hostname specified.
00112       throw ::CORBA::INV_OBJREF (
00113                    CORBA::SystemException::_tao_minor_code (
00114                      TAO::VMCID,
00115                      EINVAL),
00116                    CORBA::COMPLETED_NO);
00117     }
00118 
00119   // Length of host string.
00120   CORBA::ULong length_host = okd - ior;
00121 
00122   CORBA::String_var tmp = CORBA::string_alloc (length_host);
00123 
00124   // Skip the trailing '/'
00125   ACE_OS::strncpy (tmp.inout (), ior, length_host);
00126   tmp[length_host] = '\0';
00127 
00128   this->endpoint_.uuid_.from_string (tmp._retn ());
00129 
00130   TAO::ObjectKey ok;
00131   TAO::ObjectKey::decode_string_to_sequence (ok,
00132                                              okd + 1);
00133 
00134   (void) this->orb_core ()->object_key_table ().bind (ok,
00135                                                       this->ref_object_key_);
00136 }

const char * TAO_COIOP_Profile::prefix void   )  [static]
 

Return the char string prefix.

Definition at line 248 of file COIOP_Profile.cpp.

00249 {
00250   return ::the_prefix;
00251 }

char * TAO_COIOP_Profile::to_string void   )  [virtual]
 

Template methods. Please tao/Profile.h for documentation.

Implements TAO_Profile.

Definition at line 210 of file COIOP_Profile.cpp.

References ACE_CString, TAO::ObjectKey::encode_sequence_to_string(), TAO::Refcounted_ObjectKey::object_key(), object_key_delimiter_, ACE_OS::sprintf(), CORBA::string_alloc(), ACE_OS::strlen(), the_prefix, ACE_Utils::UUID::to_string(), and TAO_COIOP_Endpoint::uuid_.

00211 {
00212   CORBA::String_var key;
00213   TAO::ObjectKey::encode_sequence_to_string (key.inout(),
00214                                             this->ref_object_key_->object_key ());
00215 
00216   const ACE_CString * uuidstr = this->endpoint_.uuid_.to_string ();
00217   size_t buflen = (8 /* "corbaloc" */ +
00218                    1 /* colon separator */ +
00219                    ACE_OS::strlen (::the_prefix) +
00220                    1 /* colon separator */ +
00221                    1 /* major version */ +
00222                    1 /* decimal point */ +
00223                    1 /* minor version */ +
00224                    1 /* `@' character */ +
00225                    uuidstr->length() +
00226                    1 /* colon separator */ +
00227                    5 /* port number */ +
00228                    1 /* object key separator */ +
00229                    ACE_OS::strlen (key.in ()));
00230 
00231   char * buf = CORBA::string_alloc (static_cast<CORBA::ULong> (buflen));
00232 
00233   static const char digits [] = "0123456789";
00234 
00235   ACE_OS::sprintf (buf,
00236                    "corbaloc:%s:%c.%c@%s%c%s",
00237                    ::the_prefix,
00238                    digits [this->version_.major],
00239                    digits [this->version_.minor],
00240                    uuidstr->c_str (),
00241                    this->object_key_delimiter_,
00242                    key.in ());
00243 
00244   return buf;
00245 }


Member Data Documentation

CORBA::ULong TAO_COIOP_Profile::count_ [protected]
 

Number of endpoints in the list headed by .

Definition at line 110 of file COIOP_Profile.h.

TAO_COIOP_Endpoint TAO_COIOP_Profile::endpoint_ [protected]
 

Head of this profile's list of endpoints. This endpoint is not dynamically allocated because a profile always contains at least one endpoint.

Currently, a profile contains more than one endpoint, i.e., list contains more than just the head, only when RTCORBA is enabled. However, in the near future, this will be used in nonRT mode as well, e.g., to support TAG_ALTERNATE_COIOP_ADDRESS feature. Addressing info of the default endpoint, i.e., head of the list, is transmitted using standard COIOP ProfileBody components. See method documentation above for how the rest of the endpoint list is transmitted.

Definition at line 107 of file COIOP_Profile.h.

Referenced by do_is_equivalent().

TAO_BEGIN_VERSIONED_NAMESPACE_DECL const char TAO_COIOP_Profile::object_key_delimiter_ = '/' [static]
 

The object key delimiter that COIOP uses or expects.

Definition at line 25 of file COIOP_Profile.cpp.

Referenced by object_key_delimiter(), and to_string().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 16:02:25 2008 for TAO_Strategies by doxygen 1.3.6