#include <DynEnum_i.h>
Inheritance diagram for TAO_DynEnum_i:
Public Member Functions | |
TAO_DynEnum_i (void) | |
Constructor. | |
~TAO_DynEnum_i (void) | |
Destructor. | |
void | init (CORBA::TypeCode_ptr tc) |
Initialize using just a TypeCode. | |
void | init (const CORBA::Any &any) |
Initialize using an Any. | |
virtual char * | get_as_string (void) |
virtual void | set_as_string (const char *value) |
virtual CORBA::ULong | get_as_ulong (void) |
virtual void | set_as_ulong (CORBA::ULong value) |
virtual void | from_any (const CORBA::Any &value) |
virtual CORBA::Any * | to_any (void) |
virtual CORBA::Boolean | equal (DynamicAny::DynAny_ptr dyn_any) |
virtual void | destroy (void) |
virtual DynamicAny::DynAny_ptr | current_component (void) |
Static Public Member Functions | |
static TAO_DynEnum_i * | _narrow (CORBA::Object_ptr obj) |
Private Member Functions | |
void | init_common (void) |
TAO_DynEnum_i (const TAO_DynEnum_i &src) | |
TAO_DynEnum_i & | operator= (const TAO_DynEnum_i &src) |
Private Attributes | |
CORBA::ULong | value_ |
Current numeric value of the enum. |
Definition at line 42 of file DynEnum_i.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_DynEnum_i::TAO_DynEnum_i | ( | void | ) |
TAO_DynEnum_i::~TAO_DynEnum_i | ( | void | ) |
TAO_DynEnum_i::TAO_DynEnum_i | ( | const TAO_DynEnum_i & | src | ) | [private] |
TAO_DynEnum_i * TAO_DynEnum_i::_narrow | ( | CORBA::Object_ptr | obj | ) | [static] |
Reimplemented from CORBA::LocalObject.
Definition at line 97 of file DynEnum_i.cpp.
References CORBA::is_nil().
Referenced by TAO_DynUnion_i::init(), and TAO_DynUnion_i::set_discriminator().
00098 { 00099 if (CORBA::is_nil (_tao_objref)) 00100 { 00101 return 0; 00102 } 00103 00104 return dynamic_cast<TAO_DynEnum_i *> (_tao_objref); 00105 }
DynamicAny::DynAny_ptr TAO_DynEnum_i::current_component | ( | void | ) | [virtual] |
Definition at line 290 of file DynEnum_i.cpp.
00291 { 00292 if (this->destroyed_) 00293 { 00294 throw ::CORBA::OBJECT_NOT_EXIST (); 00295 } 00296 00297 throw DynamicAny::DynAny::TypeMismatch (); 00298 }
void TAO_DynEnum_i::destroy | ( | void | ) | [virtual] |
Definition at line 276 of file DynEnum_i.cpp.
References TAO_DynCommon::destroyed_.
00277 { 00278 if (this->destroyed_) 00279 { 00280 throw ::CORBA::OBJECT_NOT_EXIST (); 00281 } 00282 00283 if (!this->ref_to_component_ || this->container_is_destroying_) 00284 { 00285 this->destroyed_ = true; 00286 } 00287 }
CORBA::Boolean TAO_DynEnum_i::equal | ( | DynamicAny::DynAny_ptr | dyn_any | ) | [virtual] |
Definition at line 235 of file DynEnum_i.cpp.
References ACE_InputCDR::read_ulong(), and value_.
00236 { 00237 CORBA::TypeCode_var tc = rhs->type (); 00238 00239 CORBA::Boolean equivalent = tc->equivalent (this->type_.in ()); 00240 00241 if (!equivalent) 00242 { 00243 return false; 00244 } 00245 00246 CORBA::Any_var any = rhs->to_any (); 00247 00248 TAO::Any_Impl *impl = any->impl (); 00249 CORBA::ULong value; 00250 00251 if (impl->encoded ()) 00252 { 00253 TAO::Unknown_IDL_Type * const unk = 00254 dynamic_cast<TAO::Unknown_IDL_Type *> (impl); 00255 00256 if (!unk) 00257 throw CORBA::INTERNAL (); 00258 00259 // We don't want unk's rd_ptr to move, in case we are shared by 00260 // another Any, so we use this to copy the state, not the buffer. 00261 TAO_InputCDR for_reading (unk->_tao_get_cdr ()); 00262 for_reading.read_ulong (value); 00263 } 00264 else 00265 { 00266 TAO_OutputCDR out; 00267 impl->marshal_value (out); 00268 TAO_InputCDR in (out); 00269 in.read_ulong (value); 00270 } 00271 00272 return value == this->value_; 00273 }
void TAO_DynEnum_i::from_any | ( | const CORBA::Any & | value | ) | [virtual] |
Definition at line 174 of file DynEnum_i.cpp.
References TAO_Pseudo_Var_T< T >::in(), ACE_InputCDR::read_ulong(), CORBA::tk_enum, and TAO_DynAnyFactory::unalias().
00175 { 00176 CORBA::TypeCode_var tc = any.type (); 00177 CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()); 00178 00179 if (kind == CORBA::tk_enum) 00180 { 00181 // Get the CDR stream of the Any, if there isn't one, make one. 00182 TAO::Any_Impl *impl = any.impl (); 00183 00184 if (impl->encoded ()) 00185 { 00186 TAO::Unknown_IDL_Type * const unk = 00187 dynamic_cast<TAO::Unknown_IDL_Type *> (impl); 00188 00189 if (!unk) 00190 throw CORBA::INTERNAL (); 00191 00192 // We don't want unk's rd_ptr to move, in case we are shared by 00193 // another Any, so we use this to copy the state, not the buffer. 00194 TAO_InputCDR for_reading (unk->_tao_get_cdr ()); 00195 for_reading.read_ulong (this->value_); 00196 } 00197 else 00198 { 00199 TAO_OutputCDR out; 00200 impl->marshal_value (out); 00201 TAO_InputCDR in (out); 00202 in.read_ulong (this->value_); 00203 } 00204 } 00205 else 00206 { 00207 throw DynamicAny::DynAny::TypeMismatch (); 00208 } 00209 }
char * TAO_DynEnum_i::get_as_string | ( | void | ) | [virtual] |
Definition at line 110 of file DynEnum_i.cpp.
References TAO_Pseudo_Var_T< T >::in(), CORBA::string_dup(), and TAO_DynAnyFactory::strip_alias().
00111 { 00112 CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); 00113 00114 const char *retval = ct.in ()->member_name (this->value_); 00115 00116 return CORBA::string_dup (retval); 00117 }
CORBA::ULong TAO_DynEnum_i::get_as_ulong | ( | void | ) | [virtual] |
Definition at line 150 of file DynEnum_i.cpp.
References value_.
00151 { 00152 return this->value_; 00153 }
void TAO_DynEnum_i::init | ( | const CORBA::Any & | any | ) |
Initialize using an Any.
Definition at line 39 of file DynEnum_i.cpp.
References TAO_Pseudo_Var_T< T >::in(), init_common(), ACE_InputCDR::read_ulong(), CORBA::tk_enum, TAO_DynCommon::type_, and TAO_DynAnyFactory::unalias().
00040 { 00041 CORBA::TypeCode_var tc = any.type (); 00042 CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()); 00043 00044 if (kind != CORBA::tk_enum) 00045 { 00046 throw DynamicAny::DynAnyFactory::InconsistentTypeCode (); 00047 } 00048 00049 this->type_ = tc; 00050 00051 TAO::Any_Impl *impl = any.impl (); 00052 00053 if (impl->encoded ()) 00054 { 00055 TAO::Unknown_IDL_Type * const unk = 00056 dynamic_cast<TAO::Unknown_IDL_Type *> (impl); 00057 00058 if (!unk) 00059 throw CORBA::INTERNAL (); 00060 00061 // We don't want unk's rd_ptr to move, in case we are shared by 00062 // another Any, so we use this to copy the state, not the buffer. 00063 TAO_InputCDR for_reading (unk->_tao_get_cdr ()); 00064 for_reading.read_ulong (this->value_); 00065 } 00066 else 00067 { 00068 TAO_OutputCDR out; 00069 impl->marshal_value (out); 00070 TAO_InputCDR in (out); 00071 in.read_ulong (this->value_); 00072 } 00073 00074 this->init_common (); 00075 }
void TAO_DynEnum_i::init | ( | CORBA::TypeCode_ptr | tc | ) |
Initialize using just a TypeCode.
Definition at line 78 of file DynEnum_i.cpp.
References init_common(), CORBA::tk_enum, TAO_DynCommon::type_, TAO_DynAnyFactory::unalias(), and value_.
00079 { 00080 CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc); 00081 00082 if (kind != CORBA::tk_enum) 00083 { 00084 throw DynamicAny::DynAnyFactory::InconsistentTypeCode (); 00085 } 00086 00087 this->type_ = CORBA::TypeCode::_duplicate (tc); 00088 00089 this->value_ = 0; 00090 00091 this->init_common (); 00092 }
void TAO_DynEnum_i::init_common | ( | void | ) | [private] |
Definition at line 28 of file DynEnum_i.cpp.
References TAO_DynCommon::component_count_, TAO_DynCommon::container_is_destroying_, TAO_DynCommon::current_position_, TAO_DynCommon::destroyed_, TAO_DynCommon::has_components_, and TAO_DynCommon::ref_to_component_.
Referenced by init().
00029 { 00030 this->ref_to_component_ = false; 00031 this->container_is_destroying_ = false; 00032 this->has_components_ = false; 00033 this->destroyed_ = false; 00034 this->current_position_ = -1; 00035 this->component_count_ = 0; 00036 }
TAO_DynEnum_i& TAO_DynEnum_i::operator= | ( | const TAO_DynEnum_i & | src | ) | [private] |
void TAO_DynEnum_i::set_as_string | ( | const char * | value | ) | [virtual] |
Definition at line 120 of file DynEnum_i.cpp.
References TAO_Pseudo_Var_T< T >::in(), ACE_OS::strcmp(), TAO_DynAnyFactory::strip_alias(), and value_.
00121 { 00122 CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); 00123 00124 CORBA::ULong count = ct.in ()->member_count (); 00125 00126 CORBA::ULong i; 00127 const char *temp = 0; 00128 00129 for (i = 0; i < count; ++i) 00130 { 00131 temp = ct.in ()->member_name (i); 00132 00133 if (!ACE_OS::strcmp (value_as_string, temp)) 00134 { 00135 break; 00136 } 00137 } 00138 00139 if (i < count) 00140 { 00141 this->value_ = i; 00142 } 00143 else 00144 { 00145 throw DynamicAny::DynAny::InvalidValue (); 00146 } 00147 }
void TAO_DynEnum_i::set_as_ulong | ( | CORBA::ULong | value | ) | [virtual] |
Definition at line 156 of file DynEnum_i.cpp.
References TAO_Pseudo_Var_T< T >::in(), TAO_DynAnyFactory::strip_alias(), and value_.
00157 { 00158 CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); 00159 CORBA::ULong const max = ct.in ()->member_count (); 00160 00161 if (value_as_ulong < max) 00162 { 00163 this->value_ = value_as_ulong; 00164 } 00165 else 00166 { 00167 throw DynamicAny::DynAny::InvalidValue (); 00168 } 00169 }
CORBA::Any_ptr TAO_DynEnum_i::to_any | ( | void | ) | [virtual] |
Definition at line 212 of file DynEnum_i.cpp.
References ACE_NEW_THROW_EX, and ACE_OutputCDR::write_ulong().
00213 { 00214 TAO_OutputCDR out_cdr; 00215 00216 out_cdr.write_ulong (this->value_); 00217 00218 CORBA::Any *retval; 00219 ACE_NEW_THROW_EX (retval, 00220 CORBA::Any, 00221 CORBA::NO_MEMORY ()); 00222 00223 TAO_InputCDR in_cdr (out_cdr); 00224 TAO::Unknown_IDL_Type *unk = 0; 00225 ACE_NEW_THROW_EX (unk, 00226 TAO::Unknown_IDL_Type (this->type_.in (), 00227 in_cdr), 00228 CORBA::NO_MEMORY ()); 00229 00230 retval->replace (unk); 00231 return retval; 00232 }
CORBA::ULong TAO_DynEnum_i::value_ [private] |
Current numeric value of the enum.
Definition at line 95 of file DynEnum_i.h.
Referenced by equal(), get_as_ulong(), init(), set_as_string(), and set_as_ulong().