TAO::Unknown_IDL_Type Class Reference

CDR-based Any impl class. More...

#include <Any_Unknown_IDL_Type.h>

Inheritance diagram for TAO::Unknown_IDL_Type:

Inheritance graph
[legend]
Collaboration diagram for TAO::Unknown_IDL_Type:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Unknown_IDL_Type (CORBA::TypeCode_ptr, TAO_InputCDR &cdr)
 Unknown_IDL_Type (CORBA::TypeCode_ptr)
virtual ~Unknown_IDL_Type (void)
virtual CORBA::Boolean marshal_value (TAO_OutputCDR &)
virtual const void * value (void) const
virtual void free_value (void)
virtual TAO_InputCDR_tao_get_cdr (void)
virtual int _tao_byte_order (void) const
virtual void _tao_decode (TAO_InputCDR &)
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

Private Types

typedef ACE_Refcounted_Auto_Ptr<
ACE_Lock, ACE_Lock_Adapter<
TAO_SYNCH_MUTEX > > 
LOCK

Static Private Member Functions

static LOCK lock_i (void)

Private Attributes

LOCK const lock_
TAO_InputCDR cdr_

Detailed Description

CDR-based Any impl class.

Used when demarshaling an Any, and with DII/DSI, and Dynamic Anys.

Definition at line 40 of file Any_Unknown_IDL_Type.h.


Member Typedef Documentation

typedef ACE_Refcounted_Auto_Ptr<ACE_Lock, ACE_Lock_Adapter<TAO_SYNCH_MUTEX> > TAO::Unknown_IDL_Type::LOCK [private]

Definition at line 84 of file Any_Unknown_IDL_Type.h.


Constructor & Destructor Documentation

TAO::Unknown_IDL_Type::Unknown_IDL_Type ( CORBA::TypeCode_ptr  ,
TAO_InputCDR cdr 
)

Definition at line 28 of file Any_Unknown_IDL_Type.cpp.

References _tao_decode(), and Unknown_IDL_Type().

Referenced by Unknown_IDL_Type().

00030   : TAO::Any_Impl (0, tc, true)
00031   , lock_ (lock_i ())
00032   , cdr_ (static_cast<ACE_Message_Block*>(0), lock_.get ())
00033 {
00034   try
00035     {
00036       this->_tao_decode (cdr);
00037     }
00038   catch (::CORBA::Exception const &)
00039     {
00040     }
00041 }

TAO::Unknown_IDL_Type::Unknown_IDL_Type ( CORBA::TypeCode_ptr   ) 

Definition at line 43 of file Any_Unknown_IDL_Type.cpp.

References Unknown_IDL_Type().

00044   : TAO::Any_Impl (0, tc, true)
00045   , lock_ (lock_i ())
00046   , cdr_ (static_cast<ACE_Message_Block*>(0), lock_.get ())
00047 {
00048 }

TAO::Unknown_IDL_Type::~Unknown_IDL_Type ( void   )  [virtual]

Definition at line 50 of file Any_Unknown_IDL_Type.cpp.

References ~Unknown_IDL_Type().

Referenced by ~Unknown_IDL_Type().

00051 {
00052 }


Member Function Documentation

int TAO::Unknown_IDL_Type::_tao_byte_order ( void   )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 100 of file Any_Unknown_IDL_Type.cpp.

References _tao_byte_order(), ACE_InputCDR::byte_order(), and cdr_.

Referenced by _tao_byte_order().

00101 {
00102   return this->cdr_.byte_order ();
00103 }

void TAO::Unknown_IDL_Type::_tao_decode ( TAO_InputCDR  )  [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 105 of file Any_Unknown_IDL_Type.cpp.

References _tao_decode(), ACE_InputCDR::byte_order(), cdr_, ACE_InputCDR::char_translator(), ACE_InputCDR::get_version(), major_version(), ACE_CDR::MAX_ALIGNMENT, ACE_CDR::mb_align(), ACE_OS::memcpy(), minor_version(), TAO_Marshal_Object::perform_skip(), ACE_Message_Block::rd_ptr(), ACE_InputCDR::rd_ptr(), ACE_InputCDR::reset(), ACE_InputCDR::set_version(), ACE_InputCDR::wchar_translator(), and ACE_Message_Block::wr_ptr().

Referenced by _tao_decode(), and Unknown_IDL_Type().

00106 {
00107   // @@ (JP) The following code depends on the fact that
00108   //         TAO_InputCDR does not contain chained message blocks,
00109   //         otherwise <begin> and <end> could be part of
00110   //         different buffers!
00111 
00112   // This will be the start of a new message block.
00113   char const * const begin = cdr.rd_ptr ();
00114 
00115   // Skip over the next argument.
00116   TAO::traverse_status const status =
00117     TAO_Marshal_Object::perform_skip (this->type_, &cdr);
00118 
00119   if (status != TAO::TRAVERSE_CONTINUE)
00120     {
00121       throw ::CORBA::MARSHAL ();
00122     }
00123 
00124   // This will be the end of the new message block.
00125   char const * const end = cdr.rd_ptr ();
00126 
00127   // The ACE_CDR::mb_align() call can shift the rd_ptr by up to
00128   // ACE_CDR::MAX_ALIGNMENT - 1 bytes. Similarly, the offset adjustment
00129   // can move the rd_ptr by up to the same amount. We accommodate
00130   // this by including 2 * ACE_CDR::MAX_ALIGNMENT bytes of additional
00131   // space in the message block.
00132   size_t const size = end - begin;
00133 
00134   ACE_Message_Block new_mb (size + 2 * ACE_CDR::MAX_ALIGNMENT);
00135 
00136   ACE_CDR::mb_align (&new_mb);
00137   ptrdiff_t offset = ptrdiff_t (begin) % ACE_CDR::MAX_ALIGNMENT;
00138 
00139   if (offset < 0)
00140     {
00141       offset += ACE_CDR::MAX_ALIGNMENT;
00142     }
00143 
00144   new_mb.rd_ptr (offset);
00145   new_mb.wr_ptr (offset + size);
00146 
00147   ACE_OS::memcpy (new_mb.rd_ptr (), begin, size);
00148 
00149   this->cdr_.reset (&new_mb, cdr.byte_order ());
00150   this->cdr_.char_translator (cdr.char_translator ());
00151   this->cdr_.wchar_translator (cdr.wchar_translator ());
00152 
00153   // Take over the GIOP version, the input cdr can have a different
00154   // version then our current GIOP version.
00155   ACE_CDR::Octet major_version;
00156   ACE_CDR::Octet minor_version;
00157   cdr.get_version (major_version, minor_version);
00158   this->cdr_.set_version (major_version, minor_version);
00159 }

TAO_InputCDR & TAO::Unknown_IDL_Type::_tao_get_cdr ( void   )  [virtual]

Definition at line 94 of file Any_Unknown_IDL_Type.cpp.

References _tao_get_cdr(), and cdr_.

Referenced by _tao_get_cdr().

00095 {
00096   return this->cdr_;
00097 }

void TAO::Unknown_IDL_Type::free_value ( void   )  [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 88 of file Any_Unknown_IDL_Type.cpp.

References free_value(), and release().

Referenced by free_value().

00089 {
00090   ::CORBA::release (this->type_);
00091 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::Unknown_IDL_Type::LOCK TAO::Unknown_IDL_Type::lock_i ( void   )  [static, private]

Definition at line 22 of file Any_Unknown_IDL_Type.cpp.

00023 {
00024   static LOCK base_lock_ (new ACE_Lock_Adapter<TAO_SYNCH_MUTEX>());
00025   return base_lock_;
00026 }

CORBA::Boolean TAO::Unknown_IDL_Type::marshal_value ( TAO_OutputCDR  )  [virtual]

Implements TAO::Any_Impl.

Definition at line 55 of file Any_Unknown_IDL_Type.cpp.

References marshal_value(), and TAO_Marshal_Object::perform_append().

Referenced by marshal_value().

00056 {
00057   try
00058     {
00059       // We don't want the rd_ptr to move, in case we are shared by
00060       // another Any, so we use this to copy the state, not the buffer.
00061       TAO_InputCDR for_reading (this->cdr_);
00062 
00063       TAO::traverse_status const status =
00064         TAO_Marshal_Object::perform_append (this->type_,
00065                                             &for_reading,
00066                                             &cdr);
00067 
00068       if (status != TAO::TRAVERSE_CONTINUE)
00069         {
00070           return false;
00071         }
00072     }
00073   catch (::CORBA::Exception const &)
00074     {
00075       return false;
00076     }
00077 
00078   return true;
00079 }

CORBA::Boolean TAO::Unknown_IDL_Type::to_abstract_base ( CORBA::AbstractBase_ptr  )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 227 of file Any_Unknown_IDL_Type.cpp.

References ACE_DEBUG, ACE_TEXT, cdr_, LM_WARNING, TAO_InputCDR::orb_core(), TAO_Valuetype_Adapter::stream_to_abstract_base(), TAO_debug_level, TAO_ORB_Core_instance(), CORBA::tk_abstract_interface, to_abstract_base(), and TAO_ORB_Core::valuetype_adapter().

Referenced by to_abstract_base().

00228 {
00229   try
00230     {
00231       CORBA::TCKind const kind = TAO::unaliased_kind (this->type_);
00232 
00233       if (kind != CORBA::tk_abstract_interface)
00234         {
00235           return false;
00236         }
00237 
00238       TAO_ORB_Core *orb_core = this->cdr_.orb_core ();
00239       if (orb_core == 0)
00240         {
00241           orb_core = TAO_ORB_Core_instance ();
00242 
00243           if (TAO_debug_level > 0)
00244             {
00245               ACE_DEBUG ((LM_WARNING,
00246                           ACE_TEXT ("TAO (%P|%t) WARNING: extracting ")
00247                           ACE_TEXT ("abstract base using default ORB_Core\n")));
00248             }
00249         }
00250 
00251       // We don't want the rd_ptr to move, in case we are shared by
00252       // another Any, so we use this to copy the state, not the buffer.
00253       TAO_InputCDR for_reading (this->cdr_);
00254 
00255       TAO_Valuetype_Adapter * const adapter =
00256         orb_core->valuetype_adapter ();
00257       return adapter->stream_to_abstract_base (for_reading, obj);
00258     }
00259    catch (::CORBA::Exception const &)
00260     {
00261     }
00262 
00263   return false;
00264 }

CORBA::Boolean TAO::Unknown_IDL_Type::to_object ( CORBA::Object_ptr  )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 162 of file Any_Unknown_IDL_Type.cpp.

References CORBA::tk_objref, and to_object().

Referenced by to_object().

00163 {
00164   try
00165     {
00166       CORBA::TCKind const kind = TAO::unaliased_kind (this->type_);
00167 
00168       if (kind != CORBA::tk_objref)
00169         {
00170           return false;
00171         }
00172 
00173       // We don't want the rd_ptr to move, in case we are shared by
00174       // another Any, so we use this to copy the state, not the buffer.
00175       TAO_InputCDR for_reading (this->cdr_);
00176 
00177       return for_reading >> obj;
00178     }
00179   catch (::CORBA::Exception const &)
00180     {
00181     }
00182 
00183   return false;
00184 }

CORBA::Boolean TAO::Unknown_IDL_Type::to_value ( CORBA::ValueBase *&   )  const [virtual]

Reimplemented from TAO::Any_Impl.

Definition at line 187 of file Any_Unknown_IDL_Type.cpp.

References ACE_DEBUG, ACE_TEXT, cdr_, LM_WARNING, TAO_InputCDR::orb_core(), TAO_Valuetype_Adapter::stream_to_value(), TAO_debug_level, TAO_ORB_Core_instance(), CORBA::tk_value, to_value(), and TAO_ORB_Core::valuetype_adapter().

Referenced by to_value().

00188 {
00189   try
00190     {
00191       CORBA::TCKind const kind = TAO::unaliased_kind (this->type_);
00192 
00193       if (kind != CORBA::tk_value)
00194         {
00195           return false;
00196         }
00197 
00198       TAO_ORB_Core *orb_core = this->cdr_.orb_core ();
00199       if (orb_core == 0)
00200         {
00201           orb_core = TAO_ORB_Core_instance ();
00202 
00203           if (TAO_debug_level > 0)
00204             {
00205               ACE_DEBUG ((LM_WARNING,
00206                           ACE_TEXT ("TAO (%P|%t) WARNING: extracting ")
00207                           ACE_TEXT ("valuetype using default ORB_Core\n")));
00208             }
00209         }
00210 
00211       // We don't want the rd_ptr to move, in case we are shared by
00212       // another Any, so we use this to copy the state, not the buffer.
00213       TAO_InputCDR for_reading (this->cdr_);
00214 
00215       TAO_Valuetype_Adapter * const adapter =
00216         orb_core->valuetype_adapter ();
00217       return adapter->stream_to_value (for_reading, val);
00218     }
00219   catch (::CORBA::Exception const &)
00220     {
00221     }
00222 
00223   return false;
00224 }

const void * TAO::Unknown_IDL_Type::value ( void   )  const [virtual]

Definition at line 82 of file Any_Unknown_IDL_Type.cpp.

References cdr_, ACE_InputCDR::start(), and value().

Referenced by value().

00083 {
00084   return this->cdr_.start ();
00085 }


Member Data Documentation

TAO_InputCDR TAO::Unknown_IDL_Type::cdr_ [mutable, private]

Definition at line 87 of file Any_Unknown_IDL_Type.h.

Referenced by _tao_byte_order(), _tao_decode(), _tao_get_cdr(), to_abstract_base(), to_value(), and value().

LOCK const TAO::Unknown_IDL_Type::lock_ [private]

Definition at line 86 of file Any_Unknown_IDL_Type.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:40:25 2010 for TAO_AnyTypeCode by  doxygen 1.4.7