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

TAO_IIOP_Profile Class Reference

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

#include <IIOP_Profile.h>

Inheritance diagram for TAO_IIOP_Profile:

Inheritance graph
[legend]
Collaboration diagram for TAO_IIOP_Profile:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual char object_key_delimiter (void) const
 The object key delimiter. More...

 TAO_IIOP_Profile (const ACE_INET_Addr &addr, const TAO_ObjectKey &object_key, const TAO_GIOP_Message_Version &version, TAO_ORB_Core *orb_core)
 Profile constructor, same as above except the object_key has already been marshaled. More...

 TAO_IIOP_Profile (const char *host, CORBA::UShort port, const TAO_ObjectKey &object_key, const ACE_INET_Addr &addr, 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. More...

 TAO_IIOP_Profile (TAO_ORB_Core *orb_core)
 Profile constructor, default. More...

 ~TAO_IIOP_Profile (void)
 Destructor is to be called only through <_decr_refcnt>. More...

virtual void parse_string (const char *string ACE_ENV_ARG_DECL)
 Initialize this object using the given input string. Url-style string contain only one endpoint. More...

virtual char * to_string (ACE_ENV_SINGLE_ARG_DECL)
virtual int decode (TAO_InputCDR &cdr)
 Initialize this object using the given CDR octet string. More...

virtual int encode (TAO_OutputCDR &stream) const
 Encode this profile in a stream, i.e. marshal it. More...

virtual int encode_endpoints (void)
virtual const TAO_ObjectKeyobject_key (void) const
 deprecated. return a reference to the Object Key. More...

virtual TAO_ObjectKey_key (void) const
 Return a pointer to the Object Key. The caller owns the memory allocated for the returned key. More...

virtual TAO_Endpointendpoint (void)
 Return pointer to the head of this profile's endpoints list. More...

virtual CORBA::ULong endpoint_count (void)
 Return how many endpoints this profile contains. More...

void add_endpoint (TAO_IIOP_Endpoint *endp)
virtual CORBA::Boolean is_equivalent (const TAO_Profile *other_profile)
virtual CORBA::ULong hash (CORBA::ULong max ACE_ENV_ARG_DECL)
 Return a hash value for this object. More...

virtual IOP::TaggedProfilecreate_tagged_profile (void)
 Please refer to Profile.h for the documentation of this function. More...


Static Public Methods

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


Static Public Attributes

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


Protected Attributes

TAO_IIOP_Endpoint endpoint_
CORBA::ULong count_
 Number of endpoints in the list headed by <endpoint_>. More...


Private Methods

void create_profile_body (TAO_OutputCDR &cdr) const
 Creates an encapsulation of the ProfileBody struct in the <cdr>. More...

int decode_endpoints (void)
int encode_endpoints_for_rt (void)

Private Attributes

TAO_ObjectKey object_key_
 object_key associated with this profile. More...

IOP::TaggedProfile tagged_profile_
 Our tagged profile. More...


Detailed Description

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

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

Definition at line 43 of file IIOP_Profile.h.


Constructor & Destructor Documentation

TAO_IIOP_Profile::TAO_IIOP_Profile const ACE_INET_Addr   addr,
const TAO_ObjectKey   object_key,
const TAO_GIOP_Message_Version   version,
TAO_ORB_Core   orb_core
 

Profile constructor, same as above except the object_key has already been marshaled.

Definition at line 33 of file IIOP_Profile.cpp.

References IOP::TAG_INTERNET_IOP.

00037   : TAO_Profile (IOP::TAG_INTERNET_IOP, orb_core, version),
00038     endpoint_ (addr,
00039                orb_core->orb_params ()->use_dotted_decimal_addresses ()),
00040     count_ (1),
00041     object_key_ (object_key),
00042     tagged_profile_ ()
00043 {
00044 }

TAO_IIOP_Profile::TAO_IIOP_Profile const char *    host,
CORBA::UShort    port,
const TAO_ObjectKey   object_key,
const ACE_INET_Addr   addr,
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 46 of file IIOP_Profile.cpp.

References IOP::TAG_INTERNET_IOP.

00052   : TAO_Profile (IOP::TAG_INTERNET_IOP, orb_core, version),
00053     endpoint_ (host, port, addr),
00054     count_ (1),
00055     object_key_ (object_key),
00056     tagged_profile_ ()
00057 {
00058 }

TAO_IIOP_Profile::TAO_IIOP_Profile TAO_ORB_Core   orb_core
 

Profile constructor, default.

Definition at line 60 of file IIOP_Profile.cpp.

References IOP::TAG_INTERNET_IOP, TAO_DEF_GIOP_MAJOR, and TAO_DEF_GIOP_MINOR.

00061   : TAO_Profile (IOP::TAG_INTERNET_IOP,
00062                  orb_core,
00063                  TAO_GIOP_Message_Version (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR)),
00064     endpoint_ (),
00065     count_ (1),
00066     object_key_ (),
00067     tagged_profile_ ()
00068 {
00069 }

TAO_IIOP_Profile::~TAO_IIOP_Profile void   
 

Destructor is to be called only through <_decr_refcnt>.

Definition at line 71 of file IIOP_Profile.cpp.

References endpoint, and TAO_Endpoint::next.

00072 {
00073   // Clean up the list of endpoints since we own it.
00074   // Skip the head, since it is not dynamically allocated.
00075   TAO_Endpoint *tmp = 0;
00076 
00077   for (TAO_Endpoint *next = this->endpoint ()->next ();
00078        next != 0;
00079        next = tmp)
00080     {
00081       tmp = next->next ();
00082       delete next;
00083     }
00084 }


Member Function Documentation

ACE_INLINE TAO_ObjectKey * TAO_IIOP_Profile::_key void    const [virtual]
 

Return a pointer to the Object Key. The caller owns the memory allocated for the returned key.

Implements TAO_Profile.

Definition at line 11 of file IIOP_Profile.i.

References ACE_NEW_RETURN.

00012 {
00013   TAO_ObjectKey *key = 0;
00014 
00015   ACE_NEW_RETURN (key,
00016                   TAO_ObjectKey (this->object_key_),
00017                   0);
00018 
00019   return key;
00020 }

void TAO_IIOP_Profile::add_endpoint TAO_IIOP_Endpoint   endp
 

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

Definition at line 369 of file IIOP_Profile.cpp.

References count_, endpoint_, and TAO_IIOP_Endpoint::next_.

Referenced by TAO_IIOP_Acceptor::create_shared_profile, and decode_endpoints.

00370 {
00371   endp->next_ = this->endpoint_.next_;
00372   this->endpoint_.next_ = endp;
00373 
00374   this->count_++;
00375 }

void TAO_IIOP_Profile::create_profile_body TAO_OutputCDR   cdr const [private]
 

Creates an encapsulation of the ProfileBody struct in the <cdr>.

Definition at line 499 of file IIOP_Profile.cpp.

References TAO_Tagged_Components::encode, TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, object_key_, TAO_Profile::tagged_components, TAO_ENCAP_BYTE_ORDER, TAO_Profile::version_, ACE_OutputCDR::write_octet, ACE_OutputCDR::write_string, and ACE_OutputCDR::write_ushort.

Referenced by create_tagged_profile, and encode.

00500 {
00501   encap.write_octet (TAO_ENCAP_BYTE_ORDER);
00502 
00503   // The GIOP version
00504   encap.write_octet (this->version_.major);
00505   encap.write_octet (this->version_.minor);
00506 
00507   // STRING hostname from profile
00508   encap.write_string (this->endpoint_.host ());
00509 
00510   // UNSIGNED SHORT port number
00511   encap.write_ushort (this->endpoint_.port ());
00512 
00513   // OCTET SEQUENCE for object key
00514   encap << this->object_key_;
00515 
00516   if (this->version_.major > 1
00517       || this->version_.minor > 0)
00518     this->tagged_components ().encode (encap);
00519 }

IOP::TaggedProfile & TAO_IIOP_Profile::create_tagged_profile void    [virtual]
 

Please refer to Profile.h for the documentation of this function.

Implements TAO_Profile.

Definition at line 452 of file IIOP_Profile.cpp.

References ACE_OutputCDR::begin, TAO_ORB_Parameters::cdr_memcpy_tradeoff, create_profile_body, ACE_CDR::DEFAULT_BUFSIZE, ACE_OutputCDR::end, ACE_Message_Block::length, ACE_OS_String::memcpy, ACE_Message_Block::next, TAO_Profile::orb_core, TAO_ORB_Core::orb_params, TAO_ORB_Core::output_cdr_dblock_allocator, TAO_ORB_Core::output_cdr_msgblock_allocator, IOP::TaggedProfile::profile_data, ACE_Message_Block::rd_ptr, IOP::TaggedProfile::tag, tagged_profile_, TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, TAO_ENCAP_BYTE_ORDER, and ACE_OutputCDR::total_length.

00453 {
00454   // Check whether we have already created the TaggedProfile
00455   if (this->tagged_profile_.profile_data.get_buffer () == 0)
00456     {
00457       // As we have not created we will now create the TaggedProfile
00458       this->tagged_profile_.tag = IOP::TAG_INTERNET_IOP;
00459 
00460       // Create the encapsulation....
00461       TAO_OutputCDR encap (ACE_CDR::DEFAULT_BUFSIZE,
00462                            TAO_ENCAP_BYTE_ORDER,
00463                            this->orb_core ()->output_cdr_buffer_allocator (),
00464                            this->orb_core ()->output_cdr_dblock_allocator (),
00465                            this->orb_core ()->output_cdr_msgblock_allocator (),
00466                            this->orb_core ()->orb_params ()->cdr_memcpy_tradeoff (),
00467                            TAO_DEF_GIOP_MAJOR,
00468                            TAO_DEF_GIOP_MINOR);
00469 
00470       // Create the profile body
00471       this->create_profile_body (encap);
00472 
00473       CORBA::ULong length =
00474         ACE_static_cast(CORBA::ULong,encap.total_length ());
00475 
00476 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00477       // Place the message block in to the Sequence of Octets that we
00478       // have
00479       this->tagged_profile_.profile_data.replace (length,
00480                                                   encap.begin ());
00481 #else
00482       this->tagged_profile_.profile_data.length (length);
00483       CORBA::Octet *buffer =
00484         this->tagged_profile_.profile_data.get_buffer ();
00485       for (const ACE_Message_Block *i = encap.begin ();
00486            i != encap.end ();
00487            i = i->next ())
00488         {
00489           ACE_OS::memcpy (buffer, i->rd_ptr (), i->length ());
00490           buffer += i->length ();
00491         }
00492 #endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */
00493     }
00494 
00495   return this->tagged_profile_;
00496 }

int TAO_IIOP_Profile::decode TAO_InputCDR   cdr [virtual]
 

Initialize this object using the given CDR octet string.

Implements TAO_Profile.

Definition at line 92 of file IIOP_Profile.cpp.

References ACE_DEBUG, ACE_TEXT, TAO_Tagged_Components::decode, decode_endpoints, endpoint_, ACE_InputCDR::good_bit, ACE_InputCDR::length, LM_DEBUG, TAO_GIOP_Message_Version::major, TAO_GIOP_Message_Version::minor, TAO_IIOP_Endpoint::object_addr_, object_key_, ACE_InputCDR::read_octet, ACE_InputCDR::read_string, ACE_InputCDR::read_ushort, TAO_Profile::tagged_components_, TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, and TAO_Profile::version_.

00093 {
00094   size_t encap_len = cdr.length ();
00095 
00096   // Read and verify major, minor versions, ignoring IIOP profiles
00097   // whose versions we don't understand.
00098   CORBA::Octet major = 0, minor = 0;
00099 
00100   if (!(cdr.read_octet (major)
00101         && major == TAO_DEF_GIOP_MAJOR
00102         && cdr.read_octet (minor)))
00103     {
00104       if (TAO_debug_level > 0)
00105         ACE_DEBUG ((LM_DEBUG,
00106                     ACE_TEXT ("TAO (%P|%t) IIOP_Profile::decode - v%d.%d\n"),
00107                     major,
00108                     minor));
00109       return -1;
00110     }
00111 
00112   this->version_.major = major;
00113 
00114   if (minor <= TAO_DEF_GIOP_MINOR)
00115     this->version_.minor = minor;
00116 
00117   // Decode host and port into the <endpoint_>.
00118   if (cdr.read_string (this->endpoint_.host_.out ()) == 0
00119       || cdr.read_ushort (this->endpoint_.port_) == 0)
00120     {
00121       if (TAO_debug_level > 0)
00122         ACE_DEBUG ((LM_DEBUG,
00123                     ACE_TEXT ("TAO (%P|%t) IIOP_Profile::decode - ")
00124                     ACE_TEXT ("error while decoding host/port")));
00125       return -1;
00126     }
00127 
00128   // ... and object key.
00129 
00130   if ((cdr >> this->object_key_) == 0)
00131     return -1;
00132 
00133   // Tagged Components *only* exist after version 1.0!
00134   // For GIOP 1.2, IIOP and GIOP have same version numbers!
00135   if (this->version_.major > 1
00136       || this->version_.minor > 0)
00137     if (this->tagged_components_.decode (cdr) == 0)
00138       return -1;
00139 
00140   if (cdr.length () != 0 && TAO_debug_level)
00141     // If there is extra data in the profile we are supposed to
00142     // ignore it, but print a warning just in case...
00143     ACE_DEBUG ((LM_DEBUG,
00144                 ACE_TEXT ("%d bytes out of %d left after IIOP profile data\n"),
00145                 cdr.length (),
00146                 encap_len));
00147 
00148   // Decode any additional endpoints per profile.  (At the present,
00149   // only RTCORBA takes advantage of this feature. Or the server must
00150   // have been run with -ORBUseSharedProfiles option turned on)
00151   if (this->decode_endpoints () == -1)
00152     return -1;
00153 
00154   if (cdr.good_bit ())
00155     {
00156       // Invalidate the object_addr_ until first access.
00157       this->endpoint_.object_addr_.set_type (-1);
00158 
00159       return 1;
00160     }
00161 
00162   return -1;
00163 }

int TAO_IIOP_Profile::decode_endpoints void    [private]
 

Helper for <decode>. Decodes endpoints from a tagged component. Decode only if RTCORBA is enabled. Furthermore, we may not find TAO_TAG_ENDPOINTS component, e.g., if we are talking to nonRT version of TAO or some other ORB. This is not an error, and we must proceed. Return 0 on success and -1 on failure.

Definition at line 645 of file IIOP_Profile.cpp.

References ACE_NEW_RETURN, add_endpoint, IOP::TaggedComponent::component_data, endpoint, endpoint_, TAO_Tagged_Components::get_component, TAG_ALTERNATE_IIOP_Endpoint_Info::host, TAG_ALTERNATE_IIOP_Endpoint_Info::port, TAO_Endpoint::priority, ACE_InputCDR::reset_byte_order, IOP::TaggedComponent::tag, TAO_Profile::tagged_components_, TAO_IIOPEndpointSequence, TAO_INVALID_PRIORITY, and TAO_TAG_ENDPOINTS.

Referenced by decode.

00646 {
00647   IOP::TaggedComponent tagged_component;
00648   tagged_component.tag = TAO_TAG_ENDPOINTS;
00649 
00650   if (this->tagged_components_.get_component (tagged_component))
00651     {
00652       const CORBA::Octet *buf =
00653         tagged_component.component_data.get_buffer ();
00654 
00655       TAO_InputCDR in_cdr (ACE_reinterpret_cast (const char*, buf),
00656                            tagged_component.component_data.length ());
00657 
00658       // Extract the Byte Order.
00659       CORBA::Boolean byte_order;
00660       if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
00661         return -1;
00662       in_cdr.reset_byte_order (ACE_static_cast(int, byte_order));
00663 
00664       // Extract endpoints sequence.
00665       TAO_IIOPEndpointSequence endpoints;
00666 
00667       if ((in_cdr >> endpoints) == 0)
00668         return -1;
00669 
00670       // Get the priority of the first endpoint (head of the list.
00671       // It's other data is extracted as part of the standard profile
00672       // decoding.
00673       this->endpoint_.priority (endpoints[0].priority);
00674 
00675       // Use information extracted from the tagged component to
00676       // populate the profile.  Skip the first endpoint, since it is
00677       // always extracted through standard profile body.  Also, begin
00678       // from the end of the sequence to preserve endpoint order,
00679       // since <add_endpoint> method reverses the order of endpoints
00680       // in the list.
00681       for (CORBA::ULong i = endpoints.length () - 1;
00682            i > 0;
00683            --i)
00684         {
00685           TAO_IIOP_Endpoint *endpoint = 0;
00686           ACE_NEW_RETURN (endpoint,
00687                           TAO_IIOP_Endpoint (endpoints[i].host,
00688                                              endpoints[i].port,
00689                                              endpoints[i].priority),
00690                           -1);
00691 
00692           this->add_endpoint (endpoint);
00693         }
00694     }
00695 
00696   // Now decode if there is TAG_ALTERNATE_IIOP_ADDRESS
00697   // component.
00698 
00699   // Check if there is any data at all. If there is no data,
00700   // return. If it was because of an error, the control wouldnt come
00701   // here. But, doublecheck just in case.
00702   if ((tagged_component.component_data.length () == 0))
00703     return 0;
00704 
00705   tagged_component.tag = IOP::TAG_ALTERNATE_IIOP_ADDRESS;
00706 
00707   if (this->tagged_components_.get_component (tagged_component))
00708     {
00709       const CORBA::Octet *buf =
00710         tagged_component.component_data.get_buffer ();
00711 
00712       TAO_InputCDR in_cdr (ACE_reinterpret_cast (const char*, buf),
00713                            tagged_component.component_data.length ());
00714 
00715       // Extract the Byte Order.
00716       CORBA::Boolean byte_order;
00717       if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
00718         return -1;
00719 
00720       in_cdr.reset_byte_order (ACE_static_cast(int, byte_order));
00721 
00722       TAG_ALTERNATE_IIOP_Endpoint_Info ei;
00723 
00724       if ((in_cdr >> ei) == 0)
00725         return -1;
00726 
00727       TAO_IIOP_Endpoint *endpoint = 0;
00728       ACE_NEW_RETURN (endpoint,
00729                       TAO_IIOP_Endpoint (ei.host,
00730                                          ei.port,
00731                                          TAO_INVALID_PRIORITY),
00732                       -1);
00733 
00734       this->add_endpoint (endpoint);
00735     }
00736 
00737   return 0;
00738 }

int TAO_IIOP_Profile::encode TAO_OutputCDR   stream const [virtual]
 

Encode this profile in a stream, i.e. marshal it.

Implements TAO_Profile.

Definition at line 424 of file IIOP_Profile.cpp.

References ACE_OutputCDR::begin, TAO_ORB_Parameters::cdr_memcpy_tradeoff, create_profile_body, ACE_CDR::DEFAULT_BUFSIZE, TAO_Profile::orb_core, TAO_ORB_Core::orb_params, TAO_ORB_Core::output_cdr_dblock_allocator, TAO_ORB_Core::output_cdr_msgblock_allocator, TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, TAO_ENCAP_BYTE_ORDER, ACE_OutputCDR::total_length, CORBA::ULong, ACE_OutputCDR::write_octet_array_mb, and ACE_OutputCDR::write_ulong.

00425 {
00426   // UNSIGNED LONG, protocol tag
00427   stream.write_ulong (this->tag ());
00428 
00429   // Create the encapsulation....
00430   TAO_OutputCDR encap (ACE_CDR::DEFAULT_BUFSIZE,
00431                        TAO_ENCAP_BYTE_ORDER,
00432                        this->orb_core ()->output_cdr_buffer_allocator (),
00433                        this->orb_core ()->output_cdr_dblock_allocator (),
00434                        this->orb_core ()->output_cdr_msgblock_allocator (),
00435                        this->orb_core ()->orb_params ()->cdr_memcpy_tradeoff (),
00436                        TAO_DEF_GIOP_MAJOR,
00437                        TAO_DEF_GIOP_MINOR);
00438 
00439   // Create the profile body
00440   this->create_profile_body (encap);
00441 
00442   // write the encapsulation as an octet sequence...
00443 
00444   stream << CORBA::ULong (encap.total_length ());
00445   stream.write_octet_array_mb (encap.begin ());
00446 
00447   return 1;
00448 }

int TAO_IIOP_Profile::encode_endpoints void    [virtual]
 

Encodes this profile's endpoints into a tagged component. This is done only if RTCORBA is enabled, since currently this is the only case when we have more than one endpoint per profile. Returns 0 on success and -1 on failure.

Endpoints are transmitted using TAO-proprietory tagged component. Component tag is TAO_TAG_ENDPOINTS and component data is an encapsulation of a sequence of structs, each representing a single endpoint. Data format is specified in iiop_endpoins.pidl.

Multiple TAG_ALTERNATE_IIOP_ADDRESS components can be used instead of a single proprietory component to transmit multiple endpoints. This is somewhat slower and less convenient. Also, TAG_ALTERNATE_IIOP_ADDRESS does not provide for transmission of endpoint priorities.

Implements TAO_Profile.

Definition at line 579 of file IIOP_Profile.cpp.

References ACE_OutputCDR::begin, IOP::TaggedComponent::component_data, ACE_Message_Block::cont, count_, encode_endpoints_for_rt, endpoint, endpoint_, TAO_IIOP_Endpoint::host, TAG_ALTERNATE_IIOP_Endpoint_Info::host, ACE_Message_Block::length, ACE_OS_String::memcpy, TAO_IIOP_Endpoint::next_, TAO_IIOP_Endpoint::port, TAG_ALTERNATE_IIOP_Endpoint_Info::port, TAO_Endpoint::priority, ACE_Message_Block::rd_ptr, TAO_Tagged_Components::set_component, IOP::TaggedComponent::tag, TAO_Profile::tagged_components_, TAO_ENCAP_BYTE_ORDER, TAO_INVALID_PRIORITY, and ACE_OutputCDR::total_length.

00580 {
00581   // Create a data structure and fill it with endpoint info for wire
00582   // transfer both for RT requests and non-RT.
00583   const TAO_IIOP_Endpoint *endpoint = &this->endpoint_;
00584 
00585   if (endpoint->priority () != TAO_INVALID_PRIORITY)
00586     {
00587       // RT requests
00588       if (this->encode_endpoints_for_rt () == -1)
00589         return -1;
00590     }
00591 
00592   // All kind of requests if there are more than one endpoints for one
00593   // profile. Use the spec standard.
00594   TAG_ALTERNATE_IIOP_Endpoint_Info ai;
00595 
00596   // encode IOP::TAG_ALTERNATE_IIOP_ADDRESS tag if there are more
00597   // than one endpoints to listen to.
00598   for (CORBA::ULong i = 1;
00599        i < this->count_;
00600        ++i)
00601     {
00602       // The first endpoint is the actual endpoint. The rest of the
00603       // endpoints are the alternate endpoints. So, neglect the first
00604       // endpoint for TAG_ALTERNATE_IIOP_ADDRESS
00605       endpoint = endpoint->next_;
00606 
00607       ai.host = endpoint->host ();
00608       ai.port = endpoint->port ();
00609 
00610       // Encode the data structure.
00611       TAO_OutputCDR out_cdr;
00612 
00613       if ((out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)
00614            == 0)
00615           || (out_cdr << ai) == 0)
00616         return -1;
00617 
00618       IOP::TaggedComponent tagged_component;
00619       tagged_component.tag = IOP::TAG_ALTERNATE_IIOP_ADDRESS;
00620 
00621       size_t length = out_cdr.total_length ();
00622       tagged_component.component_data.length (ACE_static_cast(CORBA::ULong,
00623                                                               length));
00624       CORBA::Octet *buf =
00625         tagged_component.component_data.get_buffer ();
00626 
00627       for (const ACE_Message_Block *iterator = out_cdr.begin ();
00628            iterator != 0;
00629            iterator = iterator->cont ())
00630         {
00631           size_t i_length = iterator->length ();
00632           ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);
00633 
00634           buf += i_length;
00635         }
00636 
00637       // Add component with encoded endpoint data to this profile's
00638       // TaggedComponents.
00639       tagged_components_.set_component (tagged_component);
00640     }
00641   return  0;
00642 }

int TAO_IIOP_Profile::encode_endpoints_for_rt void    [private]
 

Helper method for encode_endpoints to deal with RT requests.

Encodes this profile's endpoints into a tagged component. This is done only if RTCORBA is enabled, since currently this is the only case when we have more than one endpoint per profile. Returns 0 on success and -1 on failure.

Endpoints are transmitted using TAO-proprietory tagged component. Component tag is TAO_TAG_ENDPOINTS and component data is an encapsulation of a sequence of structs, each representing a single endpoint. Data format is specified in iiop_endpoins.pidl.

Definition at line 522 of file IIOP_Profile.cpp.

References ACE_OutputCDR::begin, IOP::TaggedComponent::component_data, ACE_Message_Block::cont, count_, endpoint, endpoint_, TAO_IIOP_Endpoint::host, ACE_Message_Block::length, ACE_OS_String::memcpy, TAO_IIOP_Endpoint::next_, TAO_IIOP_Endpoint::port, TAO_Endpoint::priority, ACE_Message_Block::rd_ptr, TAO_Tagged_Components::set_component, IOP::TaggedComponent::tag, TAO_Profile::tagged_components_, TAO_ENCAP_BYTE_ORDER, TAO_IIOPEndpointSequence, TAO_TAG_ENDPOINTS, and ACE_OutputCDR::total_length.

Referenced by encode_endpoints.

00523 {
00524   // Create a data structure and fill it with endpoint info for wire
00525   // transfer.
00526   // We include information for the head of the list
00527   // together with other endpoints because even though its addressing
00528   // info is transmitted using standard ProfileBody components, its
00529   // priority is not!
00530 
00531   TAO_IIOPEndpointSequence endpoints;
00532   endpoints.length (this->count_);
00533 
00534   const TAO_IIOP_Endpoint *endpoint = &this->endpoint_;
00535   for (CORBA::ULong i = 0;
00536        i < this->count_;
00537        ++i)
00538     {
00539       endpoints[i].host = endpoint->host ();
00540       endpoints[i].port = endpoint->port ();
00541       endpoints[i].priority = endpoint->priority ();
00542 
00543       endpoint = endpoint->next_;
00544     }
00545 
00546   // Encode the data structure.
00547   TAO_OutputCDR out_cdr;
00548   if ((out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)
00549        == 0)
00550       || (out_cdr << endpoints) == 0)
00551     return -1;
00552   size_t length = out_cdr.total_length ();
00553 
00554   IOP::TaggedComponent tagged_component;
00555   tagged_component.tag = TAO_TAG_ENDPOINTS;
00556   tagged_component.component_data.length (ACE_static_cast(CORBA::ULong,
00557                                                           length));
00558   CORBA::Octet *buf =
00559     tagged_component.component_data.get_buffer ();
00560 
00561   for (const ACE_Message_Block *iterator = out_cdr.begin ();
00562        iterator != 0;
00563        iterator = iterator->cont ())
00564     {
00565       size_t i_length = iterator->length ();
00566       ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);
00567 
00568       buf += i_length;
00569     }
00570 
00571   // Add component with encoded endpoint data to this profile's
00572   // TaggedComponents.
00573   tagged_components_.set_component (tagged_component);
00574 
00575   return  0;
00576 }

TAO_Endpoint * TAO_IIOP_Profile::endpoint void    [virtual]
 

Return pointer to the head of this profile's endpoints list.

Implements TAO_Profile.

Definition at line 357 of file IIOP_Profile.cpp.

References endpoint_.

Referenced by TAO_IIOP_Acceptor::create_new_profile, TAO_IIOP_Acceptor::create_shared_profile, decode_endpoints, encode_endpoints, encode_endpoints_for_rt, and ~TAO_IIOP_Profile.

00358 {
00359   return &this->endpoint_;
00360 }

CORBA::ULong TAO_IIOP_Profile::endpoint_count void    [virtual]
 

Return how many endpoints this profile contains.

Implements TAO_Profile.

Definition at line 363 of file IIOP_Profile.cpp.

References count_.

00364 {
00365   return this->count_;
00366 }

CORBA::ULong TAO_IIOP_Profile::hash CORBA::ULong max    ACE_ENV_ARG_DECL [virtual]
 

Return a hash value for this object.

Implements TAO_Profile.

Definition at line 332 of file IIOP_Profile.cpp.

References ACE_ENV_ARG_DECL_NOT_USED, endpoint_, TAO_IIOP_Endpoint::hash, TAO_Unbounded_Base_Sequence::length, TAO_GIOP_Message_Version::minor, TAO_IIOP_Endpoint::next_, object_key_, TAO_Profile::tag, and TAO_Profile::version_.

00334 {
00335   // Get the hashvalue for all endpoints.
00336   CORBA::ULong hashval = 0;
00337   for (TAO_IIOP_Endpoint *endp = &this->endpoint_;
00338        endp != 0;
00339        endp = endp->next_)
00340     {
00341       hashval += endp->hash ();
00342     }
00343 
00344   hashval += this->version_.minor;
00345   hashval += this->tag ();
00346 
00347   if (this->object_key_.length () >= 4)
00348     {
00349       hashval += this->object_key_ [1];
00350       hashval += this->object_key_ [3];
00351     }
00352 
00353   return hashval % max;
00354 }

CORBA::Boolean TAO_IIOP_Profile::is_equivalent const TAO_Profile   other_profile [virtual]
 

Return true if this profile is equivalent to other_profile. Two profiles are equivalent iff their tag, object_key, version and all endpoints are the same.

Implements TAO_Profile.

Definition at line 301 of file IIOP_Profile.cpp.

References count_, endpoint_, TAO_IIOP_Endpoint::is_equivalent, TAO_IIOP_Endpoint::next_, object_key_, TAO_Profile::tag, and TAO_Profile::version_.

00302 {
00303 
00304   if (other_profile->tag () != IOP::TAG_INTERNET_IOP)
00305     return 0;
00306 
00307   const TAO_IIOP_Profile *op =
00308     ACE_dynamic_cast (const TAO_IIOP_Profile *, other_profile);
00309 
00310 
00311   if (!(this->object_key_ == op->object_key_
00312         && this->version_ == op->version_
00313         && this->count_ == op->count_))
00314     return 0;
00315 
00316   // Check endpoints equivalence.
00317   const TAO_IIOP_Endpoint *other_endp = &op->endpoint_;
00318   for (TAO_IIOP_Endpoint *endp = &this->endpoint_;
00319        endp != 0;
00320        endp = endp->next_)
00321     {
00322       if (endp->is_equivalent (other_endp))
00323         other_endp = other_endp->next_;
00324       else
00325         return 0;
00326     }
00327 
00328   return 1;
00329 }

ACE_INLINE const TAO_ObjectKey & TAO_IIOP_Profile::object_key void    const [virtual]
 

deprecated. return a reference to the Object Key.

@

Implements TAO_Profile.

Definition at line 5 of file IIOP_Profile.i.

References object_key_.

00006 {
00007   return this->object_key_;
00008 }

char TAO_IIOP_Profile::object_key_delimiter void    const [virtual]
 

The object key delimiter.

Implements TAO_Profile.

Definition at line 26 of file IIOP_Profile.cpp.

References object_key_delimiter_.

00027 {
00028   return TAO_IIOP_Profile::object_key_delimiter_;
00029 }

virtual void TAO_IIOP_Profile::parse_string const char *string    ACE_ENV_ARG_DECL [virtual]
 

Initialize this object using the given input string. Url-style string contain only one endpoint.

Implements TAO_Profile.

const char * TAO_IIOP_Profile::prefix void    [static]
 

Return the char string prefix.

Definition at line 418 of file IIOP_Profile.cpp.

00419 {
00420   return ::prefix_;
00421 }

char * TAO_IIOP_Profile::to_string ACE_ENV_SINGLE_ARG_DECL    [virtual]
 

Return a string representation for this profile. client must deallocate memory. This is used to create url-style reference. Only one endpoint is included into the string.

Implements TAO_Profile.

Definition at line 378 of file IIOP_Profile.cpp.

References ACE_ENV_SINGLE_ARG_DECL_NOT_USED, TAO_ObjectKey::encode_sequence_to_string, endpoint_, object_key_, object_key_delimiter_, TAO_IIOP_Endpoint::port, prefix_, ACE_OS::sprintf, CORBA::string_alloc, and ACE_OS_String::strlen.

00379 {
00380   CORBA::String_var key;
00381   TAO_ObjectKey::encode_sequence_to_string (key.inout(),
00382                                             this->object_key_);
00383 
00384   size_t buflen = (8 /* "corbaloc" */ +
00385                    1 /* colon separator */ +
00386                    ACE_OS::strlen (::prefix_) +
00387                    1 /* colon separator */ +
00388                    1 /* major version */ +
00389                    1 /* decimal point */ +
00390                    1 /* minor version */ +
00391                    1 /* `@' character */ +
00392                    ACE_OS::strlen (this->endpoint_.host ()) +
00393                    1 /* colon separator */ +
00394                    5 /* port number */ +
00395                    1 /* object key separator */ +
00396                    ACE_OS::strlen (key.in ()));
00397 
00398   char * buf = CORBA::string_alloc (ACE_static_cast(CORBA::ULong, buflen));
00399 
00400   static const char digits [] = "0123456789";
00401 
00402   ACE_OS::sprintf (buf,
00403                    "corbaloc:%s:%c.%c@%s:%d%c%s",
00404                    ::prefix_,
00405                    digits [this->version_.major],
00406                    digits [this->version_.minor],
00407                    this->endpoint_.host (),
00408                    this->endpoint_.port (),
00409                    this->object_key_delimiter_,
00410                    key.in ());
00411 
00412   return buf;
00413 }


Member Data Documentation

CORBA::ULong TAO_IIOP_Profile::count_ [protected]
 

Number of endpoints in the list headed by <endpoint_>.

Definition at line 198 of file IIOP_Profile.h.

Referenced by add_endpoint, encode_endpoints, encode_endpoints_for_rt, endpoint_count, and is_equivalent.

TAO_IIOP_Endpoint TAO_IIOP_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_IIOP_ADDRESS feature. Addressing info of the default endpoint, i.e., head of the list, is transmitted using standard IIOP ProfileBody components. See <encode_endpoints> method documentation above for how the rest of the endpoint list is transmitted.

Definition at line 195 of file IIOP_Profile.h.

Referenced by add_endpoint, decode, decode_endpoints, encode_endpoints, encode_endpoints_for_rt, endpoint, hash, is_equivalent, and to_string.

TAO_ObjectKey TAO_IIOP_Profile::object_key_ [private]
 

object_key associated with this profile.

Definition at line 203 of file IIOP_Profile.h.

Referenced by create_profile_body, decode, hash, is_equivalent, object_key, and to_string.

const char TAO_IIOP_Profile::object_key_delimiter_ = '/' [static]
 

The object key delimiter that IIOP uses or expects.

Definition at line 23 of file IIOP_Profile.cpp.

Referenced by object_key_delimiter, TAO_IIOP_Connector::object_key_delimiter, and to_string.

IOP::TaggedProfile TAO_IIOP_Profile::tagged_profile_ [private]
 

Our tagged profile.

Definition at line 206 of file IIOP_Profile.h.

Referenced by create_tagged_profile.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:20:40 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002