TAO_Tagged_Components Class Reference

The policy manager implementation. More...

#include <Tagged_Components.h>

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::MultipleComponentProfile & components (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 <tag> a well-known component?
int unique_tag (IOP::ComponentId tag) const
 Does <tag> 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 <components> 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 <component_data> 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.inl.

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 213 of file Tagged_Components.cpp.

References components_.

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

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

Definition at line 227 of file Tagged_Components.cpp.

References components_.

Referenced by set_component(), and set_component_i().

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

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.inl.

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 312 of file Tagged_Components.cpp.

References code_sets_set_, components_, and orb_type_set_.

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

int TAO_Tagged_Components::encode ( TAO_OutputCDR cdr  )  const

Marshal and demarshal the list.

Definition at line 306 of file Tagged_Components.cpp.

Referenced by TAO_IIOP_Profile::create_profile_body().

00307 {
00308   return (cdr << this->components_);
00309 }

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.inl.

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.inl.

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 289 of file Tagged_Components.cpp.

References components_.

00290 {
00291   for (CORBA::ULong i = 0; i != this->components_.length (); ++i)
00292     {
00293       if (component.tag == this->components_[i].tag)
00294         {
00295           component = this->components_[i];
00296           return 1;
00297         }
00298     }
00299 
00300   return 0;
00301 }

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.inl.

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 <tag> a well-known component?

Definition at line 51 of file Tagged_Components.inl.

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 237 of file Tagged_Components.cpp.

References remove_component_i().

00238 {
00239   if (this->known_tag (id))
00240     {
00241       return this->remove_known_component_i (id);
00242     }
00243   else
00244     {
00245       return this->remove_component_i (id);
00246     }
00247 }

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

Definition at line 270 of file Tagged_Components.cpp.

References components_.

Referenced by remove_component().

00271 {
00272   CORBA::ULong src = 0, dest = 0;
00273   CORBA::ULong len = this->components_.length ();
00274 
00275   for (;src != len;++src)
00276     {
00277       if ( tag != this->components_[src].tag)
00278         {
00279           this->components_[dest] = this->components_[src];
00280           ++dest;
00281         }
00282     }
00283 
00284   this->components_.length (dest);
00285   return src - dest;
00286 }

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

Helper methods to implement remove_component().

Definition at line 250 of file Tagged_Components.cpp.

References code_sets_set_, orb_type_, and orb_type_set_.

00251 {
00252   if (tag == IOP::TAG_ORB_TYPE)
00253     {
00254       this->orb_type_ = 0;
00255       this->orb_type_set_ = 0;
00256       return 1;
00257     }
00258   else if (tag == IOP::TAG_CODE_SETS)
00259     {
00260       this->code_sets_set_ = 0;
00261       return 1;
00262     }
00263   else
00264     {
00265       return 0;
00266     }
00267 }

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_, set_code_sets_i(), set_component_i(), and TAO_ENCAP_BYTE_ORDER.

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

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 61 of file Tagged_Components.cpp.

Referenced by set_code_sets(), and set_known_component_i().

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

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 116 of file Tagged_Components.cpp.

References add_component_i().

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

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 98 of file Tagged_Components.cpp.

References add_component_i().

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

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

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

Definition at line 75 of file Tagged_Components.cpp.

References ACE_OutputCDR::begin(), ACE_Message_Block::cont(), ACE_OS::memcpy(), set_component_i(), and ACE_OutputCDR::total_length().

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

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

Definition at line 195 of file Tagged_Components.cpp.

References add_component_i(), and components_.

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

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

Definition at line 178 of file Tagged_Components.cpp.

References add_component_i(), and components_.

Referenced by set_code_sets(), and set_component_i().

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

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

Helper methods to implement set_component().

Definition at line 134 of file Tagged_Components.cpp.

References code_sets_set_, orb_type_, orb_type_set_, and set_code_sets_i().

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

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 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 <tag> show up only once?

Definition at line 59 of file Tagged_Components.inl.

References TAO_TAG_ENDPOINTS.

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(), 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(), and set_known_component_i().

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(), and set_known_component_i().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:39:47 2010 for TAO by  doxygen 1.4.7