Public Member Functions | Static Public Member Functions | Private Attributes

TAO::Any_Basic_Impl_T< T > Class Template Reference

Template Any class for basic types. More...

#include <Any_Basic_Impl_T.h>

Inheritance diagram for TAO::Any_Basic_Impl_T< T >:
Inheritance graph
[legend]
Collaboration diagram for TAO::Any_Basic_Impl_T< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Any_Basic_Impl_T (CORBA::TypeCode_ptr, const T &val)
virtual ~Any_Basic_Impl_T (void)
virtual CORBA::Boolean marshal_value (TAO_OutputCDR &)
CORBA::Boolean demarshal_value (TAO_InputCDR &)
virtual void _tao_decode (TAO_InputCDR &)
virtual const void * value (void) const

Static Public Member Functions

static void insert (CORBA::Any &, CORBA::TypeCode_ptr, const T &)
static CORBA::Boolean extract (const CORBA::Any &, CORBA::TypeCode_ptr, T &)
static Any_Basic_Impl_T< T > * create_empty (CORBA::TypeCode_ptr)

Private Attributes

value_

Detailed Description

template<typename T>
class TAO::Any_Basic_Impl_T< T >

Template Any class for basic types.

Used for all basic IDL types except bounded (w)strings.

Definition at line 37 of file Any_Basic_Impl_T.h.


Constructor & Destructor Documentation

template<typename T >
TAO::Any_Basic_Impl_T< T >::Any_Basic_Impl_T ( CORBA::TypeCode_ptr  tc,
const T &  val 
)

Definition at line 23 of file Any_Basic_Impl_T.cpp.

  : Any_Impl (0,
              tc),
    value_ (val)
{
}

template<typename T >
TAO::Any_Basic_Impl_T< T >::~Any_Basic_Impl_T ( void   )  [virtual]

Definition at line 32 of file Any_Basic_Impl_T.cpp.

{
}


Member Function Documentation

template<typename T >
void TAO::Any_Basic_Impl_T< T >::_tao_decode ( TAO_InputCDR cdr  )  [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 145 of file Any_Basic_Impl_T.cpp.

{
  if (! this->demarshal_value (cdr))
    {
      throw ::CORBA::MARSHAL ();
    }
}

template<typename T >
TAO::Any_Basic_Impl_T< T > * TAO::Any_Basic_Impl_T< T >::create_empty ( CORBA::TypeCode_ptr  tc  )  [static]

Definition at line 133 of file Any_Basic_Impl_T.cpp.

{
  TAO::Any_Basic_Impl_T<T> * retval = 0;
  ACE_NEW_RETURN (retval,
                  TAO::Any_Basic_Impl_T<T> (tc,
                                            static_cast<T> (0)),
                  0);
  return retval;
}

template<typename T >
CORBA::Boolean TAO::Any_Basic_Impl_T< T >::demarshal_value ( TAO_InputCDR cdr  ) 

Definition at line 10 of file Any_Basic_Impl_T.inl.

{
  return (cdr >> this->value_);
}

template<typename T >
CORBA::Boolean TAO::Any_Basic_Impl_T< T >::extract ( const CORBA::Any any,
CORBA::TypeCode_ptr  tc,
T &  _tao_elem 
) [static]

Definition at line 51 of file Any_Basic_Impl_T.cpp.

{
  try
    {
      CORBA::TypeCode_ptr any_tc = any._tao_get_typecode ();
      CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc);
      if (_tao_equiv == false)
        {
          return false;
        }

      TAO::Any_Impl * const impl = any.impl ();

      if (impl && !impl->encoded ())
        {
          TAO::Any_Basic_Impl_T<T> * const narrow_impl =
            dynamic_cast<TAO::Any_Basic_Impl_T<T> *> (impl);

          if (narrow_impl == 0)
            {
              return false;
            }

          _tao_elem = narrow_impl->value_;
          return true;
        }

      TAO::Any_Basic_Impl_T<T> * const replacement =
        TAO::Any_Basic_Impl_T<T>::create_empty (any_tc);

      auto_ptr<TAO::Any_Basic_Impl_T<T> > replacement_safety (replacement);

      // We know this will work since the unencoded case is covered above.
      TAO::Unknown_IDL_Type * const unk =
        dynamic_cast<TAO::Unknown_IDL_Type *> (impl);

      if (!unk)
        return false;

      // We don't want the rd_ptr of unk to move, in case it is
      // shared by another Any. This copies the state, not the buffer.
      TAO_InputCDR for_reading (unk->_tao_get_cdr ());

      CORBA::Boolean const good_decode =
        replacement->demarshal_value (for_reading);

      if (good_decode)
        {
          _tao_elem = replacement->value_;
          const_cast<CORBA::Any &> (any).replace (replacement);
          replacement_safety.release ();
          return true;
        }

      // Duplicated by Any_Impl base class constructor.
      ::CORBA::release (any_tc);
    }
  catch (const ::CORBA::Exception&)
    {
    }

  return false;
}

template<typename T >
void TAO::Any_Basic_Impl_T< T >::insert ( CORBA::Any any,
CORBA::TypeCode_ptr  tc,
const T &  value 
) [static]

Definition at line 38 of file Any_Basic_Impl_T.cpp.

{
  Any_Basic_Impl_T<T> *new_impl = 0;
  ACE_NEW (new_impl,
           Any_Basic_Impl_T (tc,
                             value));
  any.replace (new_impl);
}

template<typename T >
CORBA::Boolean TAO::Any_Basic_Impl_T< T >::marshal_value ( TAO_OutputCDR cdr  )  [virtual]

Implements TAO::Any_Impl.

Definition at line 119 of file Any_Basic_Impl_T.cpp.

{
  return (cdr << this->value_);
}

template<typename T >
const void * TAO::Any_Basic_Impl_T< T >::value ( void   )  const [virtual]

Definition at line 126 of file Any_Basic_Impl_T.cpp.

{
  return &this->value_;
}


Member Data Documentation

template<typename T>
T TAO::Any_Basic_Impl_T< T >::value_ [private]

Definition at line 59 of file Any_Basic_Impl_T.h.


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