TAO::Any_Dual_Impl_T< T > Class Template Reference

Template Any class for IDL types with 2 modes of insertion. More...

#include <Any_Dual_Impl_T.h>

Inheritance diagram for TAO::Any_Dual_Impl_T< T >:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Any_Dual_Impl_T (_tao_destructor destructor, CORBA::TypeCode_ptr, T *const )
 Any_Dual_Impl_T (_tao_destructor destructor, CORBA::TypeCode_ptr, const T &)
 Any_Dual_Impl_T (CORBA::TypeCode_ptr)
virtual ~Any_Dual_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
virtual void free_value (void)

Static Public Member Functions

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

Protected Member Functions

void value (const T &)

Protected Attributes

T * value_

Detailed Description

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

Template Any class for IDL types with 2 modes of insertion.

Used for the IDL types that have copying and non-copying insertion, but which are not (de)marshaled as pointers - struct, union, sequence, and exception.

Definition at line 40 of file Any_Dual_Impl_T.h.


Constructor & Destructor Documentation

template<typename T>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::Any_Dual_Impl_T< T >::Any_Dual_Impl_T _tao_destructor  destructor,
CORBA::TypeCode_ptr  ,
T *  const
 

Definition at line 25 of file Any_Dual_Impl_T.cpp.

00028   : Any_Impl (destructor,
00029               tc),
00030     value_ (val)
00031 {
00032 }

template<typename T>
TAO::Any_Dual_Impl_T< T >::Any_Dual_Impl_T _tao_destructor  destructor,
CORBA::TypeCode_ptr  ,
const T & 
 

Definition at line 42 of file Any_Dual_Impl_T.cpp.

References TAO::Any_Dual_Impl_T< T >::value().

00045   : Any_Impl (destructor,
00046               tc)
00047 {
00048   this->value (val);
00049 }

template<typename T>
TAO::Any_Dual_Impl_T< T >::Any_Dual_Impl_T CORBA::TypeCode_ptr   ) 
 

Definition at line 52 of file Any_Dual_Impl_T.cpp.

00053   : Any_Impl (0,
00054               tc)
00055 {
00056 }

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

Definition at line 59 of file Any_Dual_Impl_T.cpp.

00060 {
00061 }


Member Function Documentation

template<typename T>
void TAO::Any_Dual_Impl_T< T >::_tao_decode TAO_InputCDR  )  [virtual]
 

Reimplemented from TAO::Any_Impl.

Definition at line 203 of file Any_Dual_Impl_T.cpp.

References TAO::Any_Dual_Impl_T< T >::demarshal_value().

00204 {
00205   if (! this->demarshal_value (cdr))
00206     {
00207       throw ::CORBA::MARSHAL ();
00208     }
00209 }

template<typename T>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE CORBA::Boolean TAO::Any_Dual_Impl_T< T >::demarshal_value TAO_InputCDR  ) 
 

Definition at line 11 of file Any_Dual_Impl_T.inl.

Referenced by TAO::Any_Dual_Impl_T< T >::_tao_decode(), and TAO::Any_Dual_Impl_T< T >::extract().

00012 {
00013   return (cdr >> *this->value_);
00014 }

template<typename T>
CORBA::Boolean TAO::Any_Dual_Impl_T< T >::extract const CORBA::Any ,
_tao_destructor  ,
CORBA::TypeCode_ptr  ,
const T *& 
[static]
 

Definition at line 95 of file Any_Dual_Impl_T.cpp.

References TAO::Unknown_IDL_Type::_tao_get_cdr(), CORBA::Any::_tao_get_typecode(), ACE_NEW_RETURN, TAO::Any_Dual_Impl_T< T >::demarshal_value(), TAO::Any_Impl::encoded(), CORBA::Any::impl(), ACE_Auto_Basic_Ptr< X >::release(), and TAO::Any_Dual_Impl_T< T >::value_.

Referenced by operator>>=().

00099 {
00100   _tao_elem = 0;
00101 
00102   try
00103     {
00104       CORBA::TypeCode_ptr any_tc = any._tao_get_typecode ();
00105       CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc);
00106 
00107       if (_tao_equiv == false)
00108         {
00109           return false;
00110         }
00111 
00112       TAO::Any_Impl * const impl = any.impl ();
00113 
00114       if (impl && !impl->encoded ())
00115         {
00116           TAO::Any_Dual_Impl_T<T> * const narrow_impl =
00117             dynamic_cast <TAO::Any_Dual_Impl_T<T> *> (impl);
00118 
00119           if (narrow_impl == 0)
00120             {
00121               return false;
00122             }
00123 
00124           _tao_elem = narrow_impl->value_;
00125           return true;
00126         }
00127 
00128       T *empty_value = 0;
00129       ACE_NEW_RETURN (empty_value,
00130                       T,
00131                       false);
00132       TAO::Any_Dual_Impl_T<T> *replacement = 0;
00133       ACE_NEW_RETURN (replacement,
00134                       TAO::Any_Dual_Impl_T<T> (destructor,
00135                                                any_tc,
00136                                                empty_value),
00137                       false);
00138 
00139       auto_ptr<TAO::Any_Dual_Impl_T<T> > replacement_safety (replacement);
00140 
00141       // We know this will work since the unencoded case is covered above.
00142       TAO::Unknown_IDL_Type * const unk =
00143         dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
00144 
00145       if (!unk)
00146         return false;
00147 
00148       // We don't want the rd_ptr of unk to move, in case it is
00149       // shared by another Any. This copies the state, not the buffer.
00150       TAO_InputCDR for_reading (unk->_tao_get_cdr ());
00151 
00152       CORBA::Boolean const good_decode =
00153         replacement->demarshal_value (for_reading);
00154 
00155       if (good_decode)
00156         {
00157           _tao_elem = replacement->value_;
00158           const_cast<CORBA::Any &> (any).replace (replacement);
00159           replacement_safety.release ();
00160           return true;
00161         }
00162 
00163       // Duplicated by Any_Impl base class constructor.
00164       ::CORBA::release (any_tc);
00165     }
00166   catch (const ::CORBA::Exception&)
00167     {
00168     }
00169 
00170   return false;
00171 }

template<typename T>
void TAO::Any_Dual_Impl_T< T >::free_value void   )  [virtual]
 

Reimplemented from TAO::Any_Impl.

Definition at line 189 of file Any_Dual_Impl_T.cpp.

00190 {
00191   if (this->value_destructor_ != 0)
00192     {
00193       (*this->value_destructor_) (this->value_);
00194       this->value_destructor_ = 0;
00195     }
00196 
00197   ::CORBA::release (this->type_);
00198   this->value_ = 0;
00199 }

template<typename T>
void TAO::Any_Dual_Impl_T< T >::insert CORBA::Any ,
_tao_destructor  ,
CORBA::TypeCode_ptr  ,
T *  const
[static]
 

Definition at line 65 of file Any_Dual_Impl_T.cpp.

References ACE_NEW, and CORBA::Any::replace().

Referenced by operator<<=().

00069 {
00070   Any_Dual_Impl_T<T> *new_impl = 0;
00071   ACE_NEW (new_impl,
00072            Any_Dual_Impl_T (destructor,
00073                             tc,
00074                             value));
00075   any.replace (new_impl);
00076 }

template<typename T>
void TAO::Any_Dual_Impl_T< T >::insert_copy CORBA::Any ,
_tao_destructor  destructor,
CORBA::TypeCode_ptr  ,
const T & 
[static]
 

Definition at line 80 of file Any_Dual_Impl_T.cpp.

References ACE_NEW, and CORBA::Any::replace().

Referenced by operator<<=().

00084 {
00085   Any_Dual_Impl_T<T> *new_impl = 0;
00086   ACE_NEW (new_impl,
00087            Any_Dual_Impl_T (destructor,
00088                             tc,
00089                             value));
00090   any.replace (new_impl);
00091 }

template<typename T>
CORBA::Boolean TAO::Any_Dual_Impl_T< T >::marshal_value TAO_OutputCDR  )  [virtual]
 

Implements TAO::Any_Impl.

Definition at line 175 of file Any_Dual_Impl_T.cpp.

00176 {
00177   return (cdr << *this->value_);
00178 }

template<typename T>
void TAO::Any_Dual_Impl_T< T >::value const T &   )  [protected]
 

Definition at line 35 of file Any_Dual_Impl_T.cpp.

References ACE_NEW.

00036 {
00037   ACE_NEW (this->value_,
00038            T (val));
00039 }

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

Definition at line 182 of file Any_Dual_Impl_T.cpp.

Referenced by TAO::Any_Dual_Impl_T< T >::Any_Dual_Impl_T().

00183 {
00184   return this->value_;
00185 }


Member Data Documentation

template<typename T>
T* TAO::Any_Dual_Impl_T< T >::value_ [protected]
 

Definition at line 75 of file Any_Dual_Impl_T.h.

Referenced by TAO::Any_Dual_Impl_T< T >::extract().


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