// $Id$ #ifndef TAO_ANY_ARRAY_IMPL_T_C #define TAO_ANY_ARRAY_IMPL_T_C #include "tao/Any_Array_Impl_T.h" #include "tao/Any_Unknown_IDL_Type.h" #include "tao/Marshal.h" #include "tao/debug.h" #include "tao/CDR.h" #include "tao/SystemException.h" #include "ace/CORBA_macros.h" #include "ace/Auto_Ptr.h" #if !defined (__ACE_INLINE__) # include "tao/Any_Array_Impl_T.inl" #endif /* ! __ACE_INLINE__ */ ACE_RCSID (tao, Any_Array_Impl_T, "$Id$") template TAO::Any_Array_Impl_T::Any_Array_Impl_T ( _tao_destructor destructor, CORBA::TypeCode_ptr tc, T_slice * const val ) : Any_Impl (destructor, tc), value_ (val) { } template TAO::Any_Array_Impl_T::~Any_Array_Impl_T (void) { } template void TAO::Any_Array_Impl_T::insert (CORBA::Any & any, _tao_destructor destructor, CORBA::TypeCode_ptr tc, T_slice * const value) { TAO::Any_Array_Impl_T *new_impl = 0; typedef TAO::Any_Array_Impl_T ARRAY_ANY_IMPL; ACE_NEW (new_impl, ARRAY_ANY_IMPL (destructor, tc, value)); any.replace (new_impl); } template CORBA::Boolean TAO::Any_Array_Impl_T::extract (const CORBA::Any & any, _tao_destructor destructor, CORBA::TypeCode_ptr tc, T_slice *& _tao_elem) { _tao_elem = 0; ACE_TRY_NEW_ENV { CORBA::TypeCode_ptr any_tc = any._tao_get_typecode (); const CORBA::Boolean _tao_equiv = any_tc->equivalent (tc ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; if (_tao_equiv == 0) { return 0; } TAO::Any_Impl *impl = any.impl (); if (!impl->encoded ()) { TAO::Any_Array_Impl_T *narrow_impl = dynamic_cast *> (impl); if (narrow_impl == 0) { return 0; } _tao_elem = reinterpret_cast (narrow_impl->value_); return 1; } TAO::Any_Array_Impl_T *replacement = 0; typedef TAO::Any_Array_Impl_T ARRAY_ANY_IMPL; ACE_NEW_RETURN (replacement, ARRAY_ANY_IMPL (destructor, any_tc, T_forany::tao_alloc ()), 0); auto_ptr > replacement_safety ( replacement ); // We know this will work since the unencoded case is covered above. TAO::Unknown_IDL_Type *unk = dynamic_cast (impl); // 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 good_decode = replacement->demarshal_value (for_reading); if (good_decode) { _tao_elem = reinterpret_cast (replacement->value_); const_cast (any).replace (replacement); replacement_safety.release (); return 1; } // Duplicated by Any_Impl base class constructor. CORBA::release (any_tc); } ACE_CATCHANY { } ACE_ENDTRY; return 0; } template void TAO::Any_Array_Impl_T::free_value (void) { if (this->value_destructor_ != 0) { (*this->value_destructor_) (this->value_); this->value_destructor_ = 0; } this->value_ = 0; CORBA::release (this->type_); } template void TAO::Any_Array_Impl_T::_tao_decode (TAO_InputCDR &cdr ACE_ENV_ARG_DECL) { if (! this->demarshal_value (cdr)) { ACE_THROW (CORBA::MARSHAL ()); } } #endif /* TAO_ANY_ARRAY_IMPL_T_C */