00001
00002
00003 #ifndef TAO_ALIAS_TYPECODE_CPP
00004 #define TAO_ALIAS_TYPECODE_CPP
00005
00006 #include "tao/AnyTypeCode/Alias_TypeCode.h"
00007
00008 #ifndef __ACE_INLINE__
00009 # include "tao/AnyTypeCode/Alias_TypeCode.inl"
00010 #endif
00011
00012 #include "tao/ORB_Core.h"
00013 #include "tao/CDR.h"
00014 #include "tao/SystemException.h"
00015 #include "tao/AnyTypeCode/TypeCode_Traits.h"
00016
00017 #include "ace/Dynamic_Service.h"
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 template <typename StringType,
00022 typename TypeCodeType,
00023 class RefCountPolicy>
00024 bool
00025 TAO::TypeCode::Alias<StringType,
00026 TypeCodeType,
00027 RefCountPolicy>::tao_marshal (TAO_OutputCDR & cdr,
00028 CORBA::ULong offset) const
00029 {
00030
00031
00032
00033
00034
00035
00036
00037 TAO_OutputCDR enc;
00038
00039
00040
00041
00042
00043
00044 offset = ACE_align_binary (offset + 4,
00045 ACE_CDR::OCTET_ALIGN);
00046
00047 return
00048 enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)
00049 && enc << TAO_OutputCDR::from_string (this->attributes_.id (), 0)
00050 && enc << TAO_OutputCDR::from_string (this->attributes_.name (), 0)
00051 && marshal (enc,
00052 Traits<StringType>::get_typecode (this->content_type_),
00053 offset + enc.total_length ())
00054 && cdr << static_cast<CORBA::ULong> (enc.total_length ())
00055 && cdr.write_octet_array_mb (enc.begin ());
00056 }
00057
00058 template<typename StringType,
00059 typename TypeCodeType,
00060 class RefCountPolicy>
00061 void
00062 TAO::TypeCode::Alias<StringType,
00063 TypeCodeType,
00064 RefCountPolicy>::tao_duplicate (void)
00065 {
00066 this->RefCountPolicy::add_ref ();
00067 }
00068
00069 template<typename StringType,
00070 typename TypeCodeType,
00071 class RefCountPolicy>
00072 void
00073 TAO::TypeCode::Alias<StringType,
00074 TypeCodeType,
00075 RefCountPolicy>::tao_release (void)
00076 {
00077 this->RefCountPolicy::remove_ref ();
00078 }
00079
00080 template<typename StringType,
00081 typename TypeCodeType,
00082 class RefCountPolicy>
00083 CORBA::Boolean
00084 TAO::TypeCode::Alias<StringType,
00085 TypeCodeType,
00086 RefCountPolicy>::equal_i (CORBA::TypeCode_ptr tc) const
00087 {
00088
00089
00090
00091
00092 CORBA::TypeCode_var rhs_content_type = tc->content_type ();
00093
00094 return
00095 Traits<StringType>::get_typecode (this->content_type_)->equal (
00096 rhs_content_type.in ());
00097 }
00098
00099 template<typename StringType,
00100 typename TypeCodeType,
00101 class RefCountPolicy>
00102 CORBA::Boolean
00103 TAO::TypeCode::Alias<StringType,
00104 TypeCodeType,
00105 RefCountPolicy>::equivalent_i (CORBA::TypeCode_ptr) const
00106 {
00107
00108
00109
00110 return true;
00111 }
00112
00113 template<typename StringType,
00114 typename TypeCodeType,
00115 class RefCountPolicy>
00116 CORBA::TypeCode_ptr
00117 TAO::TypeCode::Alias<StringType,
00118 TypeCodeType,
00119 RefCountPolicy>::get_compact_typecode_i (void) const
00120 {
00121 TAO_TypeCodeFactory_Adapter * const adapter =
00122 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00123 TAO_ORB_Core::typecodefactory_adapter_name ()
00124 );
00125
00126 if (adapter == 0)
00127 {
00128 throw ::CORBA::INITIALIZE ();
00129 }
00130
00131 CORBA::TypeCode_var compact_content_type =
00132 Traits<StringType>::get_typecode (
00133 this->content_type_)->get_compact_typecode ();
00134
00135 if (this->kind_ == CORBA::tk_alias)
00136 {
00137 return adapter->create_alias_tc (this->attributes_.id (),
00138 "",
00139 compact_content_type.in ());
00140 }
00141 else
00142 {
00143 return adapter->create_value_box_tc (this->attributes_.id (),
00144 "",
00145 compact_content_type.in ());
00146 }
00147 }
00148
00149 template<typename StringType,
00150 typename TypeCodeType,
00151 class RefCountPolicy>
00152 char const *
00153 TAO::TypeCode::Alias<StringType,
00154 TypeCodeType,
00155 RefCountPolicy>::id_i (void) const
00156 {
00157
00158
00159 return this->attributes_.id ();
00160 }
00161
00162 template<typename StringType,
00163 typename TypeCodeType,
00164 class RefCountPolicy>
00165 char const *
00166 TAO::TypeCode::Alias<StringType,
00167 TypeCodeType,
00168 RefCountPolicy>::name_i (void) const
00169 {
00170
00171
00172 return this->attributes_.name ();
00173 }
00174
00175 template<typename StringType,
00176 typename TypeCodeType,
00177 class RefCountPolicy>
00178 CORBA::TypeCode_ptr
00179 TAO::TypeCode::Alias<StringType,
00180 TypeCodeType,
00181 RefCountPolicy>::content_type_i (void) const
00182 {
00183 return
00184 CORBA::TypeCode::_duplicate (
00185 Traits<StringType>::get_typecode (this->content_type_));
00186 }
00187
00188 TAO_END_VERSIONED_NAMESPACE_DECL
00189
00190 #endif