CORBA::TypeCode
implementation for an OMG IDL enum
.
More...
#include <Enum_TypeCode.h>
Inheritance diagram for TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >:
Public Member Functions | |
Enum (char const *id, char const *name, EnumeratorArrayType const &enumerators, CORBA::ULong nenumerators) | |
Constructor. | |
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 |
Private Attributes | |
Base_Attributes< StringType > | base_attributes_ |
CORBA::ULong const | nenumerators_ |
The number of enumerators in the OMG IDL enumeration. | |
EnumeratorArrayType const | enumerators_ |
CORBA::TypeCode
implementation for an OMG IDL enum
.
This class implements a CORBA::TypeCode
for an OMG IDL enum
.
Definition at line 46 of file Enum_TypeCode.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::Enum | ( | char const * | id, | |
char const * | name, | |||
EnumeratorArrayType const & | enumerators, | |||
CORBA::ULong | nenumerators | |||
) |
Constructor.
Definition at line 11 of file Enum_TypeCode.inl.
00016 : ::CORBA::TypeCode (CORBA::tk_enum) 00017 , RefCountPolicy () 00018 , base_attributes_ (id, name) 00019 , nenumerators_ (nenumerators) 00020 , enumerators_ (enumerators) 00021 { 00022 }
CORBA::Boolean TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::equal_i | ( | CORBA::TypeCode_ptr | tc | ) | const [protected, virtual] |
Implements CORBA::TypeCode.
Definition at line 83 of file Enum_TypeCode.cpp.
References ACE_OS::strcmp().
00086 { 00087 // This call shouldn't throw since CORBA::TypeCode::equal() verified 00088 // that the TCKind is the same as our's prior to invoking this 00089 // method, meaning that member_count() is supported. 00090 00091 CORBA::ULong const tc_nenumerators = 00092 tc->member_count (); 00093 00094 if (tc_nenumerators != this->nenumerators_) 00095 return false; 00096 00097 for (CORBA::ULong i = 0; i < this->nenumerators_; ++i) 00098 { 00099 StringType const & lhs_enumerator = this->enumerators_[i]; 00100 00101 char const * const lhs_name = 00102 Traits<StringType>::get_string (lhs_enumerator); 00103 char const * const rhs_name = tc->member_name (i 00104 ); 00105 00106 if (ACE_OS::strcmp (lhs_name, rhs_name) != 0) 00107 return false; 00108 } 00109 00110 return true; 00111 }
CORBA::Boolean TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::equivalent_i | ( | CORBA::TypeCode_ptr | tc | ) | const [protected, virtual] |
Implements CORBA::TypeCode.
Definition at line 117 of file Enum_TypeCode.cpp.
00120 { 00121 // Perform a structural comparison, excluding the name() and 00122 // member_name() operations. 00123 00124 CORBA::ULong const tc_nenumerators = 00125 tc->member_count (); 00126 00127 if (tc_nenumerators != this->nenumerators_) 00128 return false; 00129 00130 return true; 00131 }
CORBA::TypeCode_ptr TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::get_compact_typecode_i | ( | void | ) | const [protected, virtual] |
Implements CORBA::TypeCode.
Definition at line 137 of file Enum_TypeCode.cpp.
References TAO_TypeCodeFactory_Adapter::create_enum_tc(), ACE_Dynamic_Service< TYPE >::instance(), and TAO_ORB_Core::typecodefactory_adapter_name().
00139 { 00140 ACE_Array_Base<CORBA::String_var> tc_enumerators (this->nenumerators_); 00141 00142 // Dynamically construct a new array of enumerators stripped of 00143 // member names. 00144 00145 static char const empty_name[] = ""; 00146 00147 for (CORBA::ULong i = 0; i < this->nenumerators_; ++i) 00148 { 00149 // Member names will be stripped, i.e. not embedded within 00150 // the compact TypeCode. 00151 00152 tc_enumerators[i] = empty_name; 00153 } 00154 00155 TAO_TypeCodeFactory_Adapter * adapter = 00156 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance ( 00157 TAO_ORB_Core::typecodefactory_adapter_name ()); 00158 00159 if (adapter == 0) 00160 { 00161 throw ::CORBA::INTERNAL (); 00162 } 00163 00164 return 00165 adapter->create_enum_tc (this->base_attributes_.id (), 00166 "" /* empty name */, 00167 tc_enumerators, 00168 this->nenumerators_ 00169 ); 00170 }
char const * TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::id_i | ( | void | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 174 of file Enum_TypeCode.cpp.
References TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::base_attributes_, and TAO::TypeCode::Base_Attributes< STRING_TYPE >::id().
00176 { 00177 // Ownership is retained by the TypeCode, as required by the C++ 00178 // mapping. 00179 return this->base_attributes_.id (); 00180 }
CORBA::ULong TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::member_count_i | ( | void | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 196 of file Enum_TypeCode.cpp.
00198 { 00199 return this->nenumerators_; 00200 }
char const * TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::member_name_i | ( | CORBA::ULong | index | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 206 of file Enum_TypeCode.cpp.
00209 { 00210 // Ownership is retained by the TypeCode, as required by the C++ 00211 // mapping. 00212 if (index >= this->nenumerators_) 00213 throw ::CORBA::TypeCode::Bounds (); 00214 00215 return Traits<StringType>::get_string (this->enumerators_[index]); 00216 }
char const * TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::name_i | ( | void | ) | const [protected, virtual] |
Reimplemented from CORBA::TypeCode.
Definition at line 184 of file Enum_TypeCode.cpp.
References TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::base_attributes_, and TAO::TypeCode::Base_Attributes< STRING_TYPE >::name().
00186 { 00187 // Ownership is retained by the TypeCode, as required by the C++ 00188 // mapping. 00189 return this->base_attributes_.name (); 00190 }
void TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::tao_duplicate | ( | void | ) | [virtual] |
Increase the reference count on this TypeCode
.
Implements CORBA::TypeCode.
Definition at line 65 of file Enum_TypeCode.cpp.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL bool TAO::TypeCode::Enum< StringType, EnumeratorArrayType, 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 24 of file Enum_TypeCode.cpp.
References TAO_ENCAP_BYTE_ORDER.
00026 { 00027 // A tk_enum TypeCode has a "complex" parameter list type (see 00028 // Table 15-2 in Section 15.3.5.1 "TypeCode" in the CDR section of 00029 // the CORBA specification), meaning that it must be marshaled into 00030 // a CDR encapsulation. 00031 00032 // Create a CDR encapsulation. 00033 TAO_OutputCDR enc; 00034 00035 bool const success = 00036 (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) 00037 && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0)) 00038 && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0)) 00039 && (enc << this->nenumerators_); 00040 00041 if (!success) 00042 return false; 00043 00044 StringType const * const begin = &this->enumerators_[0]; 00045 StringType const * const end = begin + this->nenumerators_; 00046 00047 for (StringType const * i = begin; i != end; ++i) 00048 { 00049 StringType const & enumerator = *i; 00050 00051 if (!(enc << TAO_OutputCDR::from_string ( 00052 Traits<StringType>::get_string (enumerator), 0))) 00053 return false; 00054 } 00055 00056 return 00057 cdr << static_cast<CORBA::ULong> (enc.total_length ()) 00058 && cdr.write_octet_array_mb (enc.begin ()); 00059 }
void TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::tao_release | ( | void | ) | [virtual] |
Decrease the reference count on this object.
Implements CORBA::TypeCode.
Definition at line 74 of file Enum_TypeCode.cpp.
Base_Attributes<StringType> TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::base_attributes_ [private] |
Base attributes containing repository ID and name of structure type.
Definition at line 107 of file Enum_TypeCode.h.
Referenced by TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::id_i(), and TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::name_i().
EnumeratorArrayType const TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::enumerators_ [private] |
Array of TAO::TypeCode
enumerators representing enumerators in the OMG IDL defined enum
.
Definition at line 114 of file Enum_TypeCode.h.
CORBA::ULong const TAO::TypeCode::Enum< StringType, EnumeratorArrayType, RefCountPolicy >::nenumerators_ [private] |
The number of enumerators in the OMG IDL enumeration.
Definition at line 110 of file Enum_TypeCode.h.