00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Tagged_Components.h 00006 * 00007 * $Id: Tagged_Components.h 73791 2006-07-27 20:54:56Z wotte $ 00008 * 00009 * @author Carlos O'Ryan (coryan@cs.wustl.edu) 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_TAGGED_COMPONENTS_H 00014 #define TAO_TAGGED_COMPONENTS_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "tao/IOP_IORC.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "tao/CONV_FRAMEC.h" 00025 00026 00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00028 00029 class TAO_Profile; 00030 00031 /// Tag for storing multiple endpoints within a single profile. 00032 /** 00033 * This is TAO-specific, and is mostly used by TAO's RTCORBA support. 00034 * The standard TAG_ALTERNATE_IIOP_ADDRESSES tagged component is the 00035 * portable alternative. 00036 */ 00037 static const CORBA::ULong TAO_TAG_ENDPOINTS = 0x54414f02U; 00038 00039 /** 00040 * @class TAO_Tagged_Components 00041 * 00042 * @brief The policy manager implementation. 00043 * 00044 * This class is used to manipulate and access the <components> 00045 * field of an IIOP profile (and other GIOP profiles). 00046 * The definition for that field is simply a sequence of the 00047 * following structures: 00048 * typedef unsigned long ComponentId; 00049 * struct TaggedComponent { 00050 * ComponentId tag; 00051 * sequence<octet> component_data; 00052 * }; 00053 * the real motivation is to minimize the marshaling and 00054 * demarshaling of the <component_data> field for certain critical 00055 * components. 00056 */ 00057 class TAO_Export TAO_Tagged_Components 00058 { 00059 public: 00060 /// Constructor 00061 TAO_Tagged_Components (void); 00062 00063 // = Standard OMG that require fast access. 00064 /// The the IOP::TAG_ORB_TYPE component value 00065 void set_orb_type (CORBA::ULong orb_type); 00066 00067 /// Gets the IOP::TAG_ORB_TYPE component value, return 0 if the 00068 /// component is not present. 00069 int get_orb_type (CORBA::ULong& orb_type) const; 00070 00071 /** 00072 * The the IOP::TAG_CODE_SETS component value, the first version 00073 * copies the data, the second version steal all the sequence 00074 * buffers. 00075 */ 00076 void set_code_sets (const CONV_FRAME::CodeSetComponentInfo &); 00077 void set_code_sets (CONV_FRAME::CodeSetComponentInfo &); 00078 00079 /// Gets a reference of the IOP::TAG_CODE_SETS component value, 00080 /// return 0 if the component is not present. 00081 int get_code_sets (const CONV_FRAME::CodeSetComponentInfo* &) const; 00082 00083 /// Gets a copy of the IOP::TAG_CODE_SETS component value, return 0 00084 /// if the component is not present. 00085 int get_code_sets (CONV_FRAME::CodeSetComponentInfo &) const; 00086 00087 // = Generic components 00088 00089 /// Insert the component into the list, making a copy of the octet 00090 /// sequence. 00091 void set_component (const IOP::TaggedComponent& component); 00092 00093 /// Insert the component into the list, but efficiently stealing the 00094 /// contents of the octet sequence. 00095 void set_component (IOP::TaggedComponent& component); 00096 00097 /// Get a copy of the component identified by <component.tag>, return 00098 /// 0 if the component is not present. 00099 int get_component (IOP::TaggedComponent& component) const; 00100 00101 /// Remove a component, if present. Return number of components 00102 /// removed. 00103 int remove_component (IOP::ComponentId id); 00104 00105 // = Marshaling and demarshaling 00106 00107 /// Marshal and demarshal the list. 00108 int encode (TAO_OutputCDR& cdr) const; 00109 int decode (TAO_InputCDR& cdr); 00110 00111 /** 00112 * Read/Write access to the underlying 00113 * MutipleComponentProfile. Added by request from Chris Hafey 00114 * <chris@stentorsoft.com> 00115 */ 00116 IOP::MultipleComponentProfile &components (void); 00117 00118 private: 00119 /// Helper method to implement set_code_sets() 00120 void set_code_sets_i (CONV_FRAME::CodeSetComponent &lhs, 00121 CONV_FRAME::CodeSetComponent &rhs); 00122 00123 /// Helper methods to implement set_component() 00124 void set_known_component_i (const IOP::TaggedComponent& component); 00125 void set_component_i (const IOP::TaggedComponent& component); 00126 void set_component_i (IOP::TaggedComponent& component); 00127 void add_component_i (const IOP::TaggedComponent& component); 00128 void add_component_i (IOP::TaggedComponent& component); 00129 void set_component_i (IOP::ComponentId tag, TAO_OutputCDR &cdr); 00130 00131 /// Helper methods to implement remove_component() 00132 int remove_known_component_i (IOP::ComponentId tag); 00133 int remove_component_i (IOP::ComponentId tag); 00134 00135 /// Helper methods to implement set_component() 00136 int get_known_component_i (IOP::TaggedComponent& component) const; 00137 int get_component_i (IOP::TaggedComponent& component) const; 00138 00139 /// Is <tag> a well-known component? 00140 int known_tag (IOP::ComponentId tag) const; 00141 00142 /// Does <tag> show up only once? 00143 int unique_tag (IOP::ComponentId tag) const; 00144 00145 private: 00146 /// The ORB_TYPE component value 00147 CORBA::ULong orb_type_; 00148 00149 /// The ORB_TYPE component value 00150 CONV_FRAME::CodeSetComponentInfo code_sets_; 00151 00152 /// The rest of the components, to be compliant we cannot drop a 00153 /// bunch of them. 00154 IOP::MultipleComponentProfile components_; 00155 00156 // A flag for each component... 00157 CORBA::Octet orb_type_set_; 00158 CORBA::Octet code_sets_set_; 00159 }; 00160 00161 TAO_END_VERSIONED_NAMESPACE_DECL 00162 00163 #if defined (__ACE_INLINE__) 00164 # include "tao/Tagged_Components.inl" 00165 #endif /* __ACE_INLINE__ */ 00166 00167 #include /**/ "ace/post.h" 00168 00169 #endif /* TAO_TAGGED_COMPONENTS_H */