Public Member Functions | Static Public Member Functions | Private Attributes

TAO::Any_Impl_T< T > Class Template Reference

Template Any class for pointer types. More...

#include <Any_Impl_T.h>

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

List of all members.

Public Member Functions

 Any_Impl_T (_tao_destructor destructor, CORBA::TypeCode_ptr, T *const)
virtual ~Any_Impl_T (void)
virtual CORBA::Boolean to_object (CORBA::Object_ptr &) const
virtual CORBA::Boolean to_value (CORBA::ValueBase *&) const
virtual CORBA::Boolean to_abstract_base (CORBA::AbstractBase_ptr &) const
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
virtual void free_value (void)
template<>
CORBA::Boolean to_object (CORBA::Object_ptr &_tao_elem) const
template<>
CORBA::Boolean to_object (CORBA::Object_ptr &_tao_elem) const
template<>
CORBA::Boolean to_object (::CORBA::Object_ptr &_tao_elem) const
template<>
CORBA::Boolean marshal_value (TAO_OutputCDR &)
template<>
CORBA::Boolean demarshal_value (TAO_InputCDR &)

Static Public Member Functions

static void insert (CORBA::Any &, _tao_destructor destructor, CORBA::TypeCode_ptr, T *const)
static CORBA::Boolean extract (const CORBA::Any &, _tao_destructor, CORBA::TypeCode_ptr, T *&)

Private Attributes

T * value_

Detailed Description

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

Template Any class for pointer types.

Used for interfaces and typecodes

Definition at line 42 of file Any_Impl_T.h.


Constructor & Destructor Documentation

template<typename T >
TAO::Any_Impl_T< T >::Any_Impl_T ( _tao_destructor  destructor,
CORBA::TypeCode_ptr  tc,
T * const  val 
)

Definition at line 25 of file Any_Impl_T.cpp.

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

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

Definition at line 35 of file Any_Impl_T.cpp.

{
}


Member Function Documentation

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

Reimplemented from TAO::Any_Impl.

Definition at line 182 of file Any_Impl_T.cpp.

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

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

Definition at line 12 of file Any_Impl_T.inl.

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

template<>
CORBA::Boolean TAO::Any_Impl_T< RTCORBA::ProtocolProperties >::demarshal_value ( TAO_InputCDR  ) 

Definition at line 93 of file RT_ProtocolPropertiesA.cpp.

  {
    return false;
  }

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

Definition at line 56 of file Any_Impl_T.cpp.

{
  _tao_elem = 0;

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

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

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

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

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

          _tao_elem = (T *) narrow_impl->value_;
          return true;
        }

      TAO::Any_Impl_T<T> *replacement = 0;
      ACE_NEW_RETURN (replacement,
                      TAO::Any_Impl_T<T> (destructor,
                                          any_tc,
                                          0),
                      false);

      auto_ptr<TAO::Any_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 = const_cast<T *> (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_Impl_T< T >::free_value ( void   )  [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 168 of file Any_Impl_T.cpp.

{
  if (this->value_destructor_ != 0)
    {
      (*this->value_destructor_) (this->value_);
      this->value_destructor_ = 0;
    }

  ::CORBA::release (this->type_);
  this->value_ = 0;
}

template<typename T >
void TAO::Any_Impl_T< T >::insert ( CORBA::Any any,
_tao_destructor  destructor,
CORBA::TypeCode_ptr  tc,
T * const  value 
) [static]

Definition at line 41 of file Any_Impl_T.cpp.

{
  TAO::Any_Impl_T<T> *new_impl = 0;
  ACE_NEW (new_impl,
           TAO::Any_Impl_T<T> (destructor,
                               tc,
                               value));
  any.replace (new_impl);
}

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

Implements TAO::Any_Impl.

Definition at line 154 of file Any_Impl_T.cpp.

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

template<>
CORBA::Boolean TAO::Any_Impl_T< RTCORBA::ProtocolProperties >::marshal_value ( TAO_OutputCDR  )  [virtual]

Implements TAO::Any_Impl.

Definition at line 86 of file RT_ProtocolPropertiesA.cpp.

  {
    return false;
  }

template<typename T >
CORBA::Boolean TAO::Any_Impl_T< T >::to_abstract_base ( CORBA::AbstractBase_ptr  )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 147 of file Any_Impl_T.cpp.

{
  return false;
}

template<>
CORBA::Boolean TAO::Any_Impl_T< RTCORBA::ProtocolProperties >::to_object ( ::CORBA::Object_ptr _tao_elem  )  const

Definition at line 73 of file RT_ProtocolPropertiesA.cpp.

  {
    _tao_elem = ::CORBA::Object::_duplicate (this->value_);
    return true;
  }

template<>
CORBA::Boolean TAO::Any_Impl_T< CORBA::Policy >::to_object ( CORBA::Object_ptr _tao_elem  )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 320 of file PolicyA.cpp.

  {
    _tao_elem = CORBA::Object::_duplicate (this->value_);
    return true;
  }

template<>
CORBA::Boolean TAO::Any_Impl_T< CORBA::Object >::to_object ( CORBA::Object_ptr _tao_elem  )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 753 of file Any.cpp.

  {
    _tao_elem = CORBA::Object::_duplicate (this->value_);
    return true;
  }

template<typename T >
CORBA::Boolean TAO::Any_Impl_T< T >::to_object ( CORBA::Object_ptr  )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 132 of file Any_Impl_T.cpp.

{
  return false;
}

template<typename T >
CORBA::Boolean TAO::Any_Impl_T< T >::to_value ( CORBA::ValueBase *&   )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 139 of file Any_Impl_T.cpp.

{
  return false;
}

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

Definition at line 161 of file Any_Impl_T.cpp.

{
  return this->value_;
}


Member Data Documentation

template<typename T >
T* TAO::Any_Impl_T< T >::value_ [private]

Definition at line 70 of file Any_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