00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Any_Unknown_IDL_Type.h 00006 * 00007 * $Id: Any_Unknown_IDL_Type.h 85181 2009-04-28 07:00:58Z johnnyw $ 00008 * 00009 * @author Carlos O'Ryan 00010 * @author Jeff Parsons 00011 */ 00012 //============================================================================= 00013 00014 #ifndef TAO_ANY_UNKNOWN_IDL_TYPE_H 00015 #define TAO_ANY_UNKNOWN_IDL_TYPE_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #include "ace/Refcounted_Auto_Ptr.h" 00020 #include "ace/Lock_Adapter_T.h" 00021 00022 #include "tao/AnyTypeCode/Any_Impl.h" 00023 #include "tao/CDR.h" 00024 00025 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00026 # pragma once 00027 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 namespace TAO 00032 { 00033 /** 00034 * @class Unknown_IDL_Type 00035 * 00036 * @brief CDR-based Any impl class. 00037 * 00038 * Used when demarshaling an Any, and with DII/DSI, and Dynamic Anys. 00039 */ 00040 class TAO_AnyTypeCode_Export Unknown_IDL_Type : public Any_Impl 00041 { 00042 public: 00043 Unknown_IDL_Type (CORBA::TypeCode_ptr, 00044 TAO_InputCDR &cdr); 00045 00046 Unknown_IDL_Type (CORBA::TypeCode_ptr); 00047 00048 virtual ~Unknown_IDL_Type (void); 00049 00050 virtual CORBA::Boolean marshal_value (TAO_OutputCDR &); 00051 virtual const void *value (void) const; 00052 virtual void free_value (void); 00053 00054 virtual TAO_InputCDR &_tao_get_cdr (void); 00055 virtual int _tao_byte_order (void) const; 00056 00057 virtual void _tao_decode (TAO_InputCDR &); 00058 00059 virtual CORBA::Boolean to_object (CORBA::Object_ptr &) const; 00060 virtual CORBA::Boolean to_value (CORBA::ValueBase *&) const; 00061 virtual CORBA::Boolean to_abstract_base (CORBA::AbstractBase_ptr &) const; 00062 00063 private: 00064 // We make the lock global, so that it won't be deleted when shared. 00065 // For instance, see Any_Basic_Impl::extract() which copies the insides 00066 // from an Unknown_IDL_Type to an Any_Basic_Impl. 00067 00068 // [Iliyan] However, having a global static makes this a subject 00069 // to the whim of the specific compiler implentation. It is the 00070 // one deciding the order in which our instance is initialized and 00071 // destroyed and that is boundto be a problem 00072 // somewhere. Typically, it becomes a problem when a code that 00073 // depends on that instance finds that the runtime has already 00074 // destroyed it. The scenario plays almost always in the process 00075 // shutdown code, after main() exits, having to debug which is a 00076 // lot of fun :) ... Bottom line, use a static function, which 00077 // encapsulates a local static initializer, guaranteed to be 00078 // initialized at the first invocation. Using ACE_Refcounted_Auto_Ptr 00079 // ensures that the ref count will not drop to zero until the library 00080 // is unloaded *and* all Unknown_IDL_Type instances have been destroyed. 00081 typedef ACE_Refcounted_Auto_Ptr<ACE_Lock, 00082 ACE_Lock_Adapter<TAO_SYNCH_MUTEX> > 00083 LOCK; 00084 static LOCK const lock_i (void); 00085 LOCK const lock_; 00086 mutable TAO_InputCDR cdr_; 00087 }; 00088 } 00089 00090 TAO_END_VERSIONED_NAMESPACE_DECL 00091 00092 #include /**/ "ace/post.h" 00093 00094 #endif /* TAO_ANY_UNKNOWN_IDL_TYPE_H */