Classes | Public Member Functions | Private Attributes

TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType > Class Template Reference

Recursive type TypeCode decorator template. More...

#include <Recursive_Type_TypeCode.h>

List of all members.

Classes

class  Reset

Public Member Functions

 Recursive_Type (CORBA::TCKind kind, char const *id, char const *name, MemberArrayType const &fields, CORBA::ULong nfields)
 Recursive struct constructor.
 Recursive_Type (char const *id, char const *name, TypeCodeType const &discriminant_type, MemberArrayType const &cases, CORBA::ULong ncases, CORBA::Long default_index)
 Recursive union constructor.
 Recursive_Type (CORBA::TCKind kind, char const *id, char const *name, CORBA::ValueModifier modifier, TypeCodeType const &concrete_base, MemberArrayType const &fields, CORBA::ULong nfields)
 Recursive valuetype constructor.
 Recursive_Type (CORBA::TCKind kind, char const *id)
 Dynamic Recursive_Type TypeCode constructor.
bool struct_parameters (char const *name, MemberArrayType const &fields, CORBA::ULong nfields)
 Set struct TypeCode parameters.
bool union_parameters (char const *name, TypeCodeType const &discriminant_type, MemberArrayType const &cases, CORBA::ULong ncases, CORBA::Long default_index)
 Set union TypeCode parameters.
bool valuetype_parameters (char const *name, CORBA::ValueModifier modifier, TypeCodeType const &concrete_base, MemberArrayType const &fields, CORBA::ULong nfields)
 Set valuetype or eventtype TypeCode parameters.
TAO-specific @c CORBA::TypeCode Methods

Methods required by TAO's implementation of the CORBA::TypeCode class.

These are recursive type TypeCode marshaling operation overrides.

See also:
CORBA::TypeCode
virtual bool tao_marshal_kind (TAO_OutputCDR &cdr) const
virtual bool tao_marshal (TAO_OutputCDR &cdr, CORBA::ULong offset) const

Protected Member Functions

TAO @c CORBA::TypeCode Template Methods

Recursive type CORBA::TypeCode -specific template methods.

See also:
CORBA::TypeCode
virtual CORBA::Boolean equal_i (CORBA::TypeCode_ptr tc) const
virtual CORBA::Boolean equivalent_i (CORBA::TypeCode_ptr tc) const

Private Attributes

TAO_SYNCH_RECURSIVE_MUTEX lock_
 Internal state thread synchronization mutex.
bool in_recursion_
bool data_initialized_
 Track whether data has been initialized.

Detailed Description

template<class TypeCodeBase, typename TypeCodeType, typename MemberArrayType>
class TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >

Recursive type TypeCode decorator template.

This class template decorates the underlying TypeCode implementation TypeCodeBase to provide support for IDL defined recursive types. Only IDL an struct, union or valuetype may be recursive, which is why this decorator only supports constructors for the corresponding TypeCode implementations.

Definition at line 48 of file Recursive_Type_TypeCode.h.


Constructor & Destructor Documentation

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::Recursive_Type ( CORBA::TCKind  kind,
char const *  id,
char const *  name,
MemberArrayType const &  fields,
CORBA::ULong  nfields 
)

Recursive struct constructor.

Definition at line 11 of file Recursive_Type_TypeCode.inl.

  : TypeCodeBase (kind, id, name, fields, nfields)
  , lock_ ()
  , in_recursion_ (false)
  , data_initialized_(true)
{
  // ACE_ASSERT (kind != CORBA::tk_except);
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::Recursive_Type ( char const *  id,
char const *  name,
TypeCodeType const &  discriminant_type,
MemberArrayType const &  cases,
CORBA::ULong  ncases,
CORBA::Long  default_index 
)

Recursive union constructor.

Definition at line 29 of file Recursive_Type_TypeCode.inl.

  : TypeCodeBase (id,
                  name,
                  discriminant_type,
                  cases,
                  ncases,
                  default_index)
  , lock_ ()
  , in_recursion_ (false)
  , data_initialized_(true)
{
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::Recursive_Type ( CORBA::TCKind  kind,
char const *  id,
char const *  name,
CORBA::ValueModifier  modifier,
TypeCodeType const &  concrete_base,
MemberArrayType const &  fields,
CORBA::ULong  nfields 
)

Recursive valuetype constructor.

Definition at line 52 of file Recursive_Type_TypeCode.inl.

  : TypeCodeBase (kind,
                  id,
                  name,
                  modifier,
                  concrete_base,
                  fields,
                  nfields)
  , lock_ ()
  , in_recursion_ (false)
  , data_initialized_(true)
{
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::Recursive_Type ( CORBA::TCKind  kind,
char const *  id 
)

Dynamic Recursive_Type TypeCode constructor.

Definition at line 77 of file Recursive_Type_TypeCode.inl.

  : TypeCodeBase (kind, id)
  , lock_ ()
  , in_recursion_ (false)
  , data_initialized_(false)
{
//   ACE_ASSERT (kind == CORBA::tk_struct
//               || kind == CORBA::tk_union
//               || kind == CORBA::tk_value
//               || kind == CORBA::tk_event);
}


Member Function Documentation

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
CORBA::Boolean TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::equal_i ( CORBA::TypeCode_ptr  tc  )  const [protected, virtual]

Definition at line 59 of file Recursive_Type_TypeCode.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
                    guard,
                    this->lock_,
                    false);

  // Top-level TypeCode case.
  if (!(this->in_recursion_))
    {
      this->in_recursion_ = true;

      // Reset recursion flag to false in an exception-safe manner once
      // equality determination is done.
      //
      // Only reset the recursion flag at the top-level.
      Reset flag (this->in_recursion_);

      return this->TypeCodeBase::equal_i (tc);
    }

  // Nothing else to do.
  return true;
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
CORBA::Boolean TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::equivalent_i ( CORBA::TypeCode_ptr  tc  )  const [protected, virtual]

Definition at line 89 of file Recursive_Type_TypeCode.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
                    guard,
                    this->lock_,
                    false);

  // Top-level TypeCode case.
  if (!(this->in_recursion_))
    {
      this->in_recursion_ = true;

      // Reset recursion flag to false in an exception-safe manner once
      // equivalence determination is done.
      //
      // Only reset the recursion flag at the top-level.
      Reset flag (this->in_recursion_);

      return this->TypeCodeBase::equivalent_i (tc);
    }

  // Nothing else to do.
  return true;
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
bool TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::struct_parameters ( char const *  name,
MemberArrayType const &  fields,
CORBA::ULong  nfields 
)

Set struct TypeCode parameters.

Definition at line 95 of file Recursive_Type_TypeCode.inl.

{
  // Do not replace pre-existing fields!
  if ( !this->data_initialized_ )
    {
      this->base_attributes_.name (name);
      this->fields_  = fields;
      this->nfields_ = nfields;
      this->data_initialized_ = true;

      return true;
    }

  return false;
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
bool TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::tao_marshal ( TAO_OutputCDR cdr,
CORBA::ULong  offset 
) const [virtual]

Definition at line 15 of file Recursive_Type_TypeCode.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
                    guard,
                    this->lock_,
                    false);

  // Top-level TypeCode case.
  if (!(this->in_recursion_))
    {
      this->in_recursion_ = true;

      // Starting offset should point to the CORBA::TCKind value.

      // Note that this doesn't need to take into account alignment
      // padding since CORBA::TCKind (encoded as a CORBA::ULong) is
      // already aligned on the appropriate boundary, and since the
      // CORBA::TCKind was the last thing marshaled into the CDR
      // stream before getting here.
      offset = sizeof (CORBA::ULong);

      // Reset recursion flag to false in an exception-safe manner once
      // marshaling is done.
      //
      // Only reset the recursion flag at the top-level.
      Reset flag (this->in_recursion_);

      return this->TypeCodeBase::tao_marshal (cdr, offset);
    }

  // Recursive/indirected TypeCode case.

//   ACE_ASSERT (offset > 4
//               && offset < static_cast<CORBA::ULong> (ACE_INT32_MAX));

  return (cdr << -static_cast<CORBA::Long> (offset));
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
bool TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::tao_marshal_kind ( TAO_OutputCDR cdr  )  const [virtual]

Definition at line 119 of file Recursive_Type_TypeCode.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
                    guard,
                    this->lock_,
                    false);

  // Top-level TypeCode case.
  if (!(this->in_recursion_))
    return this->::CORBA::TypeCode::tao_marshal_kind (cdr);

  // Recursive/indirected TypeCode case.
  CORBA::ULong const indirection_kind = 0xffffffff;

  return (cdr << indirection_kind);
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
bool TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::union_parameters ( char const *  name,
TypeCodeType const &  discriminant_type,
MemberArrayType const &  cases,
CORBA::ULong  ncases,
CORBA::Long  default_index 
)

Set union TypeCode parameters.

Definition at line 118 of file Recursive_Type_TypeCode.inl.

{
  if ( !this->data_initialized_ )
    {
      this->base_attributes_.name (name);
      this->discriminant_type_ = discriminant_type;
      this->cases_             = cases;
      this->ncases_            = ncases;
      this->default_index_     = default_index;
      this->data_initialized_ = true;

      return true;
    }

  return false;
}

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
bool TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::valuetype_parameters ( char const *  name,
CORBA::ValueModifier  modifier,
TypeCodeType const &  concrete_base,
MemberArrayType const &  fields,
CORBA::ULong  nfields 
)

Set valuetype or eventtype TypeCode parameters.

Definition at line 144 of file Recursive_Type_TypeCode.inl.

{
  if ( !this->data_initialized_ )
    {
      this->base_attributes_.name (name);
      this->type_modifier_ = modifier;
      this->concrete_base_ = concrete_base;
      this->fields_        = fields;
      this->nfields_       = nfields;
      this->data_initialized_ = true;

      return true;
    }

  return false;
}


Member Data Documentation

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
bool TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::data_initialized_ [private]

Track whether data has been initialized.

Definition at line 169 of file Recursive_Type_TypeCode.h.

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
bool TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::in_recursion_ [mutable, private]

true if equality or equivalence is being determined recursively. This flag is used to prevent TypeCode equality and equivalence operations from recursing indefinitely.

Definition at line 166 of file Recursive_Type_TypeCode.h.

template<class TypeCodeBase , typename TypeCodeType , typename MemberArrayType >
TAO_SYNCH_RECURSIVE_MUTEX TAO::TypeCode::Recursive_Type< TypeCodeBase, TypeCodeType, MemberArrayType >::lock_ [mutable, private]

Internal state thread synchronization mutex.

Definition at line 158 of file Recursive_Type_TypeCode.h.


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