00001
00002
00003 #include "tao/Profile.h"
00004 #include "tao/Messaging_PolicyValueC.h"
00005 #include "tao/Stub.h"
00006 #include "tao/debug.h"
00007 #include "tao/target_specification.h"
00008 #include "tao/ORB_Core.h"
00009 #include "tao/Client_Strategy_Factory.h"
00010 #include "tao/CDR.h"
00011 #include "tao/SystemException.h"
00012 #include "tao/PolicyC.h"
00013 #include "tao/Endpoint.h"
00014
00015 #include "ace/ACE.h"
00016 #include "ace/OS_NS_string.h"
00017 #include "ace/OS_NS_ctype.h"
00018
00019 #if !defined (__ACE_INLINE__)
00020 #include "tao/Profile.inl"
00021 #endif
00022
00023
00024 ACE_RCSID (tao,
00025 Profile,
00026 "$Id: Profile.cpp 84909 2009-03-19 15:16:15Z johnnyw $")
00027
00028
00029
00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00031
00032 TAO_Profile::TAO_Profile (CORBA::ULong tag,
00033 TAO_ORB_Core *orb_core,
00034 const TAO::ObjectKey &obj_key,
00035 const TAO_GIOP_Message_Version &version)
00036 : version_ (version)
00037 , are_policies_parsed_ (false)
00038 , addressing_mode_ (0)
00039 , tagged_profile_ (0)
00040 , ref_object_key_ (0)
00041 , tag_ (tag)
00042 , orb_core_ (orb_core)
00043 , forward_to_ (0)
00044 , refcount_ (this->orb_core_->
00045 client_factory ()->create_profile_refcount ())
00046 , tagged_profile_lock_ ()
00047 , tagged_profile_created_ (false)
00048 {
00049 (void) this->orb_core_->object_key_table ().bind (obj_key,
00050 this->ref_object_key_);
00051 }
00052
00053 TAO_Profile::TAO_Profile (CORBA::ULong tag,
00054 TAO_ORB_Core *orb_core,
00055 const TAO_GIOP_Message_Version &version)
00056 : version_ (version)
00057 , are_policies_parsed_ (false)
00058 , addressing_mode_ (0)
00059 , tagged_profile_ (0)
00060 , ref_object_key_ (0)
00061 , tag_ (tag)
00062 , orb_core_ (orb_core)
00063 , forward_to_ (0)
00064 , refcount_ (this->orb_core_->
00065 client_factory ()->create_profile_refcount ())
00066 , tagged_profile_lock_ ()
00067 , tagged_profile_created_ (false)
00068 {
00069 }
00070
00071 TAO_Profile::~TAO_Profile (void)
00072 {
00073 if (this->tagged_profile_)
00074 {
00075 delete this->tagged_profile_;
00076 }
00077
00078 this->orb_core_->object_key_table ().unbind (this->ref_object_key_);
00079
00080
00081 }
00082
00083 void
00084 TAO_Profile::add_tagged_component (const IOP::TaggedComponent &component)
00085 {
00086
00087 this->verify_orb_configuration ();
00088
00089 this->verify_profile_version ();
00090
00091
00092
00093
00094
00095
00096
00097 this->tagged_components_.set_component (component);
00098 }
00099
00100
00101 TAO_Endpoint *
00102 TAO_Profile::base_endpoint (void)
00103 {
00104 return this->endpoint();
00105 }
00106
00107 TAO::ObjectKey *
00108 TAO_Profile::_key (void) const
00109 {
00110 TAO::ObjectKey *key = 0;
00111
00112 if (this->ref_object_key_)
00113 {
00114 ACE_NEW_RETURN (key,
00115 TAO::ObjectKey (this->ref_object_key_->object_key ()),
00116 0);
00117 }
00118 return key;
00119 }
00120
00121
00122 int
00123 TAO_Profile::encode (TAO_OutputCDR &stream) const
00124 {
00125
00126 stream.write_ulong (this->tag_);
00127
00128
00129 TAO_OutputCDR encap (ACE_CDR::DEFAULT_BUFSIZE,
00130 TAO_ENCAP_BYTE_ORDER,
00131 this->orb_core ()->output_cdr_buffer_allocator (),
00132 this->orb_core ()->output_cdr_dblock_allocator (),
00133 this->orb_core ()->output_cdr_msgblock_allocator (),
00134 this->orb_core ()->orb_params ()->cdr_memcpy_tradeoff (),
00135 TAO_DEF_GIOP_MAJOR,
00136 TAO_DEF_GIOP_MINOR);
00137
00138 #if defined (TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS)
00139
00140 (void) ACE_OS::memset (encap.current()->wr_ptr (),
00141 0,
00142 encap.current()->space ());
00143 #endif
00144
00145
00146 this->create_profile_body (encap);
00147
00148
00149 stream << CORBA::ULong (encap.total_length ());
00150 stream.write_octet_array_mb (encap.begin ());
00151
00152 return 1;
00153 }
00154
00155 int
00156 TAO_Profile::decode (TAO_InputCDR& cdr)
00157 {
00158 #if !defined (ACE_NLOGGING)
00159 size_t const encap_len = cdr.length ();
00160 #endif
00161
00162
00163
00164 if (!(cdr.read_octet (this->version_.major)
00165 && this->version_.major == TAO_DEF_GIOP_MAJOR
00166 && cdr.read_octet (this->version_.minor)
00167 && this->version_.minor <= TAO_DEF_GIOP_MINOR))
00168 {
00169 if (TAO_debug_level > 0)
00170 {
00171 ACE_DEBUG ((LM_DEBUG,
00172 ACE_TEXT ("TAO (%P|%t) - Profile::decode - v%d.%d\n"),
00173 this->version_.major,
00174 this->version_.minor));
00175 }
00176
00177 return -1;
00178 }
00179
00180
00181 if (this->decode_profile (cdr) < 0)
00182 {
00183 return -1;
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 TAO::ObjectKey ok;
00203
00204
00205 if (TAO::ObjectKey::demarshal_key (ok, cdr) == 0)
00206 {
00207 return -1;
00208 }
00209
00210 TAO::ObjectKey_Table &okt = this->orb_core ()->object_key_table ();
00211
00212 if (okt.bind (ok, this->ref_object_key_) == -1)
00213 {
00214 return -1;
00215 }
00216
00217
00218
00219 if (this->version_.major > 1 || this->version_.minor > 0)
00220 {
00221 if (this->tagged_components_.decode (cdr) == 0)
00222 {
00223 return -1;
00224 }
00225 }
00226
00227 if (cdr.length () != 0 && TAO_debug_level)
00228 {
00229
00230
00231 ACE_DEBUG ((LM_DEBUG,
00232 ACE_TEXT ("%d bytes out of %d left after profile data\n"),
00233 cdr.length (),
00234 encap_len));
00235 }
00236
00237
00238
00239 if (this->decode_endpoints () == -1)
00240 {
00241 return -1;
00242 }
00243
00244 return 1;
00245 }
00246
00247 IOP::TaggedProfile *
00248 TAO_Profile::create_tagged_profile (void)
00249 {
00250 if (this->tagged_profile_created_)
00251 return this->tagged_profile_;
00252
00253 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00254 guard,
00255 this->tagged_profile_lock_,
00256 this->tagged_profile_);
00257
00258
00259 if (!this->tagged_profile_created_)
00260 {
00261 ACE_NEW_RETURN (this->tagged_profile_,
00262 IOP::TaggedProfile,
00263 0);
00264
00265
00266 this->tagged_profile_->tag = this->tag_;
00267
00268
00269 TAO_OutputCDR encap (ACE_DEFAULT_CDR_BUFSIZE,
00270 TAO_ENCAP_BYTE_ORDER,
00271 this->orb_core ()->output_cdr_buffer_allocator (),
00272 this->orb_core ()->output_cdr_dblock_allocator (),
00273 this->orb_core ()->output_cdr_msgblock_allocator (),
00274 this->orb_core ()->orb_params ()->cdr_memcpy_tradeoff (),
00275 TAO_DEF_GIOP_MAJOR,
00276 TAO_DEF_GIOP_MINOR);
00277
00278
00279 this->create_profile_body (encap);
00280
00281 CORBA::ULong const length =
00282 static_cast <CORBA::ULong> (encap.total_length ());
00283
00284 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00285
00286
00287 this->tagged_profile_->profile_data.replace (length, encap.begin ());
00288 #else
00289 this->tagged_profile_->profile_data.length (length);
00290 CORBA::Octet *buffer =
00291 this->tagged_profile_->profile_data.get_buffer ();
00292
00293 for (const ACE_Message_Block *i = encap.begin ();
00294 i != encap.end ();
00295 i = i->next ())
00296 {
00297 ACE_OS::memcpy (buffer, i->rd_ptr (), i->length ());
00298 buffer += i->length ();
00299 }
00300 #endif
00301
00302 this->tagged_profile_created_ = true;
00303 }
00304
00305 return this->tagged_profile_;
00306 }
00307
00308 void
00309 TAO_Profile::set_tagged_components (TAO_OutputCDR &out_cdr)
00310 {
00311 CORBA::ULong const length = static_cast <CORBA::ULong> (out_cdr.total_length ());
00312
00313 IOP::TaggedComponent tagged_component;
00314 tagged_component.tag = TAO_TAG_ENDPOINTS;
00315 tagged_component.component_data.length (length);
00316 CORBA::Octet *buf = tagged_component.component_data.get_buffer ();
00317
00318 for (const ACE_Message_Block *iterator = out_cdr.begin ();
00319 iterator != 0;
00320 iterator = iterator->cont ())
00321 {
00322 size_t const i_length = iterator->length ();
00323 ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);
00324
00325 buf += i_length;
00326 }
00327
00328
00329
00330 tagged_components_.set_component (tagged_component);
00331 }
00332
00333
00334 void
00335 TAO_Profile::policies (CORBA::PolicyList *policy_list)
00336 {
00337 if (policy_list == 0)
00338 {
00339 if (TAO_debug_level)
00340 {
00341 ACE_DEBUG ((LM_DEBUG,
00342 ACE_TEXT ("TAO_Profile::policies: ")
00343 ACE_TEXT ("Null Policy List!\n")));
00344 }
00345
00346 return;
00347 }
00348
00349 Messaging::PolicyValueSeq policy_value_seq;
00350
00351 size_t length = 0;
00352 CORBA::Octet *buf = 0;
00353
00354
00355
00356 CORBA::ULong const plen = policy_list->length ();
00357
00358 policy_value_seq.length (plen);
00359
00360 for (CORBA::ULong i = 0; i < plen; ++i)
00361 {
00362 TAO_OutputCDR out_CDR;
00363 policy_value_seq[i].ptype = (*policy_list)[i]->policy_type ();
00364
00365 if (!(out_CDR << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)))
00366 return;
00367
00368 if (!((*policy_list)[i]->_tao_encode (out_CDR)))
00369 return;
00370
00371 length = out_CDR.total_length ();
00372 policy_value_seq[i].pvalue.length (static_cast <CORBA::ULong>(length));
00373
00374 buf = policy_value_seq[i].pvalue.get_buffer ();
00375
00376
00377
00378 for (const ACE_Message_Block *iterator = out_CDR.begin ();
00379 iterator != 0;
00380 iterator = iterator->cont ())
00381 {
00382 ACE_OS::memcpy (buf, iterator->rd_ptr (), iterator->length ());
00383 buf += iterator->length ();
00384 }
00385 }
00386
00387 TAO_OutputCDR out_cdr;
00388
00389
00390
00391 IOP::TaggedComponent tagged_component;
00392 tagged_component.tag = Messaging::TAG_POLICIES;
00393
00394 if (!(out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)))
00395 return;
00396
00397 if (!(out_cdr << policy_value_seq))
00398 return;
00399
00400 length = out_cdr.total_length ();
00401
00402 tagged_component.component_data.length (static_cast <CORBA::ULong>(length));
00403 buf = tagged_component.component_data.get_buffer ();
00404
00405 for (const ACE_Message_Block *iterator = out_cdr.begin ();
00406 iterator != 0;
00407 iterator = iterator->cont ())
00408 {
00409 size_t const i_length = iterator->length ();
00410 ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);
00411
00412 buf += i_length;
00413 }
00414
00415
00416
00417 tagged_components_.set_component (tagged_component);
00418 this->are_policies_parsed_ = true;
00419 }
00420
00421 void
00422 TAO_Profile::get_policies (CORBA::PolicyList& pl)
00423 {
00424 #if !defined(CORBA_E_MICRO)
00425 if (!this->are_policies_parsed_)
00426
00427 {
00428 IOP::TaggedComponent tagged_component;
00429 tagged_component.tag = Messaging::TAG_POLICIES;
00430
00431
00432
00433 if (this->tagged_components_.get_component (tagged_component))
00434 {
00435 const CORBA::Octet *buf =
00436 tagged_component.component_data.get_buffer ();
00437
00438 TAO_InputCDR in_cdr (reinterpret_cast <const char *> (buf),
00439 tagged_component.component_data.length ());
00440
00441
00442 CORBA::Boolean byte_order;
00443
00444 if (!(in_cdr >> ACE_InputCDR::to_boolean (byte_order)))
00445 {
00446 return;
00447 }
00448
00449 in_cdr.reset_byte_order (static_cast <int> (byte_order));
00450
00451
00452
00453 Messaging::PolicyValueSeq policy_value_seq;
00454
00455 if (!(in_cdr >> policy_value_seq))
00456 {
00457 throw ::CORBA::INV_OBJREF ();
00458 }
00459
00460
00461
00462 CORBA::ULong const length = policy_value_seq.length ();
00463
00464 for (CORBA::ULong i = 0; i < length; ++i)
00465 {
00466 try
00467 {
00468 CORBA::Policy_var policy =
00469 this->orb_core_->orb ()->_create_policy (
00470 policy_value_seq[i].ptype);
00471
00472 if (!CORBA::is_nil (policy.in ()))
00473 {
00474 buf = policy_value_seq[i].pvalue.get_buffer ();
00475
00476 TAO_InputCDR in_cdr (
00477 reinterpret_cast <const char*> (buf),
00478 policy_value_seq[i].pvalue.length ());
00479
00480 if (!(in_cdr >> ACE_InputCDR::to_boolean (byte_order)))
00481 throw ::CORBA::INV_OBJREF ();
00482
00483 in_cdr.reset_byte_order (static_cast <int> (byte_order));
00484
00485 if (!policy->_tao_decode (in_cdr))
00486 throw ::CORBA::INV_OBJREF ();
00487
00488
00489
00490 pl.length (pl.length () + 1);
00491
00492 pl[i] = policy._retn ();
00493 }
00494 else
00495 {
00496
00497
00498
00499
00500
00501 if (TAO_debug_level >= 5)
00502 ACE_DEBUG ((LM_DEBUG,
00503 ACE_TEXT ("The IOR contains unsupported ")
00504 ACE_TEXT ("policies.\n")));
00505 }
00506 }
00507 catch (const ::CORBA::Exception& ex)
00508 {
00509
00510
00511
00512
00513
00514 if (TAO_debug_level >= 5)
00515 ex._tao_print_exception (
00516 ACE_TEXT ("IOR contains ")
00517 ACE_TEXT ("unsupported policies."));
00518 }
00519 }
00520 }
00521 }
00522 #else
00523 ACE_UNUSED_ARG (pl);
00524 #endif
00525 }
00526
00527 void
00528 TAO_Profile::verify_orb_configuration (void)
00529 {
00530
00531
00532 if (!this->orb_core_->orb_params ()->std_profile_components ()
00533 || !this->orb_core_->orb ()->_use_omg_ior_format ())
00534 {
00535 if (TAO_debug_level > 0)
00536 {
00537 ACE_ERROR ((LM_ERROR,
00538 ACE_TEXT ("(%P|%t) Cannot add ")
00539 ACE_TEXT ("IOP::TaggedComponent to profile.\n")
00540 ACE_TEXT ("(%P|%t) Standard profile components ")
00541 ACE_TEXT ("have been disabled or URL style IORs\n")
00542 ACE_TEXT ("(%P|%t) are in use. Try ")
00543 ACE_TEXT ("\"-ORBStdProfileComponents 1\" and/or\n")
00544 ACE_TEXT ("(%P|%t) \"-ORBObjRefStyle IOR\".\n")));
00545 }
00546
00547
00548
00549
00550
00551
00552 throw ::CORBA::BAD_PARAM (
00553 CORBA::SystemException::_tao_minor_code (
00554 0,
00555 EINVAL),
00556 CORBA::COMPLETED_NO);
00557 }
00558 }
00559
00560 void
00561 TAO_Profile::verify_profile_version (void)
00562 {
00563
00564
00565
00566 if (this->version_.major == 1 && this->version_.minor == 0)
00567 {
00568 if (TAO_debug_level > 0)
00569 {
00570 ACE_ERROR ((LM_ERROR,
00571 ACE_TEXT ("(%P|%t) Cannot add ")
00572 ACE_TEXT ("IOP::TaggedComponent to GIOP 1.0")
00573 ACE_TEXT ("IOR profile.\n")
00574 ACE_TEXT ("(%P|%t) Try using a GIOP 1.1 or ")
00575 ACE_TEXT ("greater endpoint.\n")));
00576 }
00577
00578
00579
00580
00581
00582
00583 throw ::CORBA::BAD_PARAM (
00584 CORBA::SystemException::_tao_minor_code (
00585 0,
00586 EINVAL),
00587 CORBA::COMPLETED_NO);
00588 }
00589 }
00590
00591 int
00592 TAO_Profile::supports_multicast (void) const
00593 {
00594
00595 return 0;
00596 }
00597
00598 bool
00599 TAO_Profile::supports_non_blocking_oneways (void) const
00600 {
00601 return !(this->version_.major == 1 && this->version_.minor == 0);
00602 }
00603
00604 void
00605 TAO_Profile::addressing_mode (CORBA::Short addr)
00606 {
00607
00608 switch (addr)
00609 {
00610 case TAO_Target_Specification::Key_Addr:
00611 case TAO_Target_Specification::Profile_Addr:
00612 case TAO_Target_Specification::Reference_Addr:
00613 this->addressing_mode_ = addr;
00614 break;
00615
00616 default:
00617 throw ::CORBA::BAD_PARAM (
00618 CORBA::SystemException::_tao_minor_code (
00619 0,
00620 EINVAL),
00621 CORBA::COMPLETED_NO);
00622 }
00623 }
00624
00625 void
00626 TAO_Profile::parse_string (const char *ior)
00627 {
00628 if (!ior || !*ior)
00629 {
00630 throw ::CORBA::INV_OBJREF (
00631 CORBA::SystemException::_tao_minor_code (
00632 0,
00633 EINVAL),
00634 CORBA::COMPLETED_NO);
00635 }
00636
00637
00638
00639
00640
00641 if (ACE_OS::ace_isdigit (ior [0]) &&
00642 ior[1] == '.' &&
00643 ACE_OS::ace_isdigit (ior [2]) &&
00644 ior[3] == '@')
00645 {
00646
00647
00648 this->version_.set_version ((char) (ior[0] - '0'),
00649 (char) (ior[2] - '0'));
00650 ior += 4;
00651
00652 }
00653 else
00654 {
00655
00656 this->version_.set_version (1, 0);
00657 }
00658
00659 if (this->version_.major != TAO_DEF_GIOP_MAJOR ||
00660 this->version_.minor > TAO_DEF_GIOP_MINOR)
00661 {
00662 throw ::CORBA::INV_OBJREF (
00663 CORBA::SystemException::_tao_minor_code (
00664 0,
00665 EINVAL),
00666 CORBA::COMPLETED_NO);
00667 }
00668
00669 this->parse_string_i (ior);
00670 }
00671
00672 CORBA::Boolean
00673 TAO_Profile::is_equivalent (const TAO_Profile *other)
00674 {
00675 CORBA::Boolean result = false;
00676 if (other)
00677 {
00678 TAO_Service_Callbacks::Profile_Equivalence callback
00679 = this->is_equivalent_hook (other);
00680 switch (callback)
00681 {
00682 case TAO_Service_Callbacks::DONT_KNOW:
00683 return this->tag () == other->tag ()
00684 && this->version_ == other->version ()
00685 && this->endpoint_count () == other->endpoint_count ()
00686 && this->object_key () == other->object_key ()
00687 && this->do_is_equivalent (other);
00688 case TAO_Service_Callbacks::EQUIVALENT:
00689 result = true;
00690 break;
00691 case TAO_Service_Callbacks::NOT_EQUIVALENT:
00692 break;
00693 }
00694 }
00695 return result;
00696 }
00697
00698 CORBA::Boolean
00699 TAO_Profile::compare_key (const TAO_Profile *other) const
00700 {
00701 return (this->ref_object_key_ == other->ref_object_key_) ||
00702 ((this->ref_object_key_ != 0 &&
00703 other->ref_object_key_ != 0 &&
00704 this->ref_object_key_->object_key() ==
00705 other->ref_object_key_->object_key()));
00706 }
00707
00708 TAO_Endpoint *
00709 TAO_Profile::first_filtered_endpoint (void)
00710 {
00711 TAO_Endpoint *ep = this->endpoint();
00712 return ep == 0 ? 0 : ep->next_filtered(this->orb_core_,0);
00713 }
00714
00715 TAO_Endpoint *
00716 TAO_Profile::next_filtered_endpoint (TAO_Endpoint *source)
00717 {
00718 if (source == 0)
00719 return this->first_filtered_endpoint();
00720 return source->next_filtered(this->orb_core_,this->endpoint());
00721 }
00722
00723 void
00724 TAO_Profile::add_generic_endpoint (TAO_Endpoint *)
00725 {
00726
00727 }
00728
00729 TAO_Service_Callbacks::Profile_Equivalence
00730 TAO_Profile::is_equivalent_hook (const TAO_Profile *other)
00731 {
00732
00733 return this->orb_core_->is_profile_equivalent (this, other);
00734 }
00735
00736 CORBA::ULong
00737 TAO_Profile::hash_service_i (CORBA::ULong m)
00738 {
00739 return this->orb_core_->hash_service (this, m);
00740 }
00741
00742
00743
00744
00745
00746
00747
00748
00749 int
00750 TAO_Profile::encode_alternate_endpoints(void)
00751 {
00752
00753
00754
00755
00756
00757
00758 return 0;
00759 }
00760
00761 void
00762 TAO_Profile::remove_generic_endpoint (TAO_Endpoint *)
00763 {
00764
00765 }
00766
00767
00768
00769
00770
00771
00772
00773 TAO_Unknown_Profile::TAO_Unknown_Profile (CORBA::ULong tag,
00774 TAO_ORB_Core *orb_core)
00775 : TAO_Profile (tag,
00776 orb_core,
00777 TAO_GIOP_Message_Version (TAO_DEF_GIOP_MAJOR,
00778 TAO_DEF_GIOP_MINOR))
00779 {
00780 }
00781
00782 TAO_Endpoint*
00783 TAO_Unknown_Profile::endpoint (void)
00784 {
00785 return 0;
00786 }
00787
00788 CORBA::ULong
00789 TAO_Unknown_Profile::endpoint_count (void) const
00790 {
00791 return 0;
00792 }
00793
00794 void
00795 TAO_Unknown_Profile::parse_string (const char *)
00796 {
00797
00798 }
00799
00800 void
00801 TAO_Unknown_Profile::parse_string_i (const char *)
00802 {
00803
00804 }
00805
00806 char
00807 TAO_Unknown_Profile::object_key_delimiter (void) const
00808 {
00809 return 0;
00810 }
00811
00812 char *
00813 TAO_Unknown_Profile::to_string (void)
00814 {
00815
00816 return 0;
00817 }
00818
00819 int
00820 TAO_Unknown_Profile::decode (TAO_InputCDR& cdr)
00821 {
00822 if (!(cdr >> this->body_))
00823 {
00824 return -1;
00825 }
00826
00827 return 0;
00828 }
00829
00830 int
00831 TAO_Unknown_Profile::decode_profile (TAO_InputCDR &)
00832 {
00833 return 0;
00834 }
00835
00836 int
00837 TAO_Unknown_Profile::decode_endpoints (void)
00838 {
00839 return 0;
00840 }
00841
00842 int
00843 TAO_Unknown_Profile::encode (TAO_OutputCDR &stream) const
00844 {
00845 stream.write_ulong (this->tag ());
00846 return (stream << this->body_);
00847 }
00848
00849 int
00850 TAO_Unknown_Profile::encode_endpoints (void)
00851 {
00852 return 0;
00853 }
00854
00855 TAO::ObjectKey *
00856 TAO_Unknown_Profile::_key (void) const
00857 {
00858 return 0;
00859 }
00860
00861 CORBA::Boolean
00862 TAO_Unknown_Profile::do_is_equivalent (const TAO_Profile* other_profile)
00863 {
00864 const TAO_Unknown_Profile * op =
00865 dynamic_cast <const TAO_Unknown_Profile *> (other_profile);
00866
00867 return (CORBA::Boolean) (op == 0 ? 0 : this->body_ == op->body_);
00868 }
00869
00870 TAO_Service_Callbacks::Profile_Equivalence
00871 TAO_Unknown_Profile::is_equivalent_hook (const TAO_Profile * )
00872 {
00873
00874
00875
00876 return TAO_Service_Callbacks::DONT_KNOW;
00877 }
00878
00879 CORBA::ULong
00880 TAO_Unknown_Profile::hash (CORBA::ULong max)
00881 {
00882 return (ACE::hash_pjw (reinterpret_cast <const char*>
00883 (this->body_.get_buffer ()),
00884 this->body_.length ()) % max);
00885 }
00886
00887 void
00888 TAO_Unknown_Profile::create_profile_body (TAO_OutputCDR &) const
00889 {
00890
00891 return;
00892 }
00893
00894
00895
00896
00897
00898
00899
00900 CORBA::Boolean
00901 operator<< (TAO_OutputCDR& cdr, const TAO_opaque& x)
00902 {
00903 CORBA::ULong const length = x.length ();
00904 cdr.write_ulong (length);
00905
00906 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00907 if (x.mb () != 0)
00908 {
00909 cdr.write_octet_array_mb (x.mb ());
00910 }
00911 else
00912 #endif
00913 {
00914 cdr.write_octet_array (x.get_buffer (), length);
00915 }
00916
00917 return (CORBA::Boolean) cdr.good_bit ();
00918 }
00919
00920 CORBA::Boolean
00921 operator>>(TAO_InputCDR& cdr, TAO_opaque& x)
00922 {
00923 CORBA::ULong length;
00924 cdr.read_ulong (length);
00925
00926 #if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
00927 if(ACE_BIT_DISABLED(cdr.start()->flags(),
00928 ACE_Message_Block::DONT_DELETE)
00929 && (cdr.orb_core() == 0
00930 || 1 == cdr.orb_core()->
00931 resource_factory()->
00932 input_cdr_allocator_type_locked()
00933 )
00934 )
00935 {
00936 x.replace (length, cdr.start ());
00937 x.mb ()->wr_ptr (x.mb ()->rd_ptr () + length);
00938 cdr.skip_bytes (length);
00939 }
00940 else
00941 #endif
00942 {
00943 x.length (length);
00944 cdr.read_octet_array (x.get_buffer (), length);
00945 }
00946
00947 return (CORBA::Boolean) cdr.good_bit ();
00948 }
00949
00950 TAO_END_VERSIONED_NAMESPACE_DECL