Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes

TAO_Profile Class Reference

Defines the Profile interface. More...

#include <Profile.h>

Inheritance diagram for TAO_Profile:
Inheritance graph
[legend]
Collaboration diagram for TAO_Profile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_Profile (CORBA::ULong tag, TAO_ORB_Core *orb_core, const TAO_GIOP_Message_Version &version)
 Constructor.
Non virtual methods for the profile classes.

CORBA::ULong tag (void) const
 The tag, each concrete class will have a specific tag value.
const TAO_GIOP_Message_Versionversion (void) const
TAO_ORB_Coreorb_core (void) const
 Get a pointer to the TAO_ORB_Core.
unsigned long _incr_refcnt (void)
 Increase the reference count by one on this object.
unsigned long _decr_refcnt (void)
void forward_to (TAO_MProfile *mprofiles)
 Keep a pointer to the forwarded profile.
TAO_MProfileforward_to (void)
 MProfile accessor.
const TAO_Tagged_Componentstagged_components (void) const
TAO_Tagged_Componentstagged_components (void)
 The tag, each concrete class will have a specific tag value.
void add_tagged_component (const IOP::TaggedComponent &component)
 Add the given tagged component to the profile.
CORBA::Short addressing_mode (void) const
const TAO::ObjectKey & object_key (void) const
TAO::ObjectKey * _key (void) const
Template methods that needs to be implemented by the

concrete classes. Some of the methods may be overridden only under specila circumstances.

virtual int encode (TAO_OutputCDR &stream) const
 Encode this profile in a stream, i.e. marshal it.
virtual int decode (TAO_InputCDR &cdr)
 Initialize this object using the given CDR octet string.
IOP::TaggedProfile * create_tagged_profile (void)
virtual void policies (CORBA::PolicyList *policy_list)
virtual void get_policies (CORBA::PolicyList &policy_list)
 Accessor for the client exposed policies of this profile.
virtual int supports_multicast (void) const
 Returns true if this profile can specify multicast endpoints.
virtual bool supports_non_blocking_oneways (void) const
 Returns true if this profile supports non blocking oneways.
virtual void addressing_mode (CORBA::Short addr_mode)
virtual char object_key_delimiter (void) const =0
 The object key delimiter.
virtual void parse_string (const char *string)
virtual char * to_string (void)=0
virtual int encode_endpoints (void)=0
virtual int encode_alternate_endpoints (void)
virtual TAO_Endpointendpoint (void)=0
virtual TAO_Endpointbase_endpoint (void)
virtual CORBA::ULong endpoint_count (void) const =0
 Return how many endpoints this profile contains.
TAO_Endpointfirst_filtered_endpoint (void)
TAO_Endpointnext_filtered_endpoint (TAO_Endpoint *source)
virtual void remove_generic_endpoint (TAO_Endpoint *ep)
virtual void add_generic_endpoint (TAO_Endpoint *ep)
 Add a protocol-agnostic endpoint.
CORBA::Boolean is_equivalent (const TAO_Profile *other_profile)
 Verify profile equivalance.
CORBA::Boolean compare_key (const TAO_Profile *other) const
virtual CORBA::ULong hash (CORBA::ULong max)=0
 Return a hash value for this object.

Protected Member Functions

virtual ~TAO_Profile (void)
 If you have a virtual method you need a virtual dtor.
 TAO_Profile (CORBA::ULong tag, TAO_ORB_Core *orb_core, const TAO::ObjectKey &key, const TAO_GIOP_Message_Version &version)
 To be used by inherited classes.
void set_tagged_components (TAO_OutputCDR &cdr)
virtual CORBA::Boolean do_is_equivalent (const TAO_Profile *other)=0
 Profile equivalence template method invoked on subclasses.
virtual
TAO_Service_Callbacks::Profile_Equivalence 
is_equivalent_hook (const TAO_Profile *other)
 Allow services to apply their own definition of "equivalence.".
CORBA::ULong hash_service_i (CORBA::ULong m)
Protected template methods.

virtual int decode_profile (TAO_InputCDR &cdr)=0
 Decode the protocol specific profile details.
virtual void create_profile_body (TAO_OutputCDR &cdr) const =0
 Creates an encapsulation of the ProfileBody struct in the cdr.
virtual int decode_endpoints (void)=0
virtual void parse_string_i (const char *string)=0
 Protocol specific implementation of parse_string ().

Protected Attributes

TAO_GIOP_Message_Version version_
 IIOP version number.
TAO_Tagged_Components tagged_components_
 The tagged components.
CORBA::Boolean are_policies_parsed_
CORBA::Short addressing_mode_
IOP::TaggedProfile * tagged_profile_
 Our tagged profile.
TAO::Refcounted_ObjectKey * ref_object_key_
 Object_key associated with this profile.

Private Member Functions

TAO_MProfileforward_to_i (void)
 This object keeps ownership of this object.
void verify_orb_configuration (void)
void verify_profile_version (void)
 TAO_Profile (const TAO_Profile &)
void operator= (const TAO_Profile &)

Private Attributes

CORBA::ULong const tag_
 IOP protocol tag.
TAO_ORB_Core *const orb_core_
 Pointer to the ORB core.
TAO_MProfileforward_to_
TAO_Configurable_Refcount refcount_
 Number of outstanding references to this object.
TAO_SYNCH_MUTEX tagged_profile_lock_
 A lock that protects creation of the tagged profile.
bool tagged_profile_created_

Detailed Description

Defines the Profile interface.

An abstract base class for representing object location information. This is based on the CORBA IOR definitions.

Definition at line 54 of file Profile.h.


Constructor & Destructor Documentation

TAO_Profile::TAO_Profile ( CORBA::ULong  tag,
TAO_ORB_Core orb_core,
const TAO_GIOP_Message_Version version 
)

Constructor.

Definition at line 53 of file Profile.cpp.

  : version_ (version)
    , are_policies_parsed_ (false)
    , addressing_mode_ (0)
    , tagged_profile_ (0)
    , ref_object_key_ (0)
    , tag_ (tag)
    , orb_core_ (orb_core)
    , forward_to_ (0)
    , refcount_ (this->orb_core_->
                   client_factory ()->create_profile_refcount ())
    , tagged_profile_lock_ ()
    , tagged_profile_created_ (false)
{
}

TAO_Profile::~TAO_Profile ( void   )  [protected, virtual]

If you have a virtual method you need a virtual dtor.

Definition at line 71 of file Profile.cpp.

{
  if (this->tagged_profile_)
    {
      delete this->tagged_profile_;
    }

  this->orb_core_->object_key_table ().unbind (this->ref_object_key_);

  //@@ TAO_PROFILE_SPL_DESTRUCTOR_ADD_HOOK
}

TAO_Profile::TAO_Profile ( CORBA::ULong  tag,
TAO_ORB_Core orb_core,
const TAO::ObjectKey &  key,
const TAO_GIOP_Message_Version version 
) [protected]

To be used by inherited classes.

Definition at line 32 of file Profile.cpp.

  : version_ (version)
    , are_policies_parsed_ (false)
    , addressing_mode_ (0)
    , tagged_profile_ (0)
    , ref_object_key_ (0)
    , tag_ (tag)
    , orb_core_ (orb_core)
    , forward_to_ (0)
    , refcount_ (this->orb_core_->
                   client_factory ()->create_profile_refcount ())
    , tagged_profile_lock_ ()
    , tagged_profile_created_ (false)
{
  (void) this->orb_core_->object_key_table ().bind (obj_key,
                                                    this->ref_object_key_);
}

TAO_Profile::TAO_Profile ( const TAO_Profile  )  [private]

Member Function Documentation

unsigned long TAO_Profile::_decr_refcnt ( void   ) 

Decrement the object's reference count. When this count goes to 0 this object will be deleted.

Definition at line 74 of file Profile.inl.

{
  unsigned long count = this->refcount_.decrement ();
  if (count != 0)
    return count;

  // refcount is 0, so delete us!
  // delete will call our ~ destructor which in turn deletes stuff.
  delete this;
  return 0;
}

unsigned long TAO_Profile::_incr_refcnt ( void   ) 

Increase the reference count by one on this object.

Definition at line 68 of file Profile.inl.

{
  return this->refcount_.increment ();
}

TAO::ObjectKey * TAO_Profile::_key ( void   )  const

Obtain the object key, return 0 if the profile cannot be parsed. The memory is owned by the caller!

Reimplemented in TAO_Unknown_Profile.

Definition at line 108 of file Profile.cpp.

{
  TAO::ObjectKey *key = 0;

  if (this->ref_object_key_)
    {
      ACE_NEW_RETURN (key,
                      TAO::ObjectKey (this->ref_object_key_->object_key ()),
                      0);
    }
  return key;
}

void TAO_Profile::add_generic_endpoint ( TAO_Endpoint ep  )  [virtual]

Add a protocol-agnostic endpoint.

Reimplemented in TAO_IIOP_Profile.

Definition at line 724 of file Profile.cpp.

{
  // noop for the base type
}

void TAO_Profile::add_tagged_component ( const IOP::TaggedComponent &  component  ) 

Add the given tagged component to the profile.

Definition at line 84 of file Profile.cpp.

{
  // Sanity checks.
  this->verify_orb_configuration ();

  this->verify_profile_version ();

  // ----------------------------------------------------------------

  // Add the given tagged component to this profile.
  //
  // Note that multiple tagged profiles with the same tag value may be
  // added, unless the tagged component is known to be unique by TAO.
  this->tagged_components_.set_component (component);
}

void TAO_Profile::addressing_mode ( CORBA::Short  addr_mode  )  [virtual]

Set the addressing mode if a remote servant replies with an addressing mode exception. If this profile doesn't support a particular addressing mode, this method needs to be overridden signal the appropriate error.

** RACE CONDITION NOTE **

Currently, getting and setting the addressing mode is not protected by a mutex. Theoretically, this could cause a race condition if one thread sends a request, then gets an exception from the remote servant to change the addressing mode, and then another thread sends a different request to the same servant using the wrong addressing mode. The result of this is that we'll get another address change exception. (Annoying, but not that bad.)

In practice at the current time, the above theoretical case never happens since the target specification always uses the object key except for MIOP requests. Remote ORBs can't respond to MIOP requests even to send exceptions, so even in this case, the race condition can't happen.

Therefore, for the time being, there is no lock to protect the addressing mode. Given that the addressing mode is checked in the critical path, this decision seems like a good thing.

Definition at line 605 of file Profile.cpp.

{
  // ** See race condition note about addressing mode in Profile.h **
  switch (addr)
    {
    case TAO_Target_Specification::Key_Addr:
    case TAO_Target_Specification::Profile_Addr:
    case TAO_Target_Specification::Reference_Addr:
      this->addressing_mode_ = addr;
      break;

    default:
      throw ::CORBA::BAD_PARAM (
             CORBA::SystemException::_tao_minor_code (
               0,
               EINVAL),
             CORBA::COMPLETED_NO);
    }
}

CORBA::Short TAO_Profile::addressing_mode ( void   )  const

Return the current addressing mode for this profile. In almost all cases, this is TAO_Target_Specification::Key_Addr.

Definition at line 56 of file Profile.inl.

{
  return this->addressing_mode_;
}

TAO_Endpoint * TAO_Profile::base_endpoint ( void   )  [virtual]

Return a pointer to this profile's endpoint. If the most derived profile type uses an endpoint that is a type that does not derive from the endpoint type of the base profile, then this method returns the base type's endpoint. For example, SSLIOP_Profile derives from IIOP_Profile, but SSLIOP_Endpoint does not derive from IIOP_Endpoint. Because SSLIOP is tagged the same as IIOP, this method is required to facilitate the Endpoint Policy's filtering function. The default implementation of base_endpoint simply returns endpoint.

Reimplemented in TAO_IIOP_Profile.

Definition at line 102 of file Profile.cpp.

{
  return this->endpoint();
}

CORBA::Boolean TAO_Profile::compare_key ( const TAO_Profile other  )  const

Compare the object key for this profile with that of another. This is weaker than is_equivalent

Definition at line 699 of file Profile.cpp.

{
  return (this->ref_object_key_ == other->ref_object_key_) ||
    ((this->ref_object_key_ != 0 &&
      other->ref_object_key_ != 0 &&
      this->ref_object_key_->object_key() ==
      other->ref_object_key_->object_key()));
}

virtual void TAO_Profile::create_profile_body ( TAO_OutputCDR cdr  )  const [protected, pure virtual]

Creates an encapsulation of the ProfileBody struct in the cdr.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

IOP::TaggedProfile * TAO_Profile::create_tagged_profile ( void   ) 

This method is used to get the IOP::TaggedProfile. The profile information that is received from the server side would have already been decoded. So this method will just make a IOP::TaggedProfile struct from the existing information and return the reference to that. This method is necessary for GIOP 1.2.

Definition at line 248 of file Profile.cpp.

{
  if (this->tagged_profile_created_)
    return this->tagged_profile_;

  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->tagged_profile_lock_,
                    this->tagged_profile_);

  // .. DCL
  if (!this->tagged_profile_created_)
    {
      ACE_NEW_RETURN (this->tagged_profile_,
                      IOP::TaggedProfile,
                      0);

      // As we have not created we will now create the TaggedProfile
      this->tagged_profile_->tag = this->tag_;

      // Create the encapsulation....
      TAO_OutputCDR encap (ACE_DEFAULT_CDR_BUFSIZE,
                           TAO_ENCAP_BYTE_ORDER,
                           this->orb_core ()->output_cdr_buffer_allocator (),
                           this->orb_core ()->output_cdr_dblock_allocator (),
                           this->orb_core ()->output_cdr_msgblock_allocator (),
                           this->orb_core ()->orb_params ()->cdr_memcpy_tradeoff (),
                           TAO_DEF_GIOP_MAJOR,
                           TAO_DEF_GIOP_MINOR);

      // Create the profile body
      this->create_profile_body (encap);

      CORBA::ULong const length =
        static_cast <CORBA::ULong> (encap.total_length ());

#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)
      // Place the message block in to the Sequence of Octets that we
      // have
      this->tagged_profile_->profile_data.replace (length, encap.begin ());
#else
      this->tagged_profile_->profile_data.length (length);
      CORBA::Octet *buffer =
        this->tagged_profile_->profile_data.get_buffer ();

      for (const ACE_Message_Block *i = encap.begin ();
           i != encap.end ();
           i = i->next ())
        {
          ACE_OS::memcpy (buffer, i->rd_ptr (), i->length ());
          buffer += i->length ();
        }
#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 1 */

      this->tagged_profile_created_ = true;
    }

  return this->tagged_profile_;
}

int TAO_Profile::decode ( TAO_InputCDR cdr  )  [virtual]

Initialize this object using the given CDR octet string.

Reimplemented in TAO_Unknown_Profile.

Definition at line 156 of file Profile.cpp.

{
#if !defined (ACE_NLOGGING)
  size_t const encap_len = cdr.length ();
#endif

  // Read and verify major, minor versions, ignoring profiles
  // whose versions we don't understand.
  if (!(cdr.read_octet (this->version_.major)
        && this->version_.major == TAO_DEF_GIOP_MAJOR
        && cdr.read_octet (this->version_.minor)
        && this->version_.minor <= TAO_DEF_GIOP_MINOR))
    {
      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - Profile::decode - v%d.%d\n"),
                      this->version_.major,
                      this->version_.minor));
        }

      return -1;
    }

  // Transport specific details
  if (this->decode_profile (cdr) < 0)
    {
      return -1;
    }

  // @@NOTE: This place *may* need strategizing. Here are the
  // issues. Placing the ObjectKey in the table adds an allocation and
  // a lock while decoding. This is bad for some cases especially if
  // the application is marshalling object references across to the
  // server end. But the server could use "lazy" evaluation and avoid
  // this during marshalling.
  //
  // The only place this will get important is when a thead tries to
  // use the object reference to create a CORBA object to make an
  // invocation. Since creation of a CORBA object itself is expensive,
  // it looks like we may not need to worry much.
  //
  // Remember strategizing needs  reconciliation of forces imposed
  // by runtime memory growth. Doing a random strategization would
  // destroy the wins in runtime memory growth got by using this
  // table scheme.
  TAO::ObjectKey ok;

  // ... and object key.
  if (TAO::ObjectKey::demarshal_key (ok, cdr) == 0)
    {
      return -1;
    }

  TAO::ObjectKey_Table &okt = this->orb_core ()->object_key_table ();

  if (okt.bind (ok, this->ref_object_key_) == -1)
    {
      return -1;
    }

  // Tagged Components *only* exist after version 1.0!
  // For GIOP 1.2, IIOP and GIOP have same version numbers!
  if (this->version_.major > 1 || this->version_.minor > 0)
    {
      if (this->tagged_components_.decode (cdr) == 0)
        {
          return -1;
        }
    }

  if (cdr.length () != 0 && TAO_debug_level)
    {
      // If there is extra data in the profile we are supposed to
      // ignore it, but print a warning just in case...
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("%d bytes out of %d left after profile data\n"),
                  cdr.length (),
                  encap_len));
    }

  // Decode any additional endpoints per profile. This is used by RTCORBA
  // and by IIOP when TAG_ALTERNATE_IIOP_ADDRESS components are present.
  if (this->decode_endpoints () == -1)
    {
      return -1;
    }

  return 1;
}

virtual int TAO_Profile::decode_endpoints ( void   )  [protected, pure virtual]

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.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

virtual int TAO_Profile::decode_profile ( TAO_InputCDR cdr  )  [protected, pure virtual]

Decode the protocol specific profile details.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

virtual CORBA::Boolean TAO_Profile::do_is_equivalent ( const TAO_Profile other  )  [protected, pure virtual]

Profile equivalence template method invoked on subclasses.

TAO_Profile subclasses must implement this template method so that they can apply their own definition of profile equivalence.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

int TAO_Profile::encode ( TAO_OutputCDR stream  )  const [virtual]

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

Reimplemented in TAO_Unknown_Profile.

Definition at line 123 of file Profile.cpp.

{
  // UNSIGNED LONG, protocol tag
  stream.write_ulong (this->tag_);

  // Create the encapsulation....
  TAO_OutputCDR encap (ACE_CDR::DEFAULT_BUFSIZE,
                       TAO_ENCAP_BYTE_ORDER,
                       this->orb_core ()->output_cdr_buffer_allocator (),
                       this->orb_core ()->output_cdr_dblock_allocator (),
                       this->orb_core ()->output_cdr_msgblock_allocator (),
                       this->orb_core ()->orb_params ()->cdr_memcpy_tradeoff (),
                       TAO_DEF_GIOP_MAJOR,
                       TAO_DEF_GIOP_MINOR);

#if defined (TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS)
  // Support limited oref ACE_OS::strcmp
  (void) ACE_OS::memset (encap.current()->wr_ptr (),
                         0,
                         encap.current()->space ());
#endif /* TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS */

  // Create the profile body
  this->create_profile_body (encap);

  // write the encapsulation as an octet sequence...
  stream << CORBA::ULong (encap.total_length ());
  stream.write_octet_array_mb (encap.begin ());

  return 1;
}

int TAO_Profile::encode_alternate_endpoints ( void   )  [virtual]

Encodes this profile's endpoints into protocol specific tagged components. This is used for non-RTCORBA applications that share endpoints on profiles. The only known implementation is IIOP, using TAG_ALTERNATE_IIOP_ADDRESS components.

Reimplemented in TAO_IIOP_Profile.

Definition at line 750 of file Profile.cpp.

{
  // this should be a pure virtual, but there are many
  // existing specializations that would need to be
  // modified. This maintains the existing behavior, since
  // the previous version of the POA did not gather alternate
  // endpoints.

  return 0;
}

virtual int TAO_Profile::encode_endpoints ( void   )  [pure 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.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

virtual TAO_Endpoint* TAO_Profile::endpoint ( void   )  [pure virtual]

Return a pointer to this profile's endpoint. If the profile contains more than one endpoint, i.e., a list, the method returns the head of the list.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

virtual CORBA::ULong TAO_Profile::endpoint_count ( void   )  const [pure virtual]

Return how many endpoints this profile contains.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

TAO_Endpoint * TAO_Profile::first_filtered_endpoint ( void   ) 

Return the first endpoint in the list that matches some filtering constraint, such as IPv6 compatibility for IIOP endpoints. This method is implemented in terms of TAO_Endpoint::next_filtered().

Definition at line 709 of file Profile.cpp.

{
  TAO_Endpoint *ep = this->endpoint();
  return ep == 0 ? 0 : ep->next_filtered(this->orb_core_,0);
}

void TAO_Profile::forward_to ( TAO_MProfile mprofiles  ) 

Keep a pointer to the forwarded profile.

Definition at line 26 of file Profile.inl.

{
  this->forward_to_ = mprofiles;
}

TAO_MProfile * TAO_Profile::forward_to ( void   ) 

MProfile accessor.

Definition at line 32 of file Profile.inl.

{
  return this->forward_to_;
}

TAO_MProfile * TAO_Profile::forward_to_i ( void   )  [private]

This object keeps ownership of this object.

Definition at line 38 of file Profile.inl.

{
  return this->forward_to_;
}

void TAO_Profile::get_policies ( CORBA::PolicyList &  policy_list  )  [virtual]

Accessor for the client exposed policies of this profile.

Definition at line 422 of file Profile.cpp.

{
#if !defined(CORBA_E_MICRO)
     if (!this->are_policies_parsed_)
    // None has already parsed the policies.
    {
      IOP::TaggedComponent tagged_component;
      tagged_component.tag = Messaging::TAG_POLICIES;

      // This gets a component with the proper "tag" field
      // if it exists.
      if (this->tagged_components_.get_component (tagged_component))
        {
          const CORBA::Octet *buf =
            tagged_component.component_data.get_buffer ();

          TAO_InputCDR in_cdr (reinterpret_cast <const char *> (buf),
                               tagged_component.component_data.length ());

          // Extract the Byte Order
          CORBA::Boolean byte_order;

          if (!(in_cdr >> ACE_InputCDR::to_boolean (byte_order)))
            {
              return;
            }

          in_cdr.reset_byte_order (static_cast <int> (byte_order));

          // Now we take out the Messaging::PolicyValueSeq out from the
          // CDR.
          Messaging::PolicyValueSeq policy_value_seq;

          if (!(in_cdr >> policy_value_seq))
            {
              throw ::CORBA::INV_OBJREF ();
            }

          // Here we extract the Messaging::PolicyValue out of the sequence
          // and we convert those into the proper CORBA::Policy
          CORBA::ULong const length = policy_value_seq.length ();

          for (CORBA::ULong i = 0; i < length; ++i)
            {
              try
                {
                  CORBA::Policy_var policy =
                    this->orb_core_->orb ()->_create_policy (
                      policy_value_seq[i].ptype);

                  if (!CORBA::is_nil (policy.in ()))
                    {
                      buf = policy_value_seq[i].pvalue.get_buffer ();

                      TAO_InputCDR in_cdr (
                        reinterpret_cast <const char*>  (buf),
                        policy_value_seq[i].pvalue.length ());

                      if (!(in_cdr >> ACE_InputCDR::to_boolean (byte_order)))
                        throw ::CORBA::INV_OBJREF ();

                      in_cdr.reset_byte_order (static_cast <int> (byte_order));

                      if (!policy->_tao_decode (in_cdr))
                        throw ::CORBA::INV_OBJREF ();

                      // Increase the policy length with 1 when we know we support
                      // this policy, this way we don't get nil values in the list
                      pl.length (pl.length () + 1);

                      pl[i] = policy._retn ();
                    }
                  else
                    {
                      // This case should occure when in the IOR are
                      // embedded policies that TAO doesn't support,
                      // so as specified by the RT-CORBA
                      // spec. ptc/99-05-03 we just ignore these
                      // un-understood policies.
                      if (TAO_debug_level >= 5)
                        ACE_DEBUG ((LM_DEBUG,
                                    ACE_TEXT ("The IOR contains unsupported ")
                                    ACE_TEXT ("policies.\n")));
                    }
                }
              catch (const ::CORBA::Exception& ex)
                {
                  // This case should occur when in the IOR are
                  // embedded policies that TAO doesn't support, so as
                  // specified by the RT-CORBA spec. ptc/99-05-03 we
                  // just ignore these un-understood policies.

                  if (TAO_debug_level >= 5)
                    ex._tao_print_exception (
                      ACE_TEXT ("IOR contains ")
                      ACE_TEXT ("unsupported policies."));
                }
            }
        }
    }
#else
 ACE_UNUSED_ARG (pl);
#endif
}

virtual CORBA::ULong TAO_Profile::hash ( CORBA::ULong  max  )  [pure virtual]

Return a hash value for this object.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

CORBA::ULong TAO_Profile::hash_service_i ( CORBA::ULong  m  )  [protected]

Definition at line 737 of file Profile.cpp.

{
  return this->orb_core_->hash_service (this, m);
}

CORBA::Boolean TAO_Profile::is_equivalent ( const TAO_Profile other_profile  ) 

Verify profile equivalance.

Two profiles are equivalent if their tag, object_key, version and all endpoints are the same.

See also:
do_is_equivalent_i()
is_equivalent_hook()
Returns:
true if this profile is equivalent to other_profile.

Definition at line 673 of file Profile.cpp.

{
  CORBA::Boolean result = false;
  if (other)
    {
      TAO_Service_Callbacks::Profile_Equivalence callback
        = this->is_equivalent_hook (other);
      switch (callback)
        {
          case TAO_Service_Callbacks::DONT_KNOW:
            return this->tag () == other->tag ()
                && this->version_ == other->version ()
                && this->endpoint_count () == other->endpoint_count ()
                && this->object_key () == other->object_key ()
                && this->do_is_equivalent (other);
          case TAO_Service_Callbacks::EQUIVALENT:
            result = true;
            break;
          case TAO_Service_Callbacks::NOT_EQUIVALENT:
            break;
        }
    }
  return result;
}

TAO_Service_Callbacks::Profile_Equivalence TAO_Profile::is_equivalent_hook ( const TAO_Profile other  )  [protected, virtual]

Allow services to apply their own definition of "equivalence.".

This method differs from the do_is_equivalent() template method in that it has a default implementation that may or not be applicable to all TAO_Profile subclasses.

Reimplemented in TAO_Unknown_Profile.

Definition at line 730 of file Profile.cpp.

{
  // Allow services to apply their own definition of "equivalence."
  return this->orb_core_->is_profile_equivalent (this, other);
}

TAO_Endpoint * TAO_Profile::next_filtered_endpoint ( TAO_Endpoint source  ) 

Return the next filtered endpoint in the list after the one passed in. This method is implemented in terms of TAO_Endpoint;:next_filtered(). If the supplied source endpoint is null, this returns the first filtered endpoint.

Definition at line 716 of file Profile.cpp.

{
  if (source == 0)
    return this->first_filtered_endpoint();
  return source->next_filtered(this->orb_core_,this->endpoint());
}

const TAO::ObjectKey & TAO_Profile::object_key ( void   )  const
Deprecated:
Return a reference to the Object Key.

Definition at line 62 of file Profile.inl.

{
  return this->ref_object_key_->object_key ();
}

virtual char TAO_Profile::object_key_delimiter ( void   )  const [pure virtual]

The object key delimiter.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

void TAO_Profile::operator= ( const TAO_Profile  )  [private]
TAO_ORB_Core * TAO_Profile::orb_core ( void   )  const

Get a pointer to the TAO_ORB_Core.

Definition at line 20 of file Profile.inl.

{
  return this->orb_core_;
}

void TAO_Profile::parse_string ( const char *  string  )  [virtual]

Initialize this object using the given input string. Supports URL style of object references

Reimplemented in TAO_Unknown_Profile.

Definition at line 626 of file Profile.cpp.

{
  if (!ior || !*ior)
    {
      throw ::CORBA::INV_OBJREF (
                   CORBA::SystemException::_tao_minor_code (
                     0,
                     EINVAL),
                   CORBA::COMPLETED_NO);
    }

  // Remove the "N.n@" version prefix, if it exists, and verify the
  // version is one that we accept.

  // Check for version
  if (ACE_OS::ace_isdigit (ior [0]) &&
      ior[1] == '.' &&
      ACE_OS::ace_isdigit (ior [2]) &&
      ior[3] == '@')
    {
      // @@ This may fail for non-ascii character sets [but take that
      // with a grain of salt]
      this->version_.set_version ((char) (ior[0] - '0'),
                                  (char) (ior[2] - '0'));
      ior += 4;
      // Skip over the "N.n@"
    }
  else
    {
      // CORBA spec requires 1.0 if a version isn't specified.
      this->version_.set_version (1, 0);
    }

  if (this->version_.major != TAO_DEF_GIOP_MAJOR ||
      this->version_.minor >  TAO_DEF_GIOP_MINOR)
    {
      throw ::CORBA::INV_OBJREF (
                   CORBA::SystemException::_tao_minor_code (
                     0,
                     EINVAL),
                   CORBA::COMPLETED_NO);
    }

  this->parse_string_i (ior);
}

virtual void TAO_Profile::parse_string_i ( const char *  string  )  [protected, pure virtual]

Protocol specific implementation of parse_string ().

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

void TAO_Profile::policies ( CORBA::PolicyList *  policy_list  )  [virtual]

This method sets the client exposed policies, i.e., the ones propagated in the IOR, for this profile.

Definition at line 335 of file Profile.cpp.

{
  if (policy_list == 0)
    {
      if (TAO_debug_level)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO_Profile::policies: ")
                      ACE_TEXT ("Null Policy List!\n")));
        }

      return;
    }

  Messaging::PolicyValueSeq policy_value_seq;

  size_t length = 0;
  CORBA::Octet *buf = 0;

  // This loop iterates through CORBA::PolicyList to convert
  // each CORBA::Policy into a CORBA::PolicyValue
  CORBA::ULong const plen = policy_list->length ();

  policy_value_seq.length (plen);

  for (CORBA::ULong i = 0; i < plen; ++i)
    {
      TAO_OutputCDR out_CDR;
      policy_value_seq[i].ptype = (*policy_list)[i]->policy_type ();

      if (!(out_CDR << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)))
        return;

      if (!((*policy_list)[i]->_tao_encode (out_CDR)))
        return;

      length = out_CDR.total_length ();
      policy_value_seq[i].pvalue.length (static_cast <CORBA::ULong>(length));

      buf = policy_value_seq[i].pvalue.get_buffer ();

      // Copy the CDR buffer data into the octet sequence buffer.

      for (const ACE_Message_Block *iterator = out_CDR.begin ();
           iterator != 0;
           iterator = iterator->cont ())
        {
          ACE_OS::memcpy (buf, iterator->rd_ptr (), iterator->length ());
          buf += iterator->length ();
        }
    }

  TAO_OutputCDR out_cdr;
  // Now we have to embed the Messaging::PolicyValueSeq into
  // a TaggedComponent.

  IOP::TaggedComponent tagged_component;
  tagged_component.tag = Messaging::TAG_POLICIES;

  if (!(out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)))
    return;

  if (!(out_cdr << policy_value_seq))
    return;

  length = out_cdr.total_length ();

  tagged_component.component_data.length (static_cast <CORBA::ULong>(length));
  buf = tagged_component.component_data.get_buffer ();

  for (const ACE_Message_Block *iterator = out_cdr.begin ();
       iterator != 0;
       iterator = iterator->cont ())
    {
      size_t const i_length = iterator->length ();
      ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);

      buf += i_length;
    }

  // Eventually we add the TaggedComponent to the TAO_TaggedComponents
  // member variable.
  tagged_components_.set_component (tagged_component);
  this->are_policies_parsed_ = true;
}

void TAO_Profile::remove_generic_endpoint ( TAO_Endpoint ep  )  [virtual]

Remove the provided endpoint from the profile. Some subclasses of TAO_Profile already have a protocol-specific version of remove_endpoint, but this generic interface is required. The default implementation is a no-op. Protocol maintainers wishing to add support for the EndpointPolicy must implement remove_generic_endpoint to call their protocol-specific version of remove_endpoint

Reimplemented in TAO_IIOP_Profile.

Definition at line 762 of file Profile.cpp.

{
  // default for virtual methods, thus a no-op
}

void TAO_Profile::set_tagged_components ( TAO_OutputCDR cdr  )  [protected]

Helper method that encodes the endpoints for RTCORBA as tagged_components.

Definition at line 309 of file Profile.cpp.

{
  CORBA::ULong const length = static_cast <CORBA::ULong> (out_cdr.total_length ());

  IOP::TaggedComponent tagged_component;
  tagged_component.tag = TAO_TAG_ENDPOINTS;
  tagged_component.component_data.length (length);
  CORBA::Octet *buf = tagged_component.component_data.get_buffer ();

  for (const ACE_Message_Block *iterator = out_cdr.begin ();
       iterator != 0;
       iterator = iterator->cont ())
    {
      size_t const i_length = iterator->length ();
      ACE_OS::memcpy (buf, iterator->rd_ptr (), i_length);

      buf += i_length;
    }

  // Add component with encoded endpoint data to this profile's
  // TaggedComponents.
  tagged_components_.set_component (tagged_component);
}

int TAO_Profile::supports_multicast ( void   )  const [virtual]

Returns true if this profile can specify multicast endpoints.

Definition at line 592 of file Profile.cpp.

{
  // Most profiles do not support multicast endpoints.
  return 0;
}

bool TAO_Profile::supports_non_blocking_oneways ( void   )  const [virtual]

Returns true if this profile supports non blocking oneways.

Definition at line 599 of file Profile.cpp.

{
  return !(this->version_.major == 1 && this->version_.minor == 0);
}

CORBA::ULong TAO_Profile::tag ( void   )  const

The tag, each concrete class will have a specific tag value.

Definition at line 8 of file Profile.inl.

{
  return this->tag_;
}

const TAO_Tagged_Components & TAO_Profile::tagged_components ( void   )  const

Access the tagged components, notice that they they could be empty (or ignored) for non-GIOP protocols (and even for GIOP-1.0)

Definition at line 44 of file Profile.inl.

{
  return this->tagged_components_;
}

TAO_Tagged_Components & TAO_Profile::tagged_components ( void   ) 

The tag, each concrete class will have a specific tag value.

Definition at line 50 of file Profile.inl.

{
  return this->tagged_components_;
}

virtual char* TAO_Profile::to_string ( void   )  [pure virtual]

Return a string representation for this profile. Client must deallocate memory. Only one endpoint is included into the string.

Implemented in TAO_IIOP_Profile, TAO_Unknown_Profile, TAO_DIOP_Profile, and TAO_UIOP_Profile.

void TAO_Profile::verify_orb_configuration ( void   )  [private]

Verify that the current ORB's configuration supports tagged components in IORs.

Definition at line 528 of file Profile.cpp.

{
  // If the ORB isn't configured to support tagged components, then
  // throw an exception.
  if (!this->orb_core_->orb_params ()->std_profile_components ()
      || !this->orb_core_->orb ()->_use_omg_ior_format ())
    {
      if (TAO_debug_level > 0)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("(%P|%t) Cannot add ")
                      ACE_TEXT ("IOP::TaggedComponent to profile.\n")
                      ACE_TEXT ("(%P|%t) Standard profile components ")
                      ACE_TEXT ("have been disabled or URL style IORs\n")
                      ACE_TEXT ("(%P|%t) are in use.  Try ")
                      ACE_TEXT ("\"-ORBStdProfileComponents 1\" and/or\n")
                      ACE_TEXT ("(%P|%t) \"-ORBObjRefStyle IOR\".\n")));
        }

      // According to the Portable Interceptor specification, we're
      // supposed to throw a CORBA::BAD_PARAM exception if it isn't
      // possible to add components to the profile.
      // @todo: We need the proper minor code as soon as the spec is
      //        updated.
      throw ::CORBA::BAD_PARAM (
                   CORBA::SystemException::_tao_minor_code (
                      0,
                      EINVAL),
                   CORBA::COMPLETED_NO);
    }
}

void TAO_Profile::verify_profile_version ( void   )  [private]

Verify that the given profile supports tagged components, i.e. is not a GIOP 1.0 profile.

Definition at line 561 of file Profile.cpp.

{
  // GIOP 1.0 does not support tagged components.  Throw an exception
  // if the profile is a GIOP 1.0 profile.

  if (this->version_.major == 1 && this->version_.minor == 0)
    {
      if (TAO_debug_level > 0)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("(%P|%t) Cannot add ")
                      ACE_TEXT ("IOP::TaggedComponent to GIOP 1.0")
                      ACE_TEXT ("IOR profile.\n")
                      ACE_TEXT ("(%P|%t) Try using a GIOP 1.1 or ")
                      ACE_TEXT ("greater endpoint.\n")));
        }

      // According to the Portable Interceptor specification, we're
      // supposed to throw a CORBA::BAD_PARAM exception if it isn't
      // possible to add components to the profile.
      // @todo: We need the proper minor code as soon as the spec is
      //        updated.
      throw ::CORBA::BAD_PARAM (
                   CORBA::SystemException::_tao_minor_code (
                     0,
                     EINVAL),
                   CORBA::COMPLETED_NO);
    }
}

const TAO_GIOP_Message_Version & TAO_Profile::version ( void   )  const

Return a pointer to this profile's version. This object maintains ownership.

Definition at line 14 of file Profile.inl.

{
  return this->version_;
}


Member Data Documentation

The current addressing mode. This may be changed if a remote server sends back an address mode exception.

Definition at line 366 of file Profile.h.

Flag indicating whether the lazy decoding of the client exposed policies has taken place.

Definition at line 361 of file Profile.h.

The TAO_MProfile which contains the profiles for the forwarded object.

Definition at line 383 of file Profile.h.

Pointer to the ORB core.

Definition at line 379 of file Profile.h.

TAO::Refcounted_ObjectKey* TAO_Profile::ref_object_key_ [protected]

Object_key associated with this profile.

Definition at line 372 of file Profile.h.

Number of outstanding references to this object.

Definition at line 386 of file Profile.h.

IOP protocol tag.

Definition at line 376 of file Profile.h.

The tagged components.

Definition at line 357 of file Profile.h.

IOP::TaggedProfile* TAO_Profile::tagged_profile_ [protected]

Our tagged profile.

Definition at line 369 of file Profile.h.

Having (tagged_profile_ != 0) doesn't mean yet that tagged_profile_ building is finished.

Definition at line 393 of file Profile.h.

TAO_SYNCH_MUTEX TAO_Profile::tagged_profile_lock_ [private]

A lock that protects creation of the tagged profile.

Definition at line 389 of file Profile.h.

IIOP version number.

Definition at line 354 of file Profile.h.


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