CORBA::TypeCode
implementation for an OMG IDL union
.
More...
#include <Union_TypeCode.h>
Inheritance diagram for TAO::TypeCode::Union< StringType, TypeCodeType, CaseArrayType, RefCountPolicy >:
Public Types | |
typedef TAO::TypeCode::Case< StringType, TypeCodeType > | case_type |
Public Member Functions | |
Union (char const *id, char const *name, TypeCodeType const &discriminant_type, CaseArrayType const &cases, CORBA::ULong ncases, CORBA::Long default_index) | |
Constructor. | |
Union (CORBA::TCKind kind, char const *id) | |
Constructor used for recursive TypeCodes. | |
TAO-specific @c CORBA::TypeCode Methods | |
virtual bool | tao_marshal (TAO_OutputCDR &cdr, CORBA::ULong offset) const |
Marshal this TypeCode into a CDR output stream. | |
virtual void | tao_duplicate (void) |
Increase the reference count on this TypeCode . | |
virtual void | tao_release (void) |
Decrease the reference count on this object. | |
Protected Member Functions | |
@c TAO CORBA::TypeCode Template Methods | |
virtual CORBA::Boolean | equal_i (CORBA::TypeCode_ptr tc) const |
virtual CORBA::Boolean | equivalent_i (CORBA::TypeCode_ptr tc) const |
virtual CORBA::TypeCode_ptr | get_compact_typecode_i (void) const |
virtual char const * | id_i (void) const |
virtual char const * | name_i (void) const |
virtual CORBA::ULong | member_count_i (void) const |
virtual char const * | member_name_i (CORBA::ULong index) const |
virtual CORBA::TypeCode_ptr | member_type_i (CORBA::ULong index) const |
virtual CORBA::Any * | member_label_i (CORBA::ULong index) const |
virtual CORBA::TypeCode_ptr | discriminator_type_i (void) const |
virtual CORBA::Long | default_index_i (void) const |
Protected Attributes | |
Base_Attributes< StringType > | base_attributes_ |
TypeCodeType | discriminant_type_ |
Type of IDL union discriminant. | |
CORBA::Long | default_index_ |
Index of the default union case. | |
CORBA::ULong | ncases_ |
CaseArrayType | cases_ |
CORBA::TypeCode
implementation for an OMG IDL union
.
This class implements a CORBA::TypeCode
for an OMG IDL union
.
Definition at line 48 of file Union_TypeCode.h.
|
|
Constructor.
Definition at line 15 of file Union_TypeCode.inl.
00028 : ::CORBA::TypeCode (CORBA::tk_union) 00029 , RefCountPolicy () 00030 , base_attributes_ (id, name) 00031 , discriminant_type_ (discriminant_type) 00032 , default_index_ (default_index) 00033 , ncases_ (ncases) 00034 , cases_ (cases) 00035 { 00036 } |
|
Constructor used for recursive TypeCodes.
Definition at line 46 of file Union_TypeCode.inl.
00049 : ::CORBA::TypeCode (CORBA::tk_union) 00050 , RefCountPolicy () 00051 , base_attributes_ (id) 00052 , discriminant_type_ (0) 00053 , default_index_ (-1) 00054 , ncases_ (0) 00055 , cases_ () 00056 { 00057 } |
|
Reimplemented from CORBA::TypeCode. Definition at line 410 of file Union_TypeCode.cpp.
00411 { 00412 return this->default_index_; 00413 } |
|
Reimplemented from CORBA::TypeCode. Definition at line 395 of file Union_TypeCode.cpp. References CORBA::TypeCode::_duplicate().
00396 { 00397 return 00398 CORBA::TypeCode::_duplicate ( 00399 Traits<StringType>::get_typecode (this->discriminant_type_)); 00400 } |
|
Implements CORBA::TypeCode. Definition at line 111 of file Union_TypeCode.cpp. References TAO::TypeCode::Union< StringType, TypeCodeType, CaseArrayType, RefCountPolicy >::case_type, and TAO::TypeCode::Case< StringType, TypeCodeType >::equal().
00112 { 00113 // These calls shouldn't throw since CORBA::TypeCode::equal() 00114 // verified that the TCKind is the same as our's prior to invoking 00115 // this method, meaning that the CORBA::tk_union TypeCode methods 00116 // are supported. 00117 00118 CORBA::ULong const tc_count = 00119 tc->member_count (); 00120 00121 CORBA::Long tc_def = tc->default_index (); 00122 00123 if (tc_count != this->ncases_ 00124 || tc_def != this->default_index_) 00125 return false; 00126 00127 // Check the discriminator type. 00128 CORBA::TypeCode_var tc_discriminator = 00129 tc->discriminator_type (); 00130 00131 CORBA::Boolean const equal_discriminators = 00132 Traits<StringType>::get_typecode (this->discriminant_type_)->equal ( 00133 tc_discriminator.in ()); 00134 00135 if (!equal_discriminators) 00136 return false; 00137 00138 for (CORBA::ULong i = 0; i < this->ncases_; ++i) 00139 { 00140 if (this->default_index_ > -1 00141 && static_cast<CORBA::ULong> (this->default_index_) == i) 00142 { 00143 // Don't bother checking equality of default case label. It 00144 // will always be the zero octet (the CDR encoded value is 00145 // ignored). 00146 continue; 00147 } 00148 00149 case_type const & lhs_case = *this->cases_[i]; 00150 00151 bool const equal_case = lhs_case.equal (i, tc); 00152 00153 if (!equal_case) 00154 return false; 00155 } 00156 00157 return true; 00158 } |
|
Implements CORBA::TypeCode. Definition at line 168 of file Union_TypeCode.cpp. References TAO::TypeCode::Union< StringType, TypeCodeType, CaseArrayType, RefCountPolicy >::case_type, and TAO::TypeCode::Case< StringType, TypeCodeType >::equivalent().
00169 { 00170 // Perform a structural comparison, excluding the name() and 00171 // member_name() operations. 00172 00173 CORBA::ULong const tc_count = 00174 tc->member_count (); 00175 00176 CORBA::Long tc_def = tc->default_index (); 00177 00178 if (tc_count != this->ncases_ 00179 || tc_def != this->default_index_) 00180 return false; 00181 00182 CORBA::TypeCode_var tc_discriminator = 00183 tc->discriminator_type (); 00184 00185 CORBA::Boolean const equiv_discriminators = 00186 Traits<StringType>::get_typecode (this->discriminant_type_)->equivalent ( 00187 tc_discriminator.in ()); 00188 00189 if (!equiv_discriminators) 00190 return false; 00191 00192 for (CORBA::ULong i = 0; i < this->ncases_; ++i) 00193 { 00194 if (this->default_index_ > -1 00195 && static_cast<CORBA::ULong> (this->default_index_) == i) 00196 { 00197 // Don't bother checking equality/equivalence of default 00198 // case label. It will always be the zero octet (the CDR 00199 // encoded value is ignored). 00200 continue; 00201 } 00202 00203 case_type const & lhs_case = *this->cases_[i]; 00204 00205 bool const equivalent_case = 00206 lhs_case.equivalent (i, tc); 00207 00208 if (!equivalent_case) 00209 return false; 00210 } 00211 00212 return true; 00213 } |
|
Implements CORBA::TypeCode. Definition at line 223 of file Union_TypeCode.cpp.
00224 { 00225 // typedef ACE::Value_Ptr<TAO::TypeCode::Case<CORBA::String_var, 00226 // CORBA::TypeCode_var> > elem_type; 00227 00228 // ACE_Array_Base<elem_type> tc_cases (this->ncases_); 00229 00230 // if (this->ncases_ > 0) 00231 // { 00232 // // Dynamically construct a new array of cases stripped of 00233 // // member names. 00234 00235 // static char const empty_name[] = ""; 00236 00237 // for (CORBA::ULong i = 0; i < this->ncases_; ++i) 00238 // { 00239 // // Member names will be stripped, i.e. not embedded within 00240 // // the compact TypeCode. 00241 // tc_cases[i].name = empty_name; 00242 // tc_cases[i].type = 00243 // this->cases_[i]->type ()->get_compact_typecode ( 00244 // ); 00245 // } 00246 // } 00247 00248 // // Create the compact union TypeCode. 00249 // TAO_TypeCodeFactory_Adapter * adapter = 00250 // ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance ( 00251 // TAO_ORB_Core::typecodefactory_adapter_name ()); 00252 00253 // if (adapter == 0) 00254 // { 00255 // throw ::CORBA::INTERNAL (); 00256 // } 00257 00258 // return 00259 // adapter->create_union_tc ( 00260 // this->base_attributes_.id (), 00261 // "", /* empty name */ 00262 // Traits<StringType>::get_typecode (this->discriminant_type_), 00263 // tc_cases, 00264 // this->ncases_, 00265 // this->default_index_, 00266 // "", 00267 // Traits<StringType>::get_typecode (this->default_case_.type) 00268 // ); 00269 00270 throw ::CORBA::NO_IMPLEMENT (); 00271 } |
|
Reimplemented from CORBA::TypeCode. Definition at line 281 of file Union_TypeCode.cpp.
00282 { 00283 // Ownership is retained by the TypeCode, as required by the C++ 00284 // mapping. 00285 return this->base_attributes_.id (); 00286 } |
|
Reimplemented from CORBA::TypeCode. Definition at line 311 of file Union_TypeCode.cpp.
00312 { 00313 return this->ncases_; 00314 } |
|
Reimplemented from CORBA::TypeCode. Definition at line 358 of file Union_TypeCode.cpp. References CORBA::Any_var::_retn(), ACE_NEW_THROW_EX, and CORBA::Any::from_octet.
00359 { 00360 if (index >= this->ncases_) 00361 throw ::CORBA::TypeCode::Bounds (); 00362 00363 // Default case. 00364 if (this->default_index_ > -1 00365 && static_cast<CORBA::ULong> (this->default_index_) == index) 00366 { 00367 CORBA::Any * any = 0; 00368 ACE_NEW_THROW_EX (any, 00369 CORBA::Any, 00370 CORBA::NO_MEMORY ()); 00371 00372 CORBA::Any_var safe_any (any); 00373 00374 // Default case's label is a zero octet. 00375 CORBA::Any::from_octet const zero_octet (0); 00376 00377 // Default case/member has a zero octet label value. 00378 (*any) <<= zero_octet; 00379 00380 return safe_any._retn (); 00381 } 00382 00383 // Non-default cases. 00384 return this->cases_[index]->label (); 00385 } |
|
Reimplemented from CORBA::TypeCode. Definition at line 324 of file Union_TypeCode.cpp.
|
|
Reimplemented from CORBA::TypeCode. Definition at line 342 of file Union_TypeCode.cpp. References CORBA::TypeCode::_duplicate().
00343 { 00344 if (index >= this->ncases_) 00345 throw ::CORBA::TypeCode::Bounds (); 00346 00347 return CORBA::TypeCode::_duplicate (this->cases_[index]->type ()); 00348 } |
|
Reimplemented from CORBA::TypeCode. Definition at line 296 of file Union_TypeCode.cpp.
00297 { 00298 // Ownership is retained by the TypeCode, as required by the C++ 00299 // mapping. 00300 return this->base_attributes_.name (); 00301 } |
|
Increase the reference count on this
Implements CORBA::TypeCode. Definition at line 85 of file Union_TypeCode.cpp.
00086 { 00087 this->RefCountPolicy::add_ref (); 00088 } |
|
Marshal this
Marshal this
Implements CORBA::TypeCode. Definition at line 27 of file Union_TypeCode.cpp. References ACE_align_binary(), ACE_OutputCDR::begin(), TAO::TypeCode::Union< StringType, TypeCodeType, CaseArrayType, RefCountPolicy >::case_type, TAO::TypeCode::Case< StringType, TypeCodeType >::marshal(), TAO_ENCAP_BYTE_ORDER, and ACE_OutputCDR::total_length().
00030 { 00031 // A tk_union TypeCode has a "complex" parameter list type (see 00032 // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of 00033 // the CORBA specification), meaning that it must be marshaled into 00034 // a CDR encapsulation. 00035 00036 // Create a CDR encapsulation. 00037 TAO_OutputCDR enc; 00038 00039 // Account for the encoded CDR encapsulation length and byte order. 00040 // 00041 // Aligning on an octet since the next value after the CDR 00042 // encapsulation length will always be the byte order octet/boolean 00043 // in this case. 00044 offset = ACE_align_binary (offset + 4, 00045 ACE_CDR::OCTET_ALIGN); 00046 00047 bool const success = 00048 (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) 00049 && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) 00050 && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) 00051 && marshal (enc, 00052 Traits<StringType>::get_typecode (this->discriminant_type_), 00053 offset + enc.total_length ()) 00054 && (enc << this->default_index_) 00055 && (enc << this->ncases_); 00056 00057 if (!success) 00058 { 00059 return false; 00060 } 00061 00062 for (CORBA::ULong i = 0; i < this->ncases_; ++i) 00063 { 00064 case_type const & c = *this->cases_[i]; 00065 00066 if (!c.marshal (enc, offset)) 00067 { 00068 return false; 00069 } 00070 } 00071 00072 return 00073 cdr << static_cast<CORBA::ULong> (enc.total_length ()) 00074 && cdr.write_octet_array_mb (enc.begin ()); 00075 } |
|
Decrease the reference count on this object.
Implements CORBA::TypeCode. Definition at line 98 of file Union_TypeCode.cpp.
00099 { 00100 this->RefCountPolicy::remove_ref (); 00101 } |
|
Base attributes containing repository ID and name of union type. Definition at line 135 of file Union_TypeCode.h. |
|
Array of Definition at line 153 of file Union_TypeCode.h. |
|
Index of the default union case. This value will be -1 if no default case is found in the union. Definition at line 145 of file Union_TypeCode.h. |
|
Type of IDL
Definition at line 138 of file Union_TypeCode.h. |
|
The number of cases in the OMG IDL union, excluding the Definition at line 149 of file Union_TypeCode.h. |