TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType > Class Template Reference

Representation of an OMG IDL defined union case for unions with Enum discriminators. More...

#include <TypeCode_Case_Enum_T.h>

Inheritance diagram for TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >:

Inheritance graph
[legend]
Collaboration diagram for TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Case_Enum_T (CORBA::TypeCode_ptr discriminator_tc, CORBA::ULong member_label, char const *member_name, TypeCodeType member_type)
 Constructor.

 Case_Enum_T (CORBA::TypeCode_ptr discriminator_tc, CORBA::ULong member_label)
 Constructor.

@c TAO::TypeCode::Case Methods
Methods required by the TAO::TypeCode::Case abstract base class.

See also:
TAO::TypeCode::Case


Case< StringType, TypeCodeType > * clone (void) const
 Cloning/copying operation.

virtual CORBA::Anylabel (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

::CORBA::ULong const  label_
 IDL union case/member label value.

CORBA::TypeCode_var discriminator_tc_
 IDL union discriminator typecode.


Detailed Description

template<typename StringType, typename TypeCodeType>
class TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >

Representation of an OMG IDL defined union case for unions with Enum discriminators.

When dynamically creating a union type with a enum discriminator, there is not way that the template parameter DiscriminatorType can be specified at runtime.

Since enums are encoded as ULongs, DiscriminatorType has been replaced with CORBA::ULong.

Definition at line 49 of file TypeCode_Case_Enum_T.h.


Constructor & Destructor Documentation

template<typename StringType, typename TypeCodeType>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >::Case_Enum_T CORBA::TypeCode_ptr  discriminator_tc,
CORBA::ULong  member_label,
char const *  member_name,
TypeCodeType  member_type
 

Constructor.

Definition at line 12 of file TypeCode_Case_Enum_T.inl.

00016   : Case<StringType, TypeCodeType> (member_name, member_type)
00017   , label_ (member_label)
00018   , discriminator_tc_( CORBA::TypeCode::_duplicate (discriminator_tc) )
00019 {
00020 }

template<typename StringType, typename TypeCodeType>
ACE_INLINE TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >::Case_Enum_T CORBA::TypeCode_ptr  discriminator_tc,
CORBA::ULong  member_label
 

Constructor.

Constructor only used in the dynamically constructed union TypeCode case.

Definition at line 26 of file TypeCode_Case_Enum_T.inl.

00028   : Case<StringType, TypeCodeType> ()
00029   , label_ (member_label)
00030   , discriminator_tc_( CORBA::TypeCode::_duplicate (discriminator_tc) )
00031 {
00032 }


Member Function Documentation

template<typename StringType, typename TypeCodeType>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::TypeCode::Case< StringType, TypeCodeType > * TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >::clone void   )  const [virtual]
 

Cloning/copying operation.

Implements TAO::TypeCode::Case< StringType, TypeCodeType >.

Definition at line 25 of file TypeCode_Case_Enum_T.cpp.

References ACE_NEW_RETURN.

00026 {
00027   Case<StringType, TypeCodeType> * p = 0;
00028 
00029   typedef Case_Enum_T<StringType,
00030                       TypeCodeType> case_type;
00031 
00032   // The compiler generated memberwise copy constructor is sufficient.
00033   ACE_NEW_RETURN (p,
00034                   case_type (*this),
00035                   p);
00036 
00037   return p;
00038 }

template<typename StringType, typename TypeCodeType>
bool TAO::TypeCode::Case_Enum_T< 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.

Parameters:
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 54 of file TypeCode_Case_Enum_T.cpp.

References ACE_UINT32_MAX, and ACE_InputCDR::read_ulong().

00057 {
00058   CORBA::Any_var any = tc->member_label (index);
00059   TAO_OutputCDR out_cdr;
00060   
00061   if (! any->impl ()->marshal_value (out_cdr))
00062     {
00063       return false;
00064     }
00065   
00066   TAO_InputCDR in_cdr (out_cdr);
00067   CORBA::ULong tc_label = ACE_UINT32_MAX;
00068   
00069   if (! in_cdr.read_ulong (tc_label))
00070     {
00071       return false;
00072     }
00073   
00074   return (this->label_ == tc_label);
00075 }

template<typename StringType, typename TypeCodeType>
CORBA::Any * TAO::TypeCode::Case_Enum_T< 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 81 of file TypeCode_Case_Enum_T.cpp.

References CORBA::Any_var::_retn(), ACE_NEW_THROW_EX, CORBA::Any::replace(), and ACE_OutputCDR::write_ulong().

00082 {
00083     TAO_OutputCDR out_cdr;
00084 
00085     out_cdr.write_ulong (this->label_);
00086 
00087     CORBA::Any *retval = 0;
00088     ACE_NEW_THROW_EX (retval,
00089                         CORBA::Any,
00090                         CORBA::NO_MEMORY ());
00091 
00092     TAO_InputCDR in_cdr (out_cdr);
00093     TAO::Unknown_IDL_Type *unk = 0;
00094     ACE_NEW_THROW_EX (unk,
00095                       TAO::Unknown_IDL_Type (this->discriminator_tc_.in (),
00096                                              in_cdr),
00097                       CORBA::NO_MEMORY ());
00098 
00099     CORBA::Any_var safe_value (retval);
00100 
00101     retval->replace (unk);
00102 
00103     return safe_value._retn ();
00104 }

template<typename StringType, typename TypeCodeType>
bool TAO::TypeCode::Case_Enum_T< 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 44 of file TypeCode_Case_Enum_T.cpp.

00045 {
00046   return
00047     (cdr << this->label_);
00048 }


Member Data Documentation

template<typename StringType, typename TypeCodeType>
CORBA::TypeCode_var TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >::discriminator_tc_ [private]
 

IDL union discriminator typecode.

Definition at line 90 of file TypeCode_Case_Enum_T.h.

template<typename StringType, typename TypeCodeType>
::CORBA::ULong const TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >::label_ [private]
 

IDL union case/member label value.

Definition at line 87 of file TypeCode_Case_Enum_T.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:22:14 2008 for TAO_AnyTypeCode by doxygen 1.3.6