Public Member Functions | Protected Member Functions | Private Attributes

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

Abstract base class for that represents an IDL union case/member. More...

#include <TypeCode_Case_Base_T.h>

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

List of all members.

Public Member Functions

 Case (char const *name, TypeCodeType tc)
 Constructor.
 Case (void)
 Constructor.
virtual ~Case (void)
 Destructor.
virtual Caseclone (void) const =0
 Cloning/copying operation.
virtual CORBA::Anylabel (void) const =0
char const * name (void) const
 Get the name of the union case/member.
void name (char const *the_name)
 Set the name of the union case/member.
CORBA::TypeCode_ptr type (void) const
 Get the CORBA::TypeCode of the union case/member.
void type (CORBA::TypeCode_ptr tc)
 Set the CORBA::TypeCode of the union case/member.
bool marshal (TAO_OutputCDR &cdr, CORBA::ULong offset) const
bool equal (CORBA::ULong index, CORBA::TypeCode_ptr tc) const
bool equivalent (CORBA::ULong index, CORBA::TypeCode_ptr tc) const

Protected Member Functions

virtual bool marshal_label (TAO_OutputCDR &cdr) const =0
virtual bool equal_label (CORBA::ULong index, CORBA::TypeCode_ptr tc) const =0
 Verify equality of member labels.

Private Attributes

StringType name_
 The name of the case.
TypeCodeType type_
 Pointer to the CORBA::TypeCode of the case.

Detailed Description

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

Abstract base class for that represents an IDL union case/member.

This class hides the actual IDL union member label value from the TAO::TypeCode::Union class by relying on a CORBA::Any return value that corresponds to the CORBA::TypeCode::member_label() return type. It also allows the TAO::TypeCode::Union class to marshal the member label values into a CDR stream without knowledge of the underlying member label values.

Definition at line 51 of file TypeCode_Case_Base_T.h.


Constructor & Destructor Documentation

template<typename StringType , typename TypeCodeType >
TAO::TypeCode::Case< StringType, TypeCodeType >::Case ( char const *  name,
TypeCodeType  tc 
)

Constructor.

Constructor used when creating static union TypeCodes.

Definition at line 12 of file TypeCode_Case_Base_T.inl.

  : name_ (member_name)
  , type_ (member_type)
{
}

template<typename StringType , typename TypeCodeType >
TAO::TypeCode::Case< StringType, TypeCodeType >::Case ( void   ) 

Constructor.

Constructor used when creating dynamic union TypeCodes.

Definition at line 22 of file TypeCode_Case_Base_T.inl.

  : name_ ()
  , type_ ()
{
  // Only used when StringType and TypeCodeType are CORBA::String_var
  // and CORBA::TypeCode_var, respectively.
}

template<typename StringType , typename TypeCodeType >
TAO::TypeCode::Case< StringType, TypeCodeType >::~Case ( void   )  [virtual]

Destructor.

Definition at line 16 of file TypeCode_Case_Base_T.cpp.

{
}


Member Function Documentation

template<typename StringType, typename TypeCodeType>
virtual Case* TAO::TypeCode::Case< StringType, TypeCodeType >::clone ( void   )  const [pure virtual]
template<typename StringType , typename TypeCodeType >
bool TAO::TypeCode::Case< StringType, TypeCodeType >::equal ( CORBA::ULong  index,
CORBA::TypeCode_ptr  tc 
) const

Check for equality of the case attributes contained by this class and the corresponding member attributes at index "@a index" in the given TypeCode tc.

Definition at line 22 of file TypeCode_Case_Base_T.cpp.

{
  // Check case names.
  char const * const lhs_name = this->name ();
  char const * const rhs_name = tc->member_name (index
                                                );

  if (ACE_OS::strcmp (lhs_name, rhs_name) != 0)
    return false;

  // Check case TypeCodes.
  CORBA::TypeCode_ptr const lhs_tc = this->type ();
  CORBA::TypeCode_var const rhs_tc =
    tc->member_type (index
                    );

  CORBA::Boolean const equal_members =
    lhs_tc->equal (rhs_tc.in ()
                  );

  if (!equal_members)
    return false;

  // Check case label.
  return this->equal_label (index,
                            tc
                           );
}

template<typename StringType, typename TypeCodeType>
virtual bool TAO::TypeCode::Case< StringType, TypeCodeType >::equal_label ( CORBA::ULong  index,
CORBA::TypeCode_ptr  tc 
) const [protected, pure 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.

Implemented in TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >, and TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >.

template<typename StringType , typename TypeCodeType >
bool TAO::TypeCode::Case< StringType, TypeCodeType >::equivalent ( CORBA::ULong  index,
CORBA::TypeCode_ptr  tc 
) const

Check for equivalence of the case attributes contained by this class and the corresponding member attributes at index "@a index" in the given TypeCode tc.

Definition at line 55 of file TypeCode_Case_Base_T.cpp.

{
  // Member names are ignore when determining equivalence.

  // Check case TypeCodes.
  CORBA::TypeCode_ptr const lhs_tc = this->type ();
  CORBA::TypeCode_var const rhs_tc =
    tc->member_type (index
                    );

  CORBA::Boolean const equivalent_members =
    lhs_tc->equivalent (rhs_tc.in ()
                       );

  if (!equivalent_members)
    return 0;

  // Check case label.
  // The label must be equal when determining equivalence, too.
  return this->equal_label (index,
                            tc
                           );
}

template<typename StringType, typename TypeCodeType>
virtual CORBA::Any* TAO::TypeCode::Case< StringType, TypeCodeType >::label ( void   )  const [pure virtual]
template<typename StringType , typename TypeCodeType >
bool TAO::TypeCode::Case< StringType, TypeCodeType >::marshal ( TAO_OutputCDR cdr,
CORBA::ULong  offset 
) const

Marshal this IDL union member into the given output CDR stream.

Definition at line 32 of file TypeCode_Case_Base_T.inl.

{
  return
    this->marshal_label (cdr)
    && (cdr << TAO_OutputCDR::from_string (
         Traits<StringType>::get_string (this->name_), 0))
    && TAO::TypeCode::marshal (cdr,
                               Traits<StringType>::get_typecode (this->type_),
                               offset + cdr.total_length ());
}

template<typename StringType, typename TypeCodeType>
virtual bool TAO::TypeCode::Case< StringType, TypeCodeType >::marshal_label ( TAO_OutputCDR cdr  )  const [protected, pure virtual]

Marshal the IDL union case label value into the given output CDR stream.

Implemented in TAO::TypeCode::Case_Enum_T< StringType, TypeCodeType >, and TAO::TypeCode::Case_T< DiscriminatorType, StringType, TypeCodeType >.

template<typename StringType , typename TypeCodeType >
void TAO::TypeCode::Case< StringType, TypeCodeType >::name ( char const *  the_name  ) 

Set the name of the union case/member.

Definition at line 55 of file TypeCode_Case_Base_T.inl.

{
  this->name_ = the_name;
}

template<typename StringType , typename TypeCodeType >
char const * TAO::TypeCode::Case< StringType, TypeCodeType >::name ( void   )  const

Get the name of the union case/member.

Definition at line 47 of file TypeCode_Case_Base_T.inl.

{
  return
    Traits<StringType>::get_string (this->name_);
}

template<typename StringType , typename TypeCodeType >
void TAO::TypeCode::Case< StringType, TypeCodeType >::type ( CORBA::TypeCode_ptr  tc  ) 

Set the CORBA::TypeCode of the union case/member.

Note:
CORBA::TypeCode::_duplicate() is called on the TypeCode tc.

Definition at line 71 of file TypeCode_Case_Base_T.inl.

{
  // This assignment works since it is only used when TypeCodeType is
  // "CORBA::TypeCode_var", not in the "CORBA::TypeCode_ptr const *"
  // case.
  this->type_ = CORBA::TypeCode::_duplicate (tc);
}

template<typename StringType , typename TypeCodeType >
CORBA::TypeCode_ptr TAO::TypeCode::Case< StringType, TypeCodeType >::type ( void   )  const

Get the CORBA::TypeCode of the union case/member.

Note:
The reference count is not manipulated by this method, i.e., ownership is retained by this class.

Definition at line 63 of file TypeCode_Case_Base_T.inl.

{
  return
    Traits<StringType>::get_typecode (this->type_);
}


Member Data Documentation

template<typename StringType, typename TypeCodeType>
StringType TAO::TypeCode::Case< StringType, TypeCodeType >::name_ [private]

The name of the case.

Definition at line 137 of file TypeCode_Case_Base_T.h.

template<typename StringType, typename TypeCodeType>
TypeCodeType TAO::TypeCode::Case< StringType, TypeCodeType >::type_ [private]

Pointer to the CORBA::TypeCode of the case.

A pointer to the CORBA::TypeCode_ptr rather than the CORBA::TypeCode_ptr itself is stored since that address is well-defined. We may not know the value of the CORBA::TypeCode_ptr when creating this Case statically at compile-time, hence the indirection.

Note:
This TypeCode is released upon destruction of this Case.

Definition at line 150 of file TypeCode_Case_Base_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines