00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Any_Unknown_IDL_Type.h 00006 * 00007 * $Id: Any_Unknown_IDL_Type.h 80562 2008-02-04 15:03:26Z 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 00060 virtual CORBA::Boolean to_object (CORBA::Object_ptr &) const; 00061 virtual CORBA::Boolean to_value (CORBA::ValueBase *&) const; 00062 virtual CORBA::Boolean to_abstract_base (CORBA::AbstractBase_ptr &) const; 00063 00064 private: 00065 // We make the lock global, so that it won't be deleted when shared. 00066 // For instance, see Any_Basic_Impl::extract() which copies the insides 00067 // from an Unknown_IDL_Type to an Any_Basic_Impl. 00068 00069 // [Iliyan] However, having a global static makes this a subject 00070 // to the whim of the specific compiler implentation. It is the 00071 // one deciding the order in which our instance is initialized and 00072 // destroyed and that is boundto be a problem 00073 // somewhere. Typically, it becomes a problem when a code that 00074 // depends on that instance finds that the runtime has already 00075 // destroyed it. The scenario plays almost always in the process 00076 // shutdown code, after main() exits, having to debug which is a 00077 // lot of fun :) ... Bottom line, use a static function, which 00078 // encapsulates a local static initializer, guaranteed to be 00079 // initialized at the first invocation. Using ACE_Refcounted_Auto_Ptr 00080 // ensures that the ref count will not drop to zero until the library 00081 // is unloaded *and* all Unknown_IDL_Type instances have been destroyed. 00082 typedef ACE_Refcounted_Auto_Ptr<ACE_Lock, 00083 ACE_Lock_Adapter<TAO_SYNCH_MUTEX> > 00084 LOCK; 00085 static LOCK lock_i (void); 00086 LOCK const lock_; 00087 mutable TAO_InputCDR cdr_; 00088 }; 00089 } 00090 00091 TAO_END_VERSIONED_NAMESPACE_DECL 00092 00093 #include /**/ "ace/post.h" 00094 00095 #endif /* TAO_ANY_UNKNOWN_IDL_TYPE_H */