#include <DynEnum_i.h>
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. |
Implementation of Dynamic Any type for enums
Definition at line 42 of file DynEnum_i.h.
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] |
is_local
member into CORBA::Object. I'll take the easier route for now. Reimplemented from CORBA::LocalObject.
Definition at line 97 of file DynEnum_i.cpp.
{ if (CORBA::is_nil (_tao_objref)) { return 0; } return dynamic_cast<TAO_DynEnum_i *> (_tao_objref); }
DynamicAny::DynAny_ptr TAO_DynEnum_i::current_component | ( | void | ) | [virtual] |
Definition at line 290 of file DynEnum_i.cpp.
{ if (this->destroyed_) { throw ::CORBA::OBJECT_NOT_EXIST (); } throw DynamicAny::DynAny::TypeMismatch (); }
void TAO_DynEnum_i::destroy | ( | void | ) | [virtual] |
Definition at line 276 of file DynEnum_i.cpp.
{ if (this->destroyed_) { throw ::CORBA::OBJECT_NOT_EXIST (); } if (!this->ref_to_component_ || this->container_is_destroying_) { this->destroyed_ = true; } }
CORBA::Boolean TAO_DynEnum_i::equal | ( | DynamicAny::DynAny_ptr | dyn_any | ) | [virtual] |
Definition at line 235 of file DynEnum_i.cpp.
{ CORBA::TypeCode_var tc = rhs->type (); CORBA::Boolean equivalent = tc->equivalent (this->type_.in ()); if (!equivalent) { return false; } CORBA::Any_var any = rhs->to_any (); TAO::Any_Impl *impl = any->impl (); CORBA::ULong value; if (impl->encoded ()) { TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); if (!unk) throw CORBA::INTERNAL (); // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); for_reading.read_ulong (value); } else { TAO_OutputCDR out; impl->marshal_value (out); TAO_InputCDR in (out); in.read_ulong (value); } return value == this->value_; }
void TAO_DynEnum_i::from_any | ( | const CORBA::Any & | value | ) | [virtual] |
Definition at line 174 of file DynEnum_i.cpp.
{ CORBA::TypeCode_var tc = any.type (); CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()); if (kind == CORBA::tk_enum) { // Get the CDR stream of the Any, if there isn't one, make one. TAO::Any_Impl *impl = any.impl (); if (impl->encoded ()) { TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); if (!unk) throw CORBA::INTERNAL (); // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); for_reading.read_ulong (this->value_); } else { TAO_OutputCDR out; impl->marshal_value (out); TAO_InputCDR in (out); in.read_ulong (this->value_); } } else { throw DynamicAny::DynAny::TypeMismatch (); } }
char * TAO_DynEnum_i::get_as_string | ( | void | ) | [virtual] |
Definition at line 110 of file DynEnum_i.cpp.
{ CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); const char *retval = ct.in ()->member_name (this->value_); return CORBA::string_dup (retval); }
CORBA::ULong TAO_DynEnum_i::get_as_ulong | ( | void | ) | [virtual] |
Definition at line 150 of file DynEnum_i.cpp.
{ return this->value_; }
void TAO_DynEnum_i::init | ( | const CORBA::Any & | any | ) |
Initialize using an Any.
Definition at line 39 of file DynEnum_i.cpp.
{ CORBA::TypeCode_var tc = any.type (); CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ()); if (kind != CORBA::tk_enum) { throw DynamicAny::DynAnyFactory::InconsistentTypeCode (); } this->type_ = tc; TAO::Any_Impl *impl = any.impl (); if (impl->encoded ()) { TAO::Unknown_IDL_Type * const unk = dynamic_cast<TAO::Unknown_IDL_Type *> (impl); if (!unk) throw CORBA::INTERNAL (); // We don't want unk's rd_ptr to move, in case we are shared by // another Any, so we use this to copy the state, not the buffer. TAO_InputCDR for_reading (unk->_tao_get_cdr ()); for_reading.read_ulong (this->value_); } else { TAO_OutputCDR out; impl->marshal_value (out); TAO_InputCDR in (out); in.read_ulong (this->value_); } this->init_common (); }
void TAO_DynEnum_i::init | ( | CORBA::TypeCode_ptr | tc | ) |
Initialize using just a TypeCode.
Definition at line 78 of file DynEnum_i.cpp.
{ CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc); if (kind != CORBA::tk_enum) { throw DynamicAny::DynAnyFactory::InconsistentTypeCode (); } this->type_ = CORBA::TypeCode::_duplicate (tc); this->value_ = 0; this->init_common (); }
void TAO_DynEnum_i::init_common | ( | void | ) | [private] |
Definition at line 28 of file DynEnum_i.cpp.
{ this->ref_to_component_ = false; this->container_is_destroying_ = false; this->has_components_ = false; this->destroyed_ = false; this->current_position_ = -1; this->component_count_ = 0; }
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.
{ CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); CORBA::ULong count = ct.in ()->member_count (); CORBA::ULong i; const char *temp = 0; for (i = 0; i < count; ++i) { temp = ct.in ()->member_name (i); if (!ACE_OS::strcmp (value_as_string, temp)) { break; } } if (i < count) { this->value_ = i; } else { throw DynamicAny::DynAny::InvalidValue (); } }
void TAO_DynEnum_i::set_as_ulong | ( | CORBA::ULong | value | ) | [virtual] |
Definition at line 156 of file DynEnum_i.cpp.
{ CORBA::TypeCode_var ct = TAO_DynAnyFactory::strip_alias (this->type_.in ()); CORBA::ULong const max = ct.in ()->member_count (); if (value_as_ulong < max) { this->value_ = value_as_ulong; } else { throw DynamicAny::DynAny::InvalidValue (); } }
CORBA::Any_ptr TAO_DynEnum_i::to_any | ( | void | ) | [virtual] |
Definition at line 212 of file DynEnum_i.cpp.
{ TAO_OutputCDR out_cdr; out_cdr.write_ulong (this->value_); CORBA::Any *retval; ACE_NEW_THROW_EX (retval, CORBA::Any, CORBA::NO_MEMORY ()); TAO_InputCDR in_cdr (out_cdr); TAO::Unknown_IDL_Type *unk = 0; ACE_NEW_THROW_EX (unk, TAO::Unknown_IDL_Type (this->type_.in (), in_cdr), CORBA::NO_MEMORY ()); retval->replace (unk); return retval; }
CORBA::ULong TAO_DynEnum_i::value_ [private] |
Current numeric value of the enum.
Definition at line 95 of file DynEnum_i.h.