union
case
.
More...
#include <TypeCode_Case_T.h>
Inheritance diagram for TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >:
Public Member Functions | |
Case_T (DiscriminatorType member_label, char const *member_name, TypeCodeType member_type) | |
Constructor. | |
Case_T (DiscriminatorType member_label) | |
Constructor. | |
@c TAO::TypeCode::Case Methods | |
Case< StringType, TypeCodeType > * | clone (void) const |
Cloning/copying operation. | |
virtual CORBA::Any * | label (void) const |
virtual bool | marshal_label (TAO_OutputCDR &cdr) const |
virtual bool | equal_label (CORBA::ULong index, CORBA::TypeCode_ptr tc) const |
Verify equality of member labels. | |
Private Attributes | |
DiscriminatorType const | label_ |
IDL union case/member label value. |
union
case
.
A Case_T
contains the corresponding case label value, name and pointer to the CORBA::TypeCode
for a given OMG IDL union
case
. For example, the cases in following OMG IDL union:
union Foo switch (short) { case 0: case 1: short a; case 2: long b; default: octet c; };
would be represented using the following statically instantiated TAO::TypeCode::Case_T
array:
typedef TAO::TypeCode::Case_T<CORBA::Short, char const *> Foo_Case; Foo_Case _tao_cases_Foo[] = { Foo_Case (0, "a", &CORBA::_tc_short), Foo_Case (1, "a", &CORBA::_tc_short), Foo_Case (2, "b", &CORBA::_tc_long), Foo_Case (0, "c", &CORBA::_tc_octet) };
The default
index is passed directly to the TAO::TypeCode::Union
constructor.
The template parameter DISCRIMINATOR_TYPE is the corresponding C++ type for the IDL defined union
discriminator type. For example, a union
with an IDL short
discriminator will have a corresponding CORBA::Short
C++ type. This template parameter is necessary to allow the actual case
label value to be stored as its actual type, which is particularly important when marshaling that value into a CDR stream.
The template parameter StringType is either char
const
*
or CORBA::String_var
. The latter is only used when creating CORBA::tk_union
TypeCode
dynamically, such as through the TypeCodeFactory.
Definition at line 88 of file TypeCode_Case_T.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >::Case_T | ( | DiscriminatorType | member_label, | |
char const * | member_name, | |||
TypeCodeType | member_type | |||
) |
Constructor.
Definition at line 14 of file TypeCode_Case_T.inl.
00017 : Case<StringType, TypeCodeType> (member_name, member_type) 00018 , label_ (member_label) 00019 { 00020 }
ACE_INLINE TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >::Case_T | ( | DiscriminatorType | member_label | ) |
Constructor.
Constructor only used in the dynamically constructed union
TypeCode
case.
Definition at line 28 of file TypeCode_Case_T.inl.
00029 : Case<StringType, TypeCodeType> () 00030 , label_ (member_label) 00031 { 00032 }
TAO::TypeCode::Case< StringType, TypeCodeType > * TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >::clone | ( | void | ) | const [virtual] |
Cloning/copying operation.
Implements TAO::TypeCode::Case< StringType, TypeCodeType >.
Definition at line 81 of file TypeCode_Case_T.cpp.
References ACE_NEW_RETURN.
00082 { 00083 Case<StringType, TypeCodeType> * p = 0; 00084 00085 typedef Case_T<DiscriminatorType, 00086 StringType, 00087 TypeCodeType> case_type; 00088 00089 // The compiler generated memberwise copy constructor is sufficient. 00090 ACE_NEW_RETURN (p, 00091 case_type (*this), 00092 p); 00093 00094 return p; 00095 }
bool TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >::equal_label | ( | CORBA::ULong | index, | |
CORBA::TypeCode_ptr | tc | |||
) | const [virtual] |
Verify equality of member labels.
Performing member label equality comparisons in the Case
subclass allows us to avoid performing interpretive extraction of the value from the Any
returned from the "right hand side" operand TypeCode
since the Case
subclass already knows what type and value should be extracted from the Any
.
index | Member index of given TypeCode tc being tested. | |
tc | The TypeCode whose member "@a index" label is being tested. |
Implements TAO::TypeCode::Case< StringType, TypeCodeType >.
Definition at line 116 of file TypeCode_Case_T.cpp.
References TAO::TypeCode::Case_Traits< T >::any_to().
00119 { 00120 CORBA::Any_var const any = tc->member_label (index); 00121 00122 // The equality operator == below is guaranteed to be defined for 00123 // the discriminator type since an IDL union discriminator type must 00124 // be any of the following: (1) an integer, (2) a character, (3) a 00125 // boolean, or (4) an enumeration. 00126 00127 DiscriminatorType tc_label; 00128 if ((any.in () 00129 >>= TAO::TypeCode::Case_Traits<DiscriminatorType>::any_to (tc_label)) 00130 && this->label_ == tc_label) 00131 { 00132 return true; 00133 } 00134 00135 return false; 00136 }
CORBA::Any * TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >::label | ( | void | ) | const [virtual] |
Return the IDL union
case label value embedded within a CORBA::Any
.
Implements TAO::TypeCode::Case< StringType, TypeCodeType >.
Definition at line 144 of file TypeCode_Case_T.cpp.
References ACE_NEW_THROW_EX, and TAO::TypeCode::Case_Traits< T >::any_from().
00145 { 00146 CORBA::Any * value = 0; 00147 00148 ACE_NEW_THROW_EX (value, 00149 CORBA::Any, 00150 CORBA::NO_MEMORY ()); 00151 00152 CORBA::Any_var safe_value (value); 00153 00154 *value <<= 00155 TAO::TypeCode::Case_Traits<DiscriminatorType>::any_from (this->label_); 00156 00157 return safe_value._retn (); 00158 }
bool TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >::marshal_label | ( | TAO_OutputCDR & | cdr | ) | const [virtual] |
Marshal the IDL union
case
label value into the given output CDR stream.
Implements TAO::TypeCode::Case< StringType, TypeCodeType >.
Definition at line 103 of file TypeCode_Case_T.cpp.
00104 { 00105 return 00106 (cdr << 00107 TAO::TypeCode::Case_Traits<DiscriminatorType>::any_from (this->label_)); 00108 }
DiscriminatorType const TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >::label_ [private] |