CORBA::TypeCode
implementation for an OMG IDL struct
or exception
.
More...
#include <Struct_TypeCode.h>
Inheritance diagram for TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >:
Public Member Functions | |
Struct (CORBA::TCKind kind, char const *id, char const *name, FieldArrayType const &fields, CORBA::ULong nfields) | |
Constructor. | |
Struct (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 |
Protected Attributes | |
Base_Attributes< StringType > | base_attributes_ |
CORBA::ULong | nfields_ |
The number of fields in the OMG IDL structure. | |
FieldArrayType | fields_ |
CORBA::TypeCode
implementation for an OMG IDL struct
or exception
.
This class implements a CORBA::TypeCode
for an OMG IDL struct
or exception
.
Definition at line 51 of file Struct_TypeCode.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::Struct | ( | CORBA::TCKind | kind, | |
char const * | id, | |||
char const * | name, | |||
FieldArrayType const & | fields, | |||
CORBA::ULong | nfields | |||
) |
Constructor.
Definition at line 15 of file Struct_TypeCode.inl.
00021 : ::CORBA::TypeCode (kind) 00022 , RefCountPolicy () 00023 , base_attributes_ (id, name) 00024 , nfields_ (nfields) 00025 , fields_ (fields) 00026 { 00027 }
ACE_INLINE TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::Struct | ( | CORBA::TCKind | kind, | |
char const * | id | |||
) |
Constructor used for recursive TypeCodes.
Definition at line 37 of file Struct_TypeCode.inl.
00040 : ::CORBA::TypeCode (kind) 00041 , RefCountPolicy () 00042 , base_attributes_ (id) 00043 , nfields_ (0) 00044 , fields_ () 00045 { 00046 // CORBA::tk_except is not allowed in the recursive TypeCode case. 00047 // ACE_ASSERT (kind == CORBA::tk_struct); 00048 }
CORBA::Boolean TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::equal_i | ( | CORBA::TypeCode_ptr | tc | ) | const [protected, virtual] |
Implements CORBA::TypeCode.
Definition at line 115 of file Struct_TypeCode.cpp.
References CORBA::TypeCode::equal(), TAO_Pseudo_Var_T< T >::in(), and ACE_OS::strcmp().
00116 { 00117 // This call shouldn't throw since CORBA::TypeCode::equal() verified 00118 // that the TCKind is the same as our's prior to invoking this 00119 // method, meaning that member_count() is supported. 00120 00121 CORBA::ULong const tc_nfields = 00122 tc->member_count (); 00123 00124 if (tc_nfields != this->nfields_) 00125 return false; 00126 00127 for (CORBA::ULong i = 0; i < this->nfields_; ++i) 00128 { 00129 Struct_Field<StringType, TypeCodeType> const & lhs_field = 00130 this->fields_[i]; 00131 00132 char const * const lhs_name = 00133 Traits<StringType>::get_string (lhs_field.name); 00134 char const * const rhs_name = tc->member_name (i); 00135 00136 if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) 00137 return false; 00138 00139 CORBA::TypeCode_ptr const lhs_tc = 00140 Traits<StringType>::get_typecode (lhs_field.type); 00141 CORBA::TypeCode_var const rhs_tc = 00142 tc->member_type (i); 00143 00144 CORBA::Boolean const equal_members = 00145 lhs_tc->equal (rhs_tc.in ()); 00146 00147 if (!equal_members) 00148 return false; 00149 } 00150 00151 return true; 00152 }
CORBA::Boolean TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::equivalent_i | ( | CORBA::TypeCode_ptr | tc | ) | const [protected, virtual] |
Implements CORBA::TypeCode.
Definition at line 162 of file Struct_TypeCode.cpp.
00164 { 00165 // Perform a structural comparison, excluding the name() and 00166 // member_name() operations. 00167 00168 CORBA::ULong const tc_nfields = 00169 tc->member_count (); 00170 00171 if (tc_nfields != this->nfields_) 00172 return false; 00173 00174 for (CORBA::ULong i = 0; i < this->nfields_; ++i) 00175 { 00176 CORBA::TypeCode_ptr const lhs = 00177 Traits<StringType>::get_typecode (this->fields_[i].type); 00178 CORBA::TypeCode_var const rhs = 00179 tc->member_type (i); 00180 00181 CORBA::Boolean const equiv_members = 00182 lhs->equivalent (rhs.in ()); 00183 00184 if (!equiv_members) 00185 return false; 00186 } 00187 00188 return true; 00189 }
CORBA::TypeCode_ptr TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::get_compact_typecode_i | ( | void | ) | const [protected, virtual] |
Implements CORBA::TypeCode.
Definition at line 199 of file Struct_TypeCode.cpp.
References TAO_TypeCodeFactory_Adapter::create_struct_except_tc(), ACE_Dynamic_Service< TYPE >::instance(), and TAO_ORB_Core::typecodefactory_adapter_name().
00200 { 00201 ACE_Array_Base<Struct_Field<CORBA::String_var, 00202 CORBA::TypeCode_var> > 00203 tc_fields (this->nfields_); 00204 00205 if (this->nfields_ > 0) 00206 { 00207 // Dynamically construct a new array of fields stripped of 00208 // member names. 00209 00210 static char const empty_name[] = ""; 00211 00212 for (CORBA::ULong i = 0; i < this->nfields_; ++i) 00213 { 00214 // Member names will be stripped, i.e. not embedded within 00215 // the compact TypeCode. 00216 00217 tc_fields[i].name = empty_name; 00218 tc_fields[i].type = 00219 Traits<StringType>::get_typecode ( 00220 this->fields_[i].type)->get_compact_typecode (); 00221 } 00222 } 00223 00224 TAO_TypeCodeFactory_Adapter * const adapter = 00225 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance ( 00226 TAO_ORB_Core::typecodefactory_adapter_name ()); 00227 00228 if (adapter == 0) 00229 { 00230 throw ::CORBA::INTERNAL (); 00231 } 00232 00233 return 00234 adapter->create_struct_except_tc (this->kind_, 00235 this->base_attributes_.id (), 00236 "" /* empty name */, 00237 tc_fields, 00238 this->nfields_); 00239 }
char const * TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::id_i | ( | void | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 249 of file Struct_TypeCode.cpp.
References CORBA::TypeCode::id().
00250 { 00251 // Ownership is retained by the TypeCode, as required by the C++ 00252 // mapping. 00253 return this->base_attributes_.id (); 00254 }
CORBA::ULong TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::member_count_i | ( | void | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 279 of file Struct_TypeCode.cpp.
00280 { 00281 return this->nfields_; 00282 }
char const * TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::member_name_i | ( | CORBA::ULong | index | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 292 of file Struct_TypeCode.cpp.
00294 { 00295 // Ownership is retained by the TypeCode, as required by the C++ 00296 // mapping. 00297 if (index >= this->nfields_) 00298 throw ::CORBA::TypeCode::Bounds (); 00299 00300 return Traits<StringType>::get_string (this->fields_[index].name); 00301 }
CORBA::TypeCode_ptr TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::member_type_i | ( | CORBA::ULong | index | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 311 of file Struct_TypeCode.cpp.
References CORBA::TypeCode::_duplicate().
00313 { 00314 if (index >= this->nfields_) 00315 throw ::CORBA::TypeCode::Bounds (); 00316 00317 return 00318 CORBA::TypeCode::_duplicate ( 00319 Traits<StringType>::get_typecode (this->fields_[index].type)); 00320 }
char const * TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::name_i | ( | void | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 264 of file Struct_TypeCode.cpp.
00265 { 00266 // Ownership is retained by the TypeCode, as required by the C++ 00267 // mapping. 00268 return this->base_attributes_.name (); 00269 }
void TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::tao_duplicate | ( | void | ) | [virtual] |
Increase the reference count on this TypeCode
.
Implements CORBA::TypeCode.
Definition at line 89 of file Struct_TypeCode.cpp.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL bool TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::tao_marshal | ( | TAO_OutputCDR & | cdr, | |
CORBA::ULong | offset | |||
) | const [virtual] |
Marshal this TypeCode
into a CDR output stream.
Marshal this TypeCode
into the cdr output CDR stream, excluding the TypeCode
kind. Existing cdr contents will not be altered. The marshaled TypeCode
will be appended to the given cdr CDR output stream.
cdr | Output CDR stream into which the TypeCode will be marshaled. | |
offset | Number of bytes currently in the output CDR stream, including the top-level TypeCode TCKind . This argument is useful for recursive TypeCodes . TypeCodes that contain other TypeCodes should pass an updated offset value to the marshaling operation for those contained TypeCodes . |
true
if marshaling was successful.CORBA::TypeCode
interface.If this method returns false, the contents of the cdr output CDR stream are undefined.
Implements CORBA::TypeCode.
Definition at line 31 of file Struct_TypeCode.cpp.
References ACE_align_binary(), ACE_CDR::OCTET_ALIGN, and TAO_ENCAP_BYTE_ORDER.
00033 { 00034 // A tk_struct TypeCode has a "complex" parameter list type (see 00035 // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of 00036 // the CORBA specification), meaning that it must be marshaled into 00037 // a CDR encapsulation. 00038 00039 // Create a CDR encapsulation. 00040 TAO_OutputCDR enc; 00041 00042 // Account for the encoded CDR encapsulation length and byte order. 00043 // 00044 // Aligning on an octet since the next value after the CDR 00045 // encapsulation length will always be the byte order octet/boolean 00046 // in this case. 00047 offset = ACE_align_binary (offset + 4, 00048 ACE_CDR::OCTET_ALIGN); 00049 00050 bool const success = 00051 (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) 00052 && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) 00053 && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) 00054 && (enc << this->nfields_); 00055 00056 if (!success) 00057 return false; 00058 00059 Struct_Field<StringType, TypeCodeType> const * const begin = 00060 &this->fields_[0]; 00061 Struct_Field<StringType, TypeCodeType> const * const end = 00062 begin + this->nfields_; 00063 00064 for (Struct_Field<StringType, TypeCodeType> const * i = begin; i != end; ++i) 00065 { 00066 Struct_Field<StringType, TypeCodeType> const & field = *i; 00067 00068 if (!(enc << TAO_OutputCDR::from_string ( 00069 Traits<StringType>::get_string (field.name), 0)) 00070 || !marshal (enc, 00071 Traits<StringType>::get_typecode (field.type), 00072 offset + enc.total_length ())) 00073 return false; 00074 } 00075 00076 return 00077 cdr << static_cast<CORBA::ULong> (enc.total_length ()) 00078 && cdr.write_octet_array_mb (enc.begin ()); 00079 }
void TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::tao_release | ( | void | ) | [virtual] |
Decrease the reference count on this object.
Implements CORBA::TypeCode.
Definition at line 102 of file Struct_TypeCode.cpp.
Base_Attributes<StringType> TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::base_attributes_ [protected] |
Base attributes containing repository ID and name of structure type.
Definition at line 118 of file Struct_TypeCode.h.
FieldArrayType TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::fields_ [protected] |
Array of TAO::TypeCode
fields representing structure of the OMG IDL defined struct
.
Definition at line 125 of file Struct_TypeCode.h.
CORBA::ULong TAO::TypeCode::Struct< StringType, TypeCodeType, FieldArrayType, RefCountPolicy >::nfields_ [protected] |