#include <SHMIOP_Profile.h>
Inheritance diagram for TAO_SHMIOP_Profile:
Public Member Functions | |
virtual char | object_key_delimiter (void) const |
TAO_SHMIOP_Profile (const ACE_MEM_Addr &addr, const TAO::ObjectKey &object_key, const TAO_GIOP_Message_Version &version, TAO_ORB_Core *orb_core) | |
TAO_SHMIOP_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) | |
TAO_SHMIOP_Profile (TAO_ORB_Core *orb_core) | |
Profile constructor, default. | |
~TAO_SHMIOP_Profile (void) | |
Destructor is to be called only through . | |
virtual char * | to_string (void) |
Template methods, please see Profile.h for documentation. | |
virtual int | encode_endpoints (void) |
virtual TAO_Endpoint * | endpoint (void) |
virtual CORBA::ULong | endpoint_count (void) const |
virtual CORBA::ULong | hash (CORBA::ULong max) |
void | add_endpoint (TAO_SHMIOP_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 SHMIOP 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) |
Private Attributes | |
TAO_SHMIOP_Endpoint | endpoint_ |
CORBA::ULong | count_ |
Number of endpoints in the list headed by . |
This class defines the SHMIOP profile.
Definition at line 45 of file SHMIOP_Profile.h.
|
Profile constructor, same as above except the object_key has already been marshaled. Definition at line 33 of file SHMIOP_Profile.cpp. References TAO_TAG_SHMEM_PROFILE.
00037 : TAO_Profile (TAO_TAG_SHMEM_PROFILE, 00038 orb_core, 00039 object_key, 00040 version), 00041 endpoint_ (addr, 00042 orb_core->orb_params ()->use_dotted_decimal_addresses ()), 00043 count_ (1) 00044 { 00045 } |
|
Profile constructor, this is the most efficient since it doesn't require any address resolution processing. Definition at line 47 of file SHMIOP_Profile.cpp. References TAO_TAG_SHMEM_PROFILE.
00053 : TAO_Profile (TAO_TAG_SHMEM_PROFILE, 00054 orb_core, 00055 object_key, 00056 version), 00057 endpoint_ (host, port, addr), 00058 count_ (1) 00059 { 00060 } |
|
Profile constructor, default.
Definition at line 62 of file SHMIOP_Profile.cpp. References TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR, and TAO_TAG_SHMEM_PROFILE.
00063 : TAO_Profile (TAO_TAG_SHMEM_PROFILE, 00064 orb_core, 00065 TAO_GIOP_Message_Version (TAO_DEF_GIOP_MAJOR, TAO_DEF_GIOP_MINOR)), 00066 endpoint_ (), 00067 count_ (1) 00068 { 00069 } |
|
Destructor is to be called only through .
Definition at line 71 of file SHMIOP_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 } |
|
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 323 of file SHMIOP_Profile.cpp. References TAO_SHMIOP_Endpoint::next_. Referenced by TAO_SHMIOP_Acceptor::create_shared_profile(), and decode_endpoints().
|
|
Implements TAO_Profile. Definition at line 375 of file SHMIOP_Profile.cpp. References 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_OutputCDR::write_octet(), ACE_OutputCDR::write_string(), and ACE_OutputCDR::write_ushort().
00376 { 00377 encap.write_octet (TAO_ENCAP_BYTE_ORDER); 00378 00379 // The GIOP version 00380 encap.write_octet (this->version_.major); 00381 encap.write_octet (this->version_.minor); 00382 00383 // STRING hostname from profile 00384 encap.write_string (this->endpoint_.host ()); 00385 00386 // UNSIGNED SHORT port number 00387 encap.write_ushort (this->endpoint_.port ()); 00388 00389 // OCTET SEQUENCE for object key 00390 if (this->ref_object_key_) 00391 encap << this->ref_object_key_->object_key (); 00392 else 00393 { 00394 ACE_ERROR ((LM_ERROR, 00395 "(%P|%t) TAO - UIOP_Profile::create_profile_body " 00396 "no object key marshalled \n")); 00397 } 00398 00399 if (this->version_.major > 1 00400 || this->version_.minor > 0) 00401 this->tagged_components ().encode (encap); 00402 } |
|
Implements TAO_Profile. Definition at line 460 of file SHMIOP_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(), and IOP::TaggedComponent::tag.
00461 { 00462 IOP::TaggedComponent tagged_component; 00463 tagged_component.tag = TAO_TAG_ENDPOINTS; 00464 00465 if (this->tagged_components_.get_component (tagged_component)) 00466 { 00467 const CORBA::Octet *buf = 00468 tagged_component.component_data.get_buffer (); 00469 00470 TAO_InputCDR in_cdr (reinterpret_cast <const char*> (buf), 00471 tagged_component.component_data.length ()); 00472 00473 // Extract the Byte Order. 00474 CORBA::Boolean byte_order; 00475 if ((in_cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) 00476 return -1; 00477 in_cdr.reset_byte_order (static_cast<int> (byte_order)); 00478 00479 // Extract endpoints sequence. 00480 TAO::IIOPEndpointSequence endpoints; 00481 00482 if ((in_cdr >> endpoints) == 0) 00483 return -1; 00484 00485 // Get the priority of the first endpoint (head of the list. 00486 // It's other data is extracted as part of the standard profile 00487 // decoding. 00488 this->endpoint_.priority (endpoints[0].priority); 00489 00490 // Use information extracted from the tagged component to 00491 // populate the profile. Skip the first endpoint, since it is 00492 // always extracted through standard profile body. Also, begin 00493 // from the end of the sequence to preserve endpoint order, 00494 // since <add_endpoint> method reverses the order of endpoints 00495 // in the list. 00496 for (CORBA::ULong i = endpoints.length () - 1; 00497 i > 0; 00498 --i) 00499 { 00500 TAO_SHMIOP_Endpoint *endpoint = 0; 00501 ACE_NEW_RETURN (endpoint, 00502 TAO_SHMIOP_Endpoint (endpoints[i].host, 00503 endpoints[i].port, 00504 endpoints[i].priority), 00505 -1); 00506 00507 this->add_endpoint (endpoint); 00508 } 00509 } 00510 00511 return 0; 00512 } |
|
Template methods. Please see tao/Profile.h for documentation.
Implements TAO_Profile. Definition at line 103 of file SHMIOP_Profile.cpp. References ACE_DEBUG, ACE_TEXT, ACE_InputCDR::good_bit(), LM_DEBUG, TAO_SHMIOP_Endpoint::object_addr_, ACE_InputCDR::read_string(), ACE_InputCDR::read_ushort(), ACE_Addr::set_type(), and TAO_debug_level.
00104 { 00105 // Decode host and port into the <endpoint_>. 00106 if (cdr.read_string (this->endpoint_.host_.out ()) == 0 00107 || cdr.read_ushort (this->endpoint_.port_) == 0) 00108 { 00109 if (TAO_debug_level > 0) 00110 { 00111 ACE_DEBUG ((LM_DEBUG, 00112 ACE_TEXT ("TAO (%P|%t) SHMIOP_Profile::decode - ") 00113 ACE_TEXT ("error while decoding host/port"))); 00114 } 00115 return -1; 00116 } 00117 00118 if (cdr.good_bit ()) 00119 { 00120 // Invalidate the object_addr_ until first access. 00121 this->endpoint_.object_addr_.set_type (-1); 00122 00123 return 1; 00124 } 00125 00126 return -1; 00127 } |
|
Implements TAO_Profile. Definition at line 269 of file SHMIOP_Profile.cpp. References endpoint_, TAO_SHMIOP_Endpoint::is_equivalent(), and TAO_SHMIOP_Endpoint::next_.
00270 { 00271 const TAO_SHMIOP_Profile *op = 00272 dynamic_cast <const TAO_SHMIOP_Profile *> (other_profile); 00273 00274 if (op == 0) 00275 return 0; 00276 00277 // Check endpoints equivalence. 00278 const TAO_SHMIOP_Endpoint *other_endp = &op->endpoint_; 00279 for (TAO_SHMIOP_Endpoint *endp = &this->endpoint_; 00280 endp != 0; 00281 endp = endp->next_) 00282 { 00283 if (endp->is_equivalent (other_endp)) 00284 other_endp = other_endp->next_; 00285 else 00286 return 0; 00287 } 00288 00289 return 1; 00290 } |
|
Implements TAO_Profile. Definition at line 405 of file SHMIOP_Profile.cpp. References ACE_OutputCDR::begin(), IOP::TaggedComponent::component_data, ACE_Message_Block::cont(), TAO_SHMIOP_Endpoint::host(), ACE_Message_Block::length(), ACE_OS::memcpy(), TAO_SHMIOP_Endpoint::next_, TAO_SHMIOP_Endpoint::port(), TAO_Endpoint::priority(), ACE_Message_Block::rd_ptr(), TAO_Tagged_Components::set_component(), IOP::TaggedComponent::tag, TAO_ENCAP_BYTE_ORDER, and ACE_OutputCDR::total_length().
00406 { 00407 // Create a data structure and fill it with endpoint info for wire 00408 // transfer. 00409 // We include information for the head of the list 00410 // together with other endpoints because even though its addressing 00411 // info is transmitted using standard ProfileBody components, its 00412 // priority is not! 00413 TAO::IIOPEndpointSequence endpoints; 00414 endpoints.length (this->count_); 00415 00416 TAO_SHMIOP_Endpoint *endpoint = &this->endpoint_; 00417 for (CORBA::ULong i = 0; 00418 i < this->count_; 00419 ++i) 00420 { 00421 endpoints[i].host = endpoint->host (); 00422 endpoints[i].port = endpoint->port (); 00423 endpoints[i].priority = endpoint->priority (); 00424 00425 endpoint = endpoint->next_; 00426 } 00427 00428 // Encode the data structure. 00429 TAO_OutputCDR out_cdr; 00430 if ((out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) 00431 == 0) 00432 || (out_cdr << endpoints) == 0) 00433 return -1; 00434 size_t length = out_cdr.total_length (); 00435 00436 IOP::TaggedComponent tagged_component; 00437 tagged_component.tag = TAO_TAG_ENDPOINTS; 00438 tagged_component.component_data.length (static_cast <CORBA::ULong>(length)); 00439 CORBA::Octet *buf = 00440 tagged_component.component_data.get_buffer (); 00441 00442 for (const ACE_Message_Block *iterator = out_cdr.begin (); 00443 iterator != 0; 00444 iterator = iterator->cont ()) 00445 { 00446 size_t i_length = iterator->length (); 00447 ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length); 00448 00449 buf += i_length; 00450 } 00451 00452 // Add component with encoded endpoint data to this profile's 00453 // TaggedComponents. 00454 tagged_components_.set_component (tagged_component); 00455 00456 return 0; 00457 } |
|
Implements TAO_Profile. Definition at line 87 of file SHMIOP_Profile.cpp. Referenced by TAO_SHMIOP_Acceptor::create_new_profile(), and ~TAO_SHMIOP_Profile().
00088 { 00089 return &this->endpoint_; 00090 } |
|
Implements TAO_Profile. Definition at line 93 of file SHMIOP_Profile.cpp.
00094 { 00095 return this->count_; 00096 } |
|
Implements TAO_Profile. Definition at line 293 of file SHMIOP_Profile.cpp. References TAO_SHMIOP_Endpoint::hash(), TAO_Profile::hash_service_i(), TAO::unbounded_value_sequence< T >::length(), TAO_GIOP_Message_Version::minor, TAO_SHMIOP_Endpoint::next_, TAO::Refcounted_ObjectKey::object_key(), and TAO_Profile::tag().
00295 { 00296 // Get the hashvalue for all endpoints. 00297 CORBA::ULong hashval = 0; 00298 for (TAO_SHMIOP_Endpoint *endp = &this->endpoint_; 00299 endp != 0; 00300 endp = endp->next_) 00301 { 00302 hashval += endp->hash (); 00303 } 00304 00305 hashval += this->version_.minor; 00306 hashval += this->tag (); 00307 00308 const TAO::ObjectKey &ok = 00309 this->ref_object_key_->object_key (); 00310 00311 if (ok.length () >= 4) 00312 { 00313 hashval += ok[1]; 00314 hashval += ok[3]; 00315 } 00316 00317 hashval += this->hash_service_i (max); 00318 00319 return hashval % max; 00320 } |
|
Implements TAO_Profile. Definition at line 28 of file SHMIOP_Profile.cpp. References object_key_delimiter_.
00029 { 00030 return TAO_SHMIOP_Profile::object_key_delimiter_; 00031 } |
|
Implements TAO_Profile. Definition at line 130 of file SHMIOP_Profile.cpp. References ACE_DEBUG, ACE_TEXT, ACE_OS::atoi(), TAO::ObjectKey_Table::bind(), TAO::ObjectKey::decode_string_to_sequence(), ACE_INET_Addr::get_host_addr(), ACE_INET_Addr::get_host_name(), ACE_INET_Addr::get_port_number(), TAO_SHMIOP_Endpoint::host_, LM_DEBUG, MAXHOSTNAMELEN, TAO_SHMIOP_Endpoint::object_addr_, TAO_ORB_Core::object_key_table(), TAO_Profile::orb_core(), TAO_SHMIOP_Endpoint::port_, ACE_INET_Addr::set(), ACE_OS::strchr(), ACE_OS::strcmp(), CORBA::string_alloc(), ACE_INET_Addr::string_to_addr(), ACE_OS::strncpy(), ACE_OS::strspn(), and TAO_debug_level.
00132 { 00133 // Pull off the "hostname:port/" part of the objref 00134 // Copy the string because we are going to modify it... 00135 CORBA::String_var copy (string); 00136 00137 char *start = copy.inout (); 00138 char *cp = ACE_OS::strchr (start, ':'); // Look for a port 00139 00140 if (cp == 0) 00141 { 00142 // No host/port delimiter! 00143 throw ::CORBA::INV_OBJREF ( 00144 CORBA::SystemException::_tao_minor_code ( 00145 TAO::VMCID, 00146 EINVAL), 00147 CORBA::COMPLETED_NO); 00148 } 00149 00150 char *okd = ACE_OS::strchr (start, this->object_key_delimiter_); 00151 00152 if (okd == 0) 00153 { 00154 // No object key delimiter! 00155 throw ::CORBA::INV_OBJREF ( 00156 CORBA::SystemException::_tao_minor_code ( 00157 TAO::VMCID, 00158 EINVAL), 00159 CORBA::COMPLETED_NO); 00160 } 00161 00162 // Don't increment the pointer 'cp' directly since we still need 00163 // to use it immediately after this block. 00164 00165 CORBA::ULong length = okd - (cp + 1); 00166 // Don't allocate space for the colon ':'. 00167 00168 CORBA::String_var tmp = CORBA::string_alloc (length); 00169 00170 ACE_OS::strncpy (tmp.inout (), cp + 1, length); 00171 tmp[length] = '\0'; 00172 00173 if (ACE_OS::strspn (tmp.in (), "1234567890") == length) 00174 { 00175 this->endpoint_.port_ = 00176 static_cast <CORBA::UShort> (ACE_OS::atoi (tmp.in ())); 00177 } 00178 else 00179 { 00180 ACE_INET_Addr ia; 00181 if (ia.string_to_addr (tmp.in ()) == -1) 00182 { 00183 throw ::CORBA::INV_OBJREF ( 00184 CORBA::SystemException::_tao_minor_code ( 00185 TAO::VMCID, 00186 EINVAL), 00187 CORBA::COMPLETED_NO); 00188 } 00189 else 00190 { 00191 this->endpoint_.port_ = ia.get_port_number (); 00192 } 00193 } 00194 00195 length = cp - start; 00196 00197 tmp = CORBA::string_alloc (length); 00198 00199 ACE_OS::strncpy (tmp.inout (), start, length); 00200 tmp[length] = '\0'; 00201 00202 this->endpoint_.host_ = tmp._retn (); 00203 00204 ACE_INET_Addr host_addr; 00205 00206 if (ACE_OS::strcmp (this->endpoint_.host_.in (), "") == 0) 00207 { 00208 char tmp_host [MAXHOSTNAMELEN + 1]; 00209 00210 // If no host is specified: assign the default host : the local host. 00211 if (host_addr.get_host_name (tmp_host, 00212 sizeof (tmp_host)) != 0) 00213 { 00214 const char *tmp = host_addr.get_host_addr (); 00215 if (tmp == 0) 00216 { 00217 if (TAO_debug_level > 0) 00218 ACE_DEBUG ((LM_DEBUG, 00219 ACE_TEXT ("\n\nTAO (%P|%t) ") 00220 ACE_TEXT ("SHMIOP_Profile::parse_string ") 00221 ACE_TEXT ("- %p\n\n"), 00222 ACE_TEXT ("cannot determine hostname"))); 00223 00224 // @@ What's the right exception to throw here? 00225 throw ::CORBA::INV_OBJREF ( 00226 CORBA::SystemException::_tao_minor_code ( 00227 TAO::VMCID, 00228 EINVAL), 00229 CORBA::COMPLETED_NO); 00230 } 00231 else 00232 this->endpoint_.host_ = tmp; 00233 } 00234 else 00235 { 00236 this->endpoint_.host_ = (const char *) tmp_host; 00237 } 00238 } 00239 00240 if (this->endpoint_.object_addr_.set (this->endpoint_.port_, 00241 this->endpoint_.host_.in ()) == -1) 00242 { 00243 if (TAO_debug_level > 0) 00244 { 00245 ACE_DEBUG ((LM_DEBUG, 00246 ACE_TEXT ("TAO (%P|%t) SHMIOP_Profile::parse_string () - \n") 00247 ACE_TEXT ("TAO (%P|%t) ACE_INET_Addr::set () failed"))); 00248 } 00249 00250 // @@ What's the right exception to throw here? 00251 throw ::CORBA::INV_OBJREF ( 00252 CORBA::SystemException::_tao_minor_code ( 00253 TAO::VMCID, 00254 EINVAL), 00255 CORBA::COMPLETED_NO); 00256 } 00257 00258 start = ++okd; // increment past the object key separator 00259 00260 TAO::ObjectKey ok; 00261 TAO::ObjectKey::decode_string_to_sequence (ok, 00262 okd + 1); 00263 00264 (void) this->orb_core ()->object_key_table ().bind (ok, 00265 this->ref_object_key_); 00266 } |
|
Return the char string prefix.
Definition at line 369 of file SHMIOP_Profile.cpp.
00370 { 00371 return ::prefix_; 00372 } |
|
Template methods, please see Profile.h for documentation.
Implements TAO_Profile. Definition at line 332 of file SHMIOP_Profile.cpp. References TAO::ObjectKey::encode_sequence_to_string(), TAO::Refcounted_ObjectKey::object_key(), object_key_delimiter_, TAO_SHMIOP_Endpoint::port(), prefix_, ACE_OS::sprintf(), CORBA::string_alloc(), and ACE_OS::strlen().
00333 { 00334 CORBA::String_var key; 00335 TAO::ObjectKey::encode_sequence_to_string (key.inout(), 00336 this->ref_object_key_->object_key ()); 00337 00338 size_t buflen = (8 /* corbaloc */ + 00339 1 /* colon separator */ + 00340 ACE_OS::strlen (::prefix_) + 00341 1 /* colon separator */ + 00342 1 /* major version */ + 00343 1 /* decimal point */ + 00344 1 /* minor version */ + 00345 1 /* `@' character */ + 00346 ACE_OS::strlen (this->endpoint_.host ()) + 00347 1 /* colon separator */ + 00348 5 /* port number */ + 00349 1 /* object key separator */ + 00350 ACE_OS::strlen (key.in ())); 00351 00352 char * buf = CORBA::string_alloc (static_cast <CORBA::ULong> (buflen)); 00353 00354 static const char digits [] = "0123456789"; 00355 00356 ACE_OS::sprintf (buf, 00357 "corbaloc:%s:%c.%c@%s:%d%c%s", 00358 ::prefix_, 00359 digits [this->version_.major], 00360 digits [this->version_.minor], 00361 this->endpoint_.host (), 00362 this->endpoint_.port (), 00363 this->object_key_delimiter_, 00364 key.in ()); 00365 return buf; 00366 } |
|
Number of endpoints in the list headed by .
Definition at line 122 of file SHMIOP_Profile.h. |
|
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-style feature. Addressing info of the default endpoint, i.e., head of the list, is transmitted using standard SHMIOP ProfileBody components. See method documentation above for how the rest of the endpoint list is transmitted. Definition at line 119 of file SHMIOP_Profile.h. Referenced by do_is_equivalent(). |
|
The object key delimiter that SHMIOP uses or expects.
Definition at line 25 of file SHMIOP_Profile.cpp. Referenced by object_key_delimiter(), and to_string(). |