TAO::Any_Special_Impl_T< T, from_T, to_T > Class Template Reference

Template Any class for bounded IDL (w)strings. More...

#include <Any_Special_Impl_T.h>

Inheritance diagram for TAO::Any_Special_Impl_T< T, from_T, to_T >:

Inheritance graph
[legend]
Collaboration diagram for TAO::Any_Special_Impl_T< T, from_T, to_T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Any_Special_Impl_T (_tao_destructor destructor, CORBA::TypeCode_ptr, T *const , CORBA::ULong bound)
virtual ~Any_Special_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 destructor, CORBA::TypeCode_ptr, T *const , CORBA::ULong bound)
CORBA::Boolean extract (const CORBA::Any &, _tao_destructor, CORBA::TypeCode_ptr, const T *&, CORBA::ULong bound)

Private Attributes

T * value_
CORBA::ULong bound_

Detailed Description

template<typename T, typename from_T, typename to_T>
class TAO::Any_Special_Impl_T< T, from_T, to_T >

Template Any class for bounded IDL (w)strings.

Definition at line 35 of file Any_Special_Impl_T.h.


Constructor & Destructor Documentation

template<typename T, typename from_T, typename to_T>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::Any_Special_Impl_T< T, from_T, to_T >::Any_Special_Impl_T _tao_destructor  destructor,
CORBA::TypeCode_ptr  ,
T *  const,
CORBA::ULong  bound
 

Definition at line 19 of file Any_Special_Impl_T.cpp.

00025   : Any_Impl (destructor,
00026               tc),
00027     value_ (val),
00028     bound_ (bound)
00029 {
00030 }

template<typename T, typename from_T, typename to_T>
TAO::Any_Special_Impl_T< T, from_T, to_T >::~Any_Special_Impl_T void   )  [virtual]
 

Definition at line 33 of file Any_Special_Impl_T.cpp.

00034 {
00035 }


Member Function Documentation

template<typename T, typename from_T, typename to_T>
void TAO::Any_Special_Impl_T< T, from_T, to_T >::_tao_decode TAO_InputCDR  )  [virtual]
 

Reimplemented from TAO::Any_Impl.

Definition at line 201 of file Any_Special_Impl_T.cpp.

References TAO::Any_Special_Impl_T< T, from_T, to_T >::demarshal_value().

00202 {
00203   if (this->value_destructor_ != 0)
00204     {
00205       (*this->value_destructor_) (this->value_);
00206       this->value_ = 0;
00207     }
00208 
00209   if (! this->demarshal_value (cdr))
00210     {
00211       throw ::CORBA::MARSHAL ();
00212     }
00213 }

template<typename T, typename from_T, typename to_T>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE CORBA::Boolean TAO::Any_Special_Impl_T< T, from_T, to_T >::demarshal_value TAO_InputCDR  ) 
 

Definition at line 10 of file Any_Special_Impl_T.inl.

Referenced by TAO::Any_Special_Impl_T< T, from_T, to_T >::_tao_decode(), and TAO::Any_Special_Impl_T< T, from_T, to_T >::extract().

00013 {
00014   return (cdr >> to_T (this->value_, this->bound_));
00015 }

template<typename T, typename from_T, typename to_T>
CORBA::Boolean TAO::Any_Special_Impl_T< T, from_T, to_T >::extract const CORBA::Any ,
_tao_destructor  ,
CORBA::TypeCode_ptr  ,
const T *&  ,
CORBA::ULong  bound
[static]
 

Definition at line 76 of file Any_Special_Impl_T.cpp.

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

00081 {
00082   _tao_elem = 0;
00083 
00084   try
00085     {
00086       CORBA::TypeCode_ptr any_type = any._tao_get_typecode ();
00087       CORBA::TypeCode_var unaliased_any_type =
00088         TAO::unaliased_typecode (any_type
00089                                 );
00090 
00091       CORBA::TCKind const any_kind =
00092         unaliased_any_type->kind ();
00093 
00094       CORBA::TCKind const try_kind = tc->kind ();
00095 
00096       if (any_kind != try_kind)
00097         {
00098           return false;
00099         }
00100 
00101       CORBA::ULong const length = unaliased_any_type->length ();
00102 
00103       if (length != bound)
00104         {
00105           return false;
00106         }
00107 
00108       TAO::Any_Impl * const impl = any.impl ();
00109 
00110       typedef TAO::Any_Special_Impl_T<T, from_T, to_T>
00111         BOUNDED_TSTRING_ANY_IMPL;
00112 
00113       if (impl && !impl->encoded ())
00114         {
00115           TAO::Any_Special_Impl_T<T, from_T, to_T> * const narrow_impl =
00116             dynamic_cast <BOUNDED_TSTRING_ANY_IMPL *> (impl);
00117 
00118           if (narrow_impl == 0)
00119             {
00120               return false;
00121             }
00122 
00123           _tao_elem = (T *) narrow_impl->value_;
00124           return true;
00125         }
00126 
00127       TAO::Any_Special_Impl_T<T, from_T, to_T> *replacement = 0;
00128       ACE_NEW_RETURN (replacement,
00129                       BOUNDED_TSTRING_ANY_IMPL (destructor,
00130                                                 tc,
00131                                                 0,
00132                                                 bound),
00133                       false);
00134 
00135       auto_ptr<TAO::Any_Special_Impl_T<T, from_T, to_T> > replacement_safety (
00136           replacement
00137         );
00138 
00139       // We know this will work since the unencoded case is covered above.
00140       TAO::Unknown_IDL_Type * const unk =
00141         dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
00142 
00143       if (!unk)
00144         return false;
00145 
00146       // We don't want the rd_ptr of unk to move, in case it is
00147       // shared by another Any. This copies the state, not the buffer.
00148       TAO_InputCDR for_reading (unk->_tao_get_cdr ());
00149 
00150       CORBA::Boolean const good_decode =
00151         replacement->demarshal_value (for_reading);
00152 
00153       if (good_decode)
00154         {
00155           _tao_elem = replacement->value_;
00156           const_cast<CORBA::Any &> (any).replace (replacement);
00157           replacement_safety.release ();
00158           return true;
00159         }
00160 
00161       // Duplicated by Any_Impl base class constructor.
00162       ::CORBA::release (tc);
00163     }
00164   catch (const ::CORBA::Exception&)
00165     {
00166     }
00167 
00168   return false;
00169 }

template<typename T, typename from_T, typename to_T>
void TAO::Any_Special_Impl_T< T, from_T, to_T >::free_value void   )  [virtual]
 

Reimplemented from TAO::Any_Impl.

Definition at line 187 of file Any_Special_Impl_T.cpp.

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

template<typename T, typename from_T, typename to_T>
void TAO::Any_Special_Impl_T< T, from_T, to_T >::insert CORBA::Any ,
_tao_destructor  destructor,
CORBA::TypeCode_ptr  ,
T *  const,
CORBA::ULong  bound
[static]
 

Definition at line 39 of file Any_Special_Impl_T.cpp.

References CORBA::TypeCode::_duplicate(), ACE_NEW, CORBA::is_nil(), and CORBA::Any::replace().

00045 {
00046   CORBA::TypeCode_var bounded_tc;
00047 
00048   if (bound > 0)
00049     {
00050       CORBA::TCKind const kind = tc->kind ();
00051 
00052       bounded_tc =
00053         TAO::TypeCodeFactory::String_Traits<from_T>::create_typecode (kind,
00054                                                                       bound);
00055     }
00056   else
00057     {
00058       bounded_tc = CORBA::TypeCode::_duplicate (tc);
00059     }
00060 
00061   if (CORBA::is_nil (bounded_tc.in ()))
00062     return;
00063 
00064   Any_Special_Impl_T<T, from_T, to_T> * new_impl;
00065   ACE_NEW (new_impl,
00066            Any_Special_Impl_T (destructor,
00067                                bounded_tc.in (),
00068                                value,
00069                                bound));
00070 
00071   any.replace (new_impl);
00072 }

template<typename T, typename from_T, typename to_T>
CORBA::Boolean TAO::Any_Special_Impl_T< T, from_T, to_T >::marshal_value TAO_OutputCDR  )  [virtual]
 

Implements TAO::Any_Impl.

Definition at line 173 of file Any_Special_Impl_T.cpp.

00174 {
00175   return (cdr << from_T (this->value_, this->bound_));
00176 }

template<typename T, typename from_T, typename to_T>
const void * TAO::Any_Special_Impl_T< T, from_T, to_T >::value void   )  const [virtual]
 

Definition at line 180 of file Any_Special_Impl_T.cpp.

00181 {
00182   return this->value_;
00183 }


Member Data Documentation

template<typename T, typename from_T, typename to_T>
CORBA::ULong TAO::Any_Special_Impl_T< T, from_T, to_T >::bound_ [private]
 

Definition at line 65 of file Any_Special_Impl_T.h.

template<typename T, typename from_T, typename to_T>
T* TAO::Any_Special_Impl_T< T, from_T, to_T >::value_ [private]
 

Definition at line 64 of file Any_Special_Impl_T.h.

Referenced by TAO::Any_Special_Impl_T< T, from_T, to_T >::extract().


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