00001 // $Id: Any_Impl.cpp 76551 2007-01-24 13:42:44Z johnnyw $ 00002 00003 #include "tao/AnyTypeCode/Any_Impl.h" 00004 #include "tao/AnyTypeCode/TypeCode.h" 00005 #include "tao/AnyTypeCode/Marshal.h" 00006 00007 #include "tao/CORBA_String.h" 00008 #include "tao/SystemException.h" 00009 00010 #include "ace/Guard_T.h" 00011 00012 ACE_RCSID (AnyTypeCode, 00013 Any_Impl, 00014 "$Id: Any_Impl.cpp 76551 2007-01-24 13:42:44Z johnnyw $") 00015 00016 00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00018 00019 TAO::Any_Impl::Any_Impl (_tao_destructor destructor, 00020 CORBA::TypeCode_ptr tc, 00021 bool encoded) 00022 : value_destructor_ (destructor) 00023 , type_ (CORBA::TypeCode::_duplicate (tc)) 00024 , encoded_ (encoded) 00025 , refcount_ (1) 00026 { 00027 } 00028 00029 TAO::Any_Impl::~Any_Impl (void) 00030 { 00031 } 00032 00033 CORBA::Boolean 00034 TAO::Any_Impl::marshal (TAO_OutputCDR &cdr) 00035 { 00036 if ((cdr << this->type_) == 0) 00037 { 00038 return false; 00039 } 00040 00041 return this->marshal_value (cdr); 00042 } 00043 00044 void 00045 TAO::Any_Impl::free_value (void) 00046 { 00047 // We always have to do this. 00048 ::CORBA::release (this->type_); 00049 } 00050 00051 CORBA::TypeCode_ptr 00052 TAO::Any_Impl::type (void) const 00053 { 00054 return CORBA::TypeCode::_duplicate (this->type_); 00055 } 00056 00057 CORBA::TypeCode_ptr 00058 TAO::Any_Impl::_tao_get_typecode (void) const 00059 { 00060 return this->type_; 00061 } 00062 00063 void 00064 TAO::Any_Impl::type (CORBA::TypeCode_ptr tc) 00065 { 00066 ::CORBA::release (this->type_); 00067 this->type_ = CORBA::TypeCode::_duplicate (tc); 00068 } 00069 00070 int 00071 TAO::Any_Impl::_tao_byte_order (void) const 00072 { 00073 return TAO_ENCAP_BYTE_ORDER; 00074 } 00075 00076 void 00077 TAO::Any_Impl::_tao_any_string_destructor (void *x) 00078 { 00079 char *tmp = static_cast<char *> (x); 00080 CORBA::string_free (tmp); 00081 } 00082 00083 void 00084 TAO::Any_Impl::_tao_any_wstring_destructor (void *x) 00085 { 00086 CORBA::WChar *tmp = static_cast<CORBA::WChar *> (x); 00087 CORBA::wstring_free (tmp); 00088 } 00089 00090 void 00091 TAO::Any_Impl::_add_ref (void) 00092 { 00093 ++this->refcount_; 00094 } 00095 00096 void 00097 TAO::Any_Impl::_remove_ref (void) 00098 { 00099 const CORBA::ULong new_count = --this->refcount_; 00100 00101 if (new_count != 0) 00102 return; 00103 00104 this->free_value (); 00105 00106 delete this; 00107 } 00108 00109 void 00110 TAO::Any_Impl::_tao_decode (TAO_InputCDR & 00111 ) 00112 { 00113 throw ::CORBA::NO_IMPLEMENT (); 00114 } 00115 00116 CORBA::Boolean 00117 TAO::Any_Impl::to_object (CORBA::Object_ptr &) const 00118 { 00119 return false; 00120 } 00121 00122 CORBA::Boolean 00123 TAO::Any_Impl::to_value (CORBA::ValueBase *&) const 00124 { 00125 return false; 00126 } 00127 00128 CORBA::Boolean 00129 TAO::Any_Impl::to_abstract_base (CORBA::AbstractBase_ptr &) const 00130 { 00131 return false; 00132 } 00133 00134 bool 00135 TAO::Any_Impl::encoded (void) const 00136 { 00137 return this->encoded_; 00138 } 00139 00140 TAO_END_VERSIONED_NAMESPACE_DECL