TAO_Tagged_Components Class Reference

The policy manager implementation. More...

#include <Tagged_Components.h>

Collaboration diagram for TAO_Tagged_Components:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Tagged_Components (void)
 Constructor.

void set_orb_type (CORBA::ULong orb_type)
 The the IOP::TAG_ORB_TYPE component value.

int get_orb_type (CORBA::ULong &orb_type) const
void set_code_sets (const CONV_FRAME::CodeSetComponentInfo &)
void set_code_sets (CONV_FRAME::CodeSetComponentInfo &)
int get_code_sets (const CONV_FRAME::CodeSetComponentInfo *&) const
int get_code_sets (CONV_FRAME::CodeSetComponentInfo &) const
void set_component (const IOP::TaggedComponent &component)
void set_component (IOP::TaggedComponent &component)
int get_component (IOP::TaggedComponent &component) const
int remove_component (IOP::ComponentId id)
int encode (TAO_OutputCDR &cdr) const
 Marshal and demarshal the list.

int decode (TAO_InputCDR &cdr)
IOP::MultipleComponentProfilecomponents (void)

Private Member Functions

void set_code_sets_i (CONV_FRAME::CodeSetComponent &lhs, CONV_FRAME::CodeSetComponent &rhs)
 Helper method to implement set_code_sets().

void set_known_component_i (const IOP::TaggedComponent &component)
 Helper methods to implement set_component().

void set_component_i (const IOP::TaggedComponent &component)
void set_component_i (IOP::TaggedComponent &component)
void add_component_i (const IOP::TaggedComponent &component)
void add_component_i (IOP::TaggedComponent &component)
void set_component_i (IOP::ComponentId tag, TAO_OutputCDR &cdr)
int remove_known_component_i (IOP::ComponentId tag)
 Helper methods to implement remove_component().

int remove_component_i (IOP::ComponentId tag)
int get_known_component_i (IOP::TaggedComponent &component) const
 Helper methods to implement set_component().

int get_component_i (IOP::TaggedComponent &component) const
int known_tag (IOP::ComponentId tag) const
 Is a well-known component?

int unique_tag (IOP::ComponentId tag) const
 Does show up only once?


Private Attributes

CORBA::ULong orb_type_
 The ORB_TYPE component value.

CONV_FRAME::CodeSetComponentInfo code_sets_
 The ORB_TYPE component value.

IOP::MultipleComponentProfile components_
CORBA::Octet orb_type_set_
CORBA::Octet code_sets_set_

Detailed Description

The policy manager implementation.

This class is used to manipulate and access the field of an IIOP profile (and other GIOP profiles). The definition for that field is simply a sequence of the following structures: typedef unsigned long ComponentId; struct TaggedComponent { ComponentId tag; sequence<octet> component_data; }; the real motivation is to minimize the marshaling and demarshaling of the field for certain critical components.

Definition at line 57 of file Tagged_Components.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_Tagged_Components::TAO_Tagged_Components void   ) 
 

Constructor.

Definition at line 8 of file Tagged_Components.i.

00009   :  orb_type_ (0),
00010      orb_type_set_ (0),
00011      code_sets_set_ (0)
00012 {
00013 }


Member Function Documentation

void TAO_Tagged_Components::add_component_i IOP::TaggedComponent component  )  [private]
 

Definition at line 217 of file Tagged_Components.cpp.

References IOP::TaggedComponent::component_data, components_, TAO::unbounded_value_sequence< T >::get_buffer(), TAO::unbounded_value_sequence< T >::length(), TAO::unbounded_value_sequence< TaggedComponent >::length(), TAO::unbounded_value_sequence< T >::maximum(), TAO::unbounded_value_sequence< TaggedComponent >::replace(), and IOP::TaggedComponent::tag.

00218 {
00219   // @@ TODO Some components can show up multiple times, others
00220   //    can't find out and take appropiate action.
00221   CORBA::ULong l = this->components_.length ();
00222   this->components_.length (l + 1);
00223   this->components_[l].tag = component.tag;
00224   CORBA::ULong max = component.component_data.maximum ();
00225   CORBA::ULong len = component.component_data.length ();
00226   CORBA::Octet* buf = component.component_data.get_buffer (1);
00227   this->components_[l].component_data.replace (max, len, buf, 1);
00228 }

void TAO_Tagged_Components::add_component_i const IOP::TaggedComponent component  )  [private]
 

Definition at line 231 of file Tagged_Components.cpp.

References components_, and TAO::unbounded_value_sequence< TaggedComponent >::length().

Referenced by set_component(), and set_component_i().

00232 {
00233   // @@ TODO Some components can show up multiple times, others
00234   //    can't find out and take appropiate action.
00235   CORBA::ULong l = this->components_.length ();
00236   this->components_.length (l + 1);
00237   this->components_[l] = component;
00238 }

ACE_INLINE IOP::MultipleComponentProfile & TAO_Tagged_Components::components void   ) 
 

Read/Write access to the underlying MutipleComponentProfile. Added by request from Chris Hafey <chris@stentorsoft.com>

Definition at line 77 of file Tagged_Components.i.

References components_.

Referenced by TAO_IIOP_Profile::decode_endpoints().

00078 {
00079   return this->components_;
00080 }

int TAO_Tagged_Components::decode TAO_InputCDR cdr  ) 
 

Definition at line 317 of file Tagged_Components.cpp.

References code_sets_set_, components_, known_tag(), TAO::unbounded_value_sequence< TaggedComponent >::length(), orb_type_set_, set_known_component_i(), and IOP::TaggedComponent::tag.

Referenced by TAO_Profile::decode().

00318 {
00319   // Mark the well-known components as removed
00320   this->orb_type_set_ = 0;
00321   this->code_sets_set_ = 0;
00322 
00323   if ((cdr >> this->components_) == 0)
00324     {
00325       return 0;
00326     }
00327 
00328   CORBA::ULong l = this->components_.length ();
00329 
00330   for (CORBA::ULong i = 0; i != l; ++i)
00331     {
00332       const IOP::TaggedComponent &component =
00333         this->components_[i];
00334 
00335       if (this->known_tag (component.tag))
00336         {
00337           this->set_known_component_i (component);
00338         }
00339     }
00340 
00341   return 1;
00342 }

int TAO_Tagged_Components::encode TAO_OutputCDR cdr  )  const
 

Marshal and demarshal the list.

Definition at line 311 of file Tagged_Components.cpp.

References components_.

Referenced by TAO_IIOP_Profile::create_profile_body().

00312 {
00313   return (cdr << this->components_);
00314 }

ACE_INLINE int TAO_Tagged_Components::get_code_sets CONV_FRAME::CodeSetComponentInfo  )  const
 

Gets a copy of the IOP::TAG_CODE_SETS component value, return 0 if the component is not present.

Definition at line 39 of file Tagged_Components.i.

References code_sets_, and code_sets_set_.

00041 {
00042   if (this->code_sets_set_ == 1)
00043     {
00044       ci = this->code_sets_;
00045     }
00046 
00047   return this->code_sets_set_;
00048 }

ACE_INLINE int TAO_Tagged_Components::get_code_sets const CONV_FRAME::CodeSetComponentInfo *&   )  const
 

Gets a reference of the IOP::TAG_CODE_SETS component value, return 0 if the component is not present.

Definition at line 27 of file Tagged_Components.i.

References code_sets_, and code_sets_set_.

00029 {
00030   if (this->code_sets_set_ == 1)
00031     {
00032       ci = &this->code_sets_;
00033     }
00034 
00035   return this->code_sets_set_;
00036 }

int TAO_Tagged_Components::get_component IOP::TaggedComponent component  )  const
 

Get a copy of the component identified by <component.tag>, return 0 if the component is not present.

Definition at line 294 of file Tagged_Components.cpp.

References components_, TAO::unbounded_value_sequence< TaggedComponent >::length(), and IOP::TaggedComponent::tag.

Referenced by TAO_IIOP_Profile::decode_endpoints(), and TAO_Profile::get_policies().

00295 {
00296   for (CORBA::ULong i = 0; i != this->components_.length (); ++i)
00297     {
00298       if (component.tag == this->components_[i].tag)
00299         {
00300           component = this->components_[i];
00301           return 1;
00302         }
00303     }
00304 
00305   return 0;
00306 }

int TAO_Tagged_Components::get_component_i IOP::TaggedComponent component  )  const [private]
 

int TAO_Tagged_Components::get_known_component_i IOP::TaggedComponent component  )  const [private]
 

Helper methods to implement set_component().

ACE_INLINE int TAO_Tagged_Components::get_orb_type CORBA::ULong orb_type  )  const
 

Gets the IOP::TAG_ORB_TYPE component value, return 0 if the component is not present.

Definition at line 16 of file Tagged_Components.i.

References orb_type_, and orb_type_set_.

00017 {
00018   if (this->orb_type_set_ == 1)
00019     {
00020       orb_type = this->orb_type_;
00021     }
00022 
00023   return this->orb_type_set_;
00024 }

ACE_INLINE int TAO_Tagged_Components::known_tag IOP::ComponentId  tag  )  const [private]
 

Is a well-known component?

Definition at line 51 of file Tagged_Components.i.

References IOP::ComponentId.

Referenced by decode(), remove_component(), and set_component().

00052 {
00053   return (tag == IOP::TAG_ORB_TYPE
00054           || tag == IOP::TAG_CODE_SETS);
00055 }

int TAO_Tagged_Components::remove_component IOP::ComponentId  id  ) 
 

Remove a component, if present. Return number of components removed.

Definition at line 241 of file Tagged_Components.cpp.

References IOP::ComponentId, known_tag(), remove_component_i(), and remove_known_component_i().

00242 {
00243   if (this->known_tag (id))
00244     {
00245       return this->remove_known_component_i (id);
00246     }
00247   else
00248     {
00249       return this->remove_component_i (id);
00250     }
00251 }

int TAO_Tagged_Components::remove_component_i IOP::ComponentId  tag  )  [private]
 

Definition at line 275 of file Tagged_Components.cpp.

References IOP::ComponentId, components_, and TAO::unbounded_value_sequence< TaggedComponent >::length().

Referenced by remove_component().

00276 {
00277   CORBA::ULong src = 0, dest = 0;
00278   CORBA::ULong len = this->components_.length ();
00279 
00280   for (;src != len;++src)
00281     {
00282       if ( tag != this->components_[src].tag)
00283         {
00284           this->components_[dest] = this->components_[src];
00285           ++dest;
00286         }
00287     }
00288 
00289   this->components_.length (dest);
00290   return src - dest;
00291 }

int TAO_Tagged_Components::remove_known_component_i IOP::ComponentId  tag  )  [private]
 

Helper methods to implement remove_component().

Definition at line 254 of file Tagged_Components.cpp.

References code_sets_set_, IOP::ComponentId, orb_type_, and orb_type_set_.

Referenced by remove_component().

00256 {
00257   if (tag == IOP::TAG_ORB_TYPE)
00258     {
00259       this->orb_type_ = 0;
00260       this->orb_type_set_ = 0;
00261       return 1;
00262     }
00263   else if (tag == IOP::TAG_CODE_SETS)
00264     {
00265       this->code_sets_set_ = 0;
00266       return 1;
00267     }
00268   else
00269     {
00270       return 0;
00271     }
00272 }

void TAO_Tagged_Components::set_code_sets CONV_FRAME::CodeSetComponentInfo  ) 
 

Definition at line 47 of file Tagged_Components.cpp.

References code_sets_, code_sets_set_, CONV_FRAME::CodeSetComponentInfo::ForCharData, CONV_FRAME::CodeSetComponentInfo::ForWcharData, set_code_sets_i(), set_component_i(), and TAO_ENCAP_BYTE_ORDER.

00048 {
00049   this->set_code_sets_i (this->code_sets_.ForCharData,
00050                          ci.ForCharData);
00051   this->set_code_sets_i (this->code_sets_.ForWcharData,
00052                          ci.ForWcharData);
00053   this->code_sets_set_ = 1;
00054 
00055   TAO_OutputCDR cdr;
00056   cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
00057   cdr << this->code_sets_;
00058 
00059   this->set_component_i (IOP::TAG_CODE_SETS, cdr);
00060 }

void TAO_Tagged_Components::set_code_sets const CONV_FRAME::CodeSetComponentInfo  ) 
 

The the IOP::TAG_CODE_SETS component value, the first version copies the data, the second version steal all the sequence buffers.

Definition at line 33 of file Tagged_Components.cpp.

References code_sets_, code_sets_set_, set_component_i(), and TAO_ENCAP_BYTE_ORDER.

00035 {
00036   this->code_sets_ = ci;
00037   this->code_sets_set_ = 1;
00038 
00039   TAO_OutputCDR cdr;
00040   cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
00041   cdr << this->code_sets_;
00042 
00043   this->set_component_i (IOP::TAG_CODE_SETS, cdr);
00044 }

void TAO_Tagged_Components::set_code_sets_i CONV_FRAME::CodeSetComponent lhs,
CONV_FRAME::CodeSetComponent rhs
[private]
 

Helper method to implement set_code_sets().

Definition at line 63 of file Tagged_Components.cpp.

References CONV_FRAME::CodeSetId, CONV_FRAME::CodeSetComponent::conversion_code_sets, and CONV_FRAME::CodeSetComponent::native_code_set.

Referenced by set_code_sets(), and set_known_component_i().

00066 {
00067   lhs.native_code_set = rhs.native_code_set;
00068   CORBA::ULong max = rhs.conversion_code_sets.maximum ();
00069   CORBA::ULong len = rhs.conversion_code_sets.length ();
00070   CONV_FRAME::CodeSetId *buffer = rhs.conversion_code_sets.get_buffer (1);
00071   lhs.conversion_code_sets.replace (max, len, buffer, 1);
00072 }

void TAO_Tagged_Components::set_component IOP::TaggedComponent component  ) 
 

Insert the component into the list, but efficiently stealing the contents of the octet sequence.

Definition at line 118 of file Tagged_Components.cpp.

References add_component_i(), known_tag(), set_component_i(), set_known_component_i(), IOP::TaggedComponent::tag, and unique_tag().

00119 {
00120   if (this->known_tag (component.tag))
00121     {
00122       this->set_known_component_i (component);
00123     }
00124 
00125   if (this->unique_tag (component.tag))
00126     {
00127       this->set_component_i (component);
00128     }
00129   else
00130     {
00131       this->add_component_i (component);
00132     }
00133 }

void TAO_Tagged_Components::set_component const IOP::TaggedComponent component  ) 
 

Insert the component into the list, making a copy of the octet sequence.

Definition at line 100 of file Tagged_Components.cpp.

References add_component_i(), known_tag(), set_component_i(), set_known_component_i(), IOP::TaggedComponent::tag, and unique_tag().

Referenced by TAO_Profile::add_tagged_component(), TAO_IIOP_Profile::encode_alternate_endpoints(), TAO_Profile::policies(), and TAO_Profile::set_tagged_components().

00101 {
00102   if (this->known_tag (component.tag))
00103     {
00104       this->set_known_component_i (component);
00105     }
00106 
00107   if (this->unique_tag (component.tag))
00108     {
00109       this->set_component_i (component);
00110     }
00111   else
00112     {
00113       this->add_component_i (component);
00114     }
00115 }

void TAO_Tagged_Components::set_component_i IOP::ComponentId  tag,
TAO_OutputCDR cdr
[private]
 

Definition at line 77 of file Tagged_Components.cpp.

References ACE_OutputCDR::begin(), IOP::TaggedComponent::component_data, IOP::ComponentId, ACE_Message_Block::cont(), TAO::unbounded_value_sequence< T >::get_buffer(), ACE_Message_Block::length(), TAO::unbounded_value_sequence< T >::length(), ACE_OS::memcpy(), ACE_Message_Block::rd_ptr(), set_component_i(), IOP::TaggedComponent::tag, and ACE_OutputCDR::total_length().

00079 {
00080   IOP::TaggedComponent component;
00081   component.tag = tag;
00082 
00083   // Make a *copy* of the CDR stream...
00084   size_t length = cdr.total_length ();
00085   component.component_data.length (static_cast<CORBA::ULong> (length));
00086   CORBA::Octet *buf = component.component_data.get_buffer ();
00087 
00088   for (const ACE_Message_Block *i = cdr.begin ();
00089        i != 0;
00090        i = i->cont ())
00091     {
00092       ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
00093       buf += i->length ();
00094     }
00095 
00096   this->set_component_i (component);
00097 }

void TAO_Tagged_Components::set_component_i IOP::TaggedComponent component  )  [private]
 

Definition at line 199 of file Tagged_Components.cpp.

References add_component_i(), IOP::TaggedComponent::component_data, components_, TAO::unbounded_value_sequence< T >::get_buffer(), TAO::unbounded_value_sequence< T >::length(), TAO::unbounded_value_sequence< TaggedComponent >::length(), TAO::unbounded_value_sequence< T >::maximum(), TAO::unbounded_value_sequence< TaggedComponent >::replace(), and IOP::TaggedComponent::tag.

00200 {
00201   for (CORBA::ULong i = 0; i != this->components_.length (); ++i)
00202     {
00203       if (component.tag == this->components_[i].tag)
00204         {
00205           CORBA::ULong max = component.component_data.maximum ();
00206           CORBA::ULong len = component.component_data.length ();
00207           CORBA::Octet* buf = component.component_data.get_buffer (1);
00208           this->components_[i].component_data.replace (max, len, buf, 1);
00209           return;
00210         }
00211     }
00212 
00213   this->add_component_i (component);
00214 }

void TAO_Tagged_Components::set_component_i const IOP::TaggedComponent component  )  [private]
 

Definition at line 182 of file Tagged_Components.cpp.

References add_component_i(), components_, TAO::unbounded_value_sequence< TaggedComponent >::length(), and IOP::TaggedComponent::tag.

Referenced by set_code_sets(), set_component(), set_component_i(), and set_orb_type().

00183 {
00184   // @@ TODO Some components can show up multiple times, others
00185   //    can't find out and take appropiate action.
00186   for (CORBA::ULong i = 0; i != this->components_.length (); ++i)
00187     {
00188       if (component.tag == this->components_[i].tag)
00189         {
00190           this->components_[i] = component;
00191           return;
00192         }
00193     }
00194 
00195   this->add_component_i (component);
00196 }

void TAO_Tagged_Components::set_known_component_i const IOP::TaggedComponent component  )  [private]
 

Helper methods to implement set_component().

Definition at line 136 of file Tagged_Components.cpp.

References code_sets_set_, IOP::TaggedComponent::component_data, CONV_FRAME::CodeSetComponentInfo::ForCharData, CONV_FRAME::CodeSetComponentInfo::ForWcharData, TAO::unbounded_value_sequence< T >::get_buffer(), TAO::unbounded_value_sequence< T >::length(), orb_type_, orb_type_set_, ACE_InputCDR::reset_byte_order(), set_code_sets_i(), and IOP::TaggedComponent::tag.

Referenced by decode(), and set_component().

00138 {
00139   TAO_InputCDR cdr (reinterpret_cast<const char*> (
00140                       component.component_data.get_buffer ()),
00141                     component.component_data.length ());
00142 
00143   CORBA::Boolean byte_order;
00144 
00145   if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
00146     {
00147       return;
00148     }
00149 
00150   cdr.reset_byte_order (static_cast<int> (byte_order));
00151 
00152   if (component.tag == IOP::TAG_ORB_TYPE)
00153     {
00154       CORBA::ULong orb_type;
00155 
00156       if ((cdr >> orb_type) == 0)
00157         {
00158           return;
00159         }
00160 
00161       this->orb_type_ = orb_type;
00162       this->orb_type_set_ = 1;
00163     }
00164   else if (component.tag == IOP::TAG_CODE_SETS)
00165     {
00166       CONV_FRAME::CodeSetComponentInfo ci;
00167 
00168       if ((cdr >> ci) == 0)
00169         {
00170           return;
00171         }
00172 
00173       this->set_code_sets_i (this->code_sets_.ForCharData,
00174                              ci.ForCharData);
00175       this->set_code_sets_i (this->code_sets_.ForWcharData,
00176                              ci.ForWcharData);
00177       this->code_sets_set_ = 1;
00178     }
00179 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL void TAO_Tagged_Components::set_orb_type CORBA::ULong  orb_type  ) 
 

The the IOP::TAG_ORB_TYPE component value.

Definition at line 20 of file Tagged_Components.cpp.

References orb_type_, orb_type_set_, set_component_i(), and TAO_ENCAP_BYTE_ORDER.

Referenced by TAO_IIOP_Acceptor::create_new_profile(), and TAO_IIOP_Acceptor::create_shared_profile().

00021 {
00022   this->orb_type_ = orb_type;
00023   this->orb_type_set_ = 1;
00024 
00025   TAO_OutputCDR cdr;
00026   cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
00027   cdr << this->orb_type_;
00028 
00029   this->set_component_i (IOP::TAG_ORB_TYPE, cdr);
00030 }

ACE_INLINE int TAO_Tagged_Components::unique_tag IOP::ComponentId  tag  )  const [private]
 

Does show up only once?

Definition at line 59 of file Tagged_Components.i.

References IOP::ComponentId.

Referenced by set_component().

00060 {
00061   return (tag == IOP::TAG_ORB_TYPE
00062           || tag == IOP::TAG_CODE_SETS
00063           || tag == IOP::TAG_POLICIES
00064           || tag == TAO_TAG_ENDPOINTS
00065           // || tag == IOP::TAG_ALTERNATE_IIOP_ADDRESS
00066           || tag == IOP::TAG_COMPLETE_OBJECT_KEY
00067           || tag == IOP::TAG_ENDPOINT_ID_POSITION
00068           || tag == IOP::TAG_LOCATION_POLICY
00069           || tag == IOP::TAG_FT_PRIMARY
00070           || tag == IOP::TAG_FT_GROUP
00071           || tag == IOP::TAG_DCE_STRING_BINDING
00072           || tag == IOP::TAG_DCE_BINDING_NAME
00073           || tag == IOP::TAG_DCE_NO_PIPES);
00074 }


Member Data Documentation

CONV_FRAME::CodeSetComponentInfo TAO_Tagged_Components::code_sets_ [private]
 

The ORB_TYPE component value.

Definition at line 150 of file Tagged_Components.h.

Referenced by get_code_sets(), and set_code_sets().

CORBA::Octet TAO_Tagged_Components::code_sets_set_ [private]
 

Definition at line 158 of file Tagged_Components.h.

Referenced by decode(), get_code_sets(), remove_known_component_i(), set_code_sets(), and set_known_component_i().

IOP::MultipleComponentProfile TAO_Tagged_Components::components_ [private]
 

The rest of the components, to be compliant we cannot drop a bunch of them.

Definition at line 154 of file Tagged_Components.h.

Referenced by add_component_i(), components(), decode(), encode(), get_component(), remove_component_i(), and set_component_i().

CORBA::ULong TAO_Tagged_Components::orb_type_ [private]
 

The ORB_TYPE component value.

Definition at line 147 of file Tagged_Components.h.

Referenced by get_orb_type(), remove_known_component_i(), set_known_component_i(), and set_orb_type().

CORBA::Octet TAO_Tagged_Components::orb_type_set_ [private]
 

Definition at line 157 of file Tagged_Components.h.

Referenced by decode(), get_orb_type(), remove_known_component_i(), set_known_component_i(), and set_orb_type().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:23:50 2006 for TAO by doxygen 1.3.6