Go to the documentation of this file.00001
00002
00003 #include "tao/AnyTypeCode/Enum_TypeCode_Static.h"
00004 #include "tao/AnyTypeCode/TypeCode_Traits.h"
00005 #include "tao/ORB_Core.h"
00006 #include "tao/CDR.h"
00007 #include "tao/TypeCodeFactory_Adapter.h"
00008 #include "tao/SystemException.h"
00009
00010 #include "ace/Dynamic_Service.h"
00011
00012 #ifndef __ACE_INLINE__
00013 # include "tao/AnyTypeCode/Enum_TypeCode_Static.inl"
00014 #endif
00015
00016
00017 ACE_RCSID (AnyTypeCode,
00018 Enum_TypeCode_Static,
00019 "$Id: Enum_TypeCode_Static.cpp 85181 2009-04-28 07:00:58Z johnnyw $")
00020
00021 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00022
00023 bool
00024 TAO::TypeCode::Enum<char const *,
00025 char const * const *,
00026 TAO::Null_RefCount_Policy>::tao_marshal (
00027 TAO_OutputCDR & cdr,
00028 CORBA::ULong) const
00029 {
00030
00031
00032
00033
00034
00035
00036 TAO_OutputCDR enc;
00037
00038 bool const success =
00039 (enc << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))
00040 && (enc << TAO_OutputCDR::from_string (this->base_attributes_.id (), 0))
00041 && (enc << TAO_OutputCDR::from_string (this->base_attributes_.name (), 0))
00042 && (enc << this->nenumerators_);
00043
00044 if (!success)
00045 return false;
00046
00047 char const * const * const begin = &this->enumerators_[0];
00048 char const * const * const end = begin + this->nenumerators_;
00049
00050 for (char const * const * i = begin; i != end; ++i)
00051 {
00052 char const * const & enumerator = *i;
00053
00054 if (!(enc << TAO_OutputCDR::from_string (
00055 Traits<char const *>::get_string (enumerator), 0)))
00056 return false;
00057 }
00058
00059 return
00060 cdr << static_cast<CORBA::ULong> (enc.total_length ())
00061 && cdr.write_octet_array_mb (enc.begin ());
00062 }
00063
00064 void
00065 TAO::TypeCode::Enum<char const *,
00066 char const * const *,
00067 TAO::Null_RefCount_Policy>::tao_duplicate (void)
00068 {
00069 }
00070
00071 void
00072 TAO::TypeCode::Enum<char const *,
00073 char const * const *,
00074 TAO::Null_RefCount_Policy>::tao_release (void)
00075 {
00076 }
00077
00078 CORBA::Boolean
00079 TAO::TypeCode::Enum<char const *,
00080 char const * const *,
00081 TAO::Null_RefCount_Policy>::equal_i (
00082 CORBA::TypeCode_ptr tc
00083 ) const
00084 {
00085
00086
00087
00088
00089 CORBA::ULong const tc_nenumerators =
00090 tc->member_count ();
00091
00092 if (tc_nenumerators != this->nenumerators_)
00093 return false;
00094
00095 for (CORBA::ULong i = 0; i < this->nenumerators_; ++i)
00096 {
00097 char const * const & lhs_enumerator = this->enumerators_[i];
00098
00099 char const * const lhs_name =
00100 Traits<char const *>::get_string (lhs_enumerator);
00101 char const * const rhs_name = tc->member_name (i);
00102
00103 if (ACE_OS::strcmp (lhs_name, rhs_name) != 0)
00104 return false;
00105 }
00106
00107 return true;
00108 }
00109
00110 CORBA::Boolean
00111 TAO::TypeCode::Enum<char const *,
00112 char const * const *,
00113 TAO::Null_RefCount_Policy>::equivalent_i (
00114 CORBA::TypeCode_ptr tc
00115 ) const
00116 {
00117
00118
00119
00120 CORBA::ULong const tc_nenumerators =
00121 tc->member_count ();
00122
00123 if (tc_nenumerators != this->nenumerators_)
00124 return false;
00125
00126 return true;
00127 }
00128
00129 CORBA::TypeCode_ptr
00130 TAO::TypeCode::Enum<char const *,
00131 char const * const *,
00132 TAO::Null_RefCount_Policy>::get_compact_typecode_i (
00133 void) const
00134 {
00135 ACE_Array_Base<CORBA::String_var> tc_enumerators (this->nenumerators_);
00136
00137
00138
00139
00140 static char const empty_name[] = "";
00141
00142 for (CORBA::ULong i = 0; i < this->nenumerators_; ++i)
00143 {
00144
00145
00146
00147 tc_enumerators[i] = empty_name;
00148 }
00149
00150 TAO_TypeCodeFactory_Adapter * adapter =
00151 ACE_Dynamic_Service<TAO_TypeCodeFactory_Adapter>::instance (
00152 TAO_ORB_Core::typecodefactory_adapter_name ());
00153
00154 if (adapter == 0)
00155 {
00156 throw ::CORBA::INTERNAL ();
00157 }
00158
00159 return
00160 adapter->create_enum_tc (this->base_attributes_.id (),
00161 "" ,
00162 tc_enumerators,
00163 this->nenumerators_
00164 );
00165 }
00166
00167 char const *
00168 TAO::TypeCode::Enum<char const *,
00169 char const * const *,
00170 TAO::Null_RefCount_Policy>::id_i (
00171 void) const
00172 {
00173
00174
00175 return this->base_attributes_.id ();
00176 }
00177
00178 char const *
00179 TAO::TypeCode::Enum<char const *,
00180 char const * const *,
00181 TAO::Null_RefCount_Policy>::name_i (
00182 void) const
00183 {
00184
00185
00186 return this->base_attributes_.name ();
00187 }
00188
00189 CORBA::ULong
00190 TAO::TypeCode::Enum<char const *,
00191 char const * const *,
00192 TAO::Null_RefCount_Policy>::member_count_i (
00193 void) const
00194 {
00195 return this->nenumerators_;
00196 }
00197
00198 char const *
00199 TAO::TypeCode::Enum<char const *,
00200 char const * const *,
00201 TAO::Null_RefCount_Policy>::member_name_i (
00202 CORBA::ULong index
00203 ) const
00204 {
00205
00206
00207 if (index >= this->nenumerators_)
00208 throw ::CORBA::TypeCode::Bounds ();
00209
00210 return Traits<char const *>::get_string (this->enumerators_[index]);
00211 }
00212
00213 TAO_END_VERSIONED_NAMESPACE_DECL