00001 #ifndef _IT_REFLECT_VALUE_IMPL_T_CXX_
00002 #define _IT_REFLECT_VALUE_IMPL_T_CXX_
00003
00004
00005
00006
00007 #include <it_bus/reflect/value.h>
00008 #include <it_bus/schema_type_traits.h>
00009 #include <it_bus/any_simple_type.h>
00010 #include <it_bus/any_simple_type_reader.h>
00011 #include <it_bus/any_simple_type_writer.h>
00012 #include <it_bus/complex_type_reader.h>
00013 #include <it_bus/complex_type_writer.h>
00014
00015 namespace IT_Reflect
00016 {
00018 template <class T>
00019 class ValueImplT :
00020 public IT_Reflect::Value<T>,
00021 public IT_Bus::AnySimpleType
00022 {
00023 public:
00027 ValueImplT() throw(());
00028
00032 ValueImplT(
00033 const T& value
00034 ) throw(());
00035
00039 ~ValueImplT() throw(());
00040
00041 ValueImplT&
00042 operator= (
00043 const T& value
00044 ) throw(());
00045
00046 operator T&() throw(());
00047
00048 operator const T&() const throw(());
00049
00050 virtual const T&
00051 get_value() const throw(());
00052
00053 virtual T&
00054 get_value() throw(());
00055
00056 virtual void
00057 set_value(
00058 const T& value
00059 ) throw(());
00060
00061 virtual const IT_Bus::QName&
00062 get_type_name() const throw(());
00063
00064 virtual IT_Bus::AnyType::Kind
00065 get_type_kind() const throw(());
00066
00067 BuiltInType::ValueKind
00068 get_value_kind() const throw(());
00069
00070 virtual IT_Bus::AnyType*
00071 clone() const throw((ReflectException));
00072
00073 virtual const IT_Bus::AnyType&
00074 get_reflected() const throw(());
00075
00076 virtual IT_Bus::AnyType&
00077 get_reflected() throw(());
00078
00083 void
00084 copy(
00085 const IT_Reflect::BuiltInType* other
00086 ) throw((ReflectException));
00087
00092 virtual IT_Bus::Boolean
00093 equals(
00094 const IT_Reflect::BuiltInType* other
00095 ) const throw(());
00096
00097
00098
00099
00100
00101 virtual const IT_Bus::QName&
00102 get_type() const;
00103
00104 virtual AnyType::Kind
00105 get_kind() const;
00106
00107 virtual IT_Reflect::Reflection*
00108 get_reflection() throw(());
00109
00110 virtual const IT_Reflect::Reflection*
00111 get_reflection() const throw(());
00112
00113 virtual void
00114 read(
00115 const IT_Bus::QName& name,
00116 IT_Bus::ComplexTypeReader& reader
00117 ) throw((IT_Bus::DeserializationException));
00118
00119 virtual void
00120 write(
00121 const IT_Bus::QName& name,
00122 IT_Bus::ComplexTypeWriter& writer
00123 ) const throw((IT_Bus::SerializationException));
00124
00125 virtual void
00126 read_value(
00127 IT_Bus::AnySimpleTypeReader& reader
00128 ) throw((IT_Bus::DeserializationException));
00129
00130 virtual void
00131 write_value(
00132 IT_Bus::AnySimpleTypeWriter& writer
00133 ) const throw((IT_Bus::SerializationException));
00134
00135 virtual
00136 IT_Bus::AnyType&
00137 copy(
00138 const IT_Bus::AnyType & rhs
00139 );
00140
00141 private:
00142 T m_data;
00143 };
00144
00145
00146
00147
00148
00149 template <class T>
00150 ValueImplT<T>::ValueImplT() throw(())
00151 {
00152
00153 }
00154
00155 template <class T>
00156 ValueImplT<T>::ValueImplT(
00157 const T& value
00158 ) throw(())
00159 :
00160 m_data(IT_CONST_CAST(T&, value))
00161 {
00162
00163 }
00164
00165 template <class T>
00166 ValueImplT<T>::~ValueImplT() throw(())
00167 {
00168
00169 }
00170
00171 template <class T>
00172 ValueImplT<T>&
00173 ValueImplT<T>::operator=(
00174 const T& data
00175 ) throw(())
00176 {
00177 m_data = data;
00178 return *this;
00179 }
00180
00181 template <class T>
00182 ValueImplT<T>::operator T&() throw(())
00183 {
00184 return m_data;
00185 }
00186
00187 template <class T>
00188 ValueImplT<T>::operator const T&() const throw(())
00189 {
00190 return m_data;
00191 }
00192
00193 template <class T>
00194 const T&
00195 ValueImplT<T>::get_value() const throw(())
00196 {
00197 return m_data;
00198 }
00199
00200 template <class T>
00201 T&
00202 ValueImplT<T>::get_value() throw(())
00203 {
00204 return m_data;
00205 }
00206
00207 template <class T>
00208 void
00209 ValueImplT<T>::set_value(
00210 const T& value
00211 ) throw(())
00212 {
00213 m_data = value;
00214 }
00215
00216 template <class T>
00217 const IT_Bus::QName&
00218 ValueImplT<T>::get_type_name(
00219 ) const throw(())
00220 {
00221 return IT_Bus::SchemaTypeTraits<T>::type_name();
00222 }
00223
00224 template <class T>
00225 IT_Bus::AnyType::Kind
00226 ValueImplT<T>::get_type_kind(
00227 ) const throw(())
00228 {
00229 return IT_Bus::AnyType::BUILT_IN;
00230 }
00231
00232 template <class T>
00233 const IT_Bus::AnyType&
00234 ValueImplT<T>::get_reflected() const throw(())
00235 {
00236 return *this;
00237 }
00238
00239 template <class T>
00240 IT_Bus::AnyType&
00241 ValueImplT<T>::get_reflected() throw(())
00242 {
00243 return *this;
00244 }
00245
00246 template <class T>
00247 IT_Bus::AnyType*
00248 ValueImplT<T>::clone() const throw((ReflectException))
00249 {
00250 return new ValueImplT<T>(m_data);
00251 }
00252
00253
00254
00255 template <class T>
00256 const IT_Bus::QName&
00257 ValueImplT<T>::get_type() const
00258 {
00259 return IT_Bus::SchemaTypeTraits<T>::type_name();
00260 }
00261
00262 template <class T>
00263 IT_Bus::AnyType::Kind
00264 ValueImplT<T>::get_kind(
00265 ) const
00266 {
00267 return IT_Bus::AnyType::BUILT_IN;
00268 }
00269
00270 template <class T>
00271 IT_Reflect::Reflection*
00272 ValueImplT<T>::get_reflection() throw(())
00273 {
00274 this->_add_ref();
00275 return this;
00276 }
00277
00278 template <class T>
00279 const IT_Reflect::Reflection*
00280 ValueImplT<T>::get_reflection() const throw(())
00281 {
00282 this->_add_ref();
00283 return this;
00284 }
00285
00286 template <class T>
00287 void
00288 ValueImplT<T>::read(
00289 const IT_Bus::QName& name,
00290 IT_Bus::ComplexTypeReader& reader
00291 ) throw((IT_Bus::DeserializationException))
00292 {
00293 reader.read(name, this->m_data);
00294 }
00295
00296 template <class T>
00297 void
00298 ValueImplT<T>::write(
00299 const IT_Bus::QName& name,
00300 IT_Bus::ComplexTypeWriter& writer
00301 ) const throw((IT_Bus::SerializationException))
00302 {
00303 writer.write(name, this->m_data);
00304 }
00305
00306 template <class T>
00307 void
00308 ValueImplT<T>::read_value(
00309 IT_Bus::AnySimpleTypeReader& reader
00310 ) throw((IT_Bus::DeserializationException))
00311 {
00312 reader.read(this->m_data);
00313 }
00314
00315 template <class T>
00316 void
00317 ValueImplT<T>::write_value(
00318 IT_Bus::AnySimpleTypeWriter& writer
00319 ) const throw((IT_Bus::SerializationException))
00320 {
00321 writer.write(this->m_data);
00322 }
00323
00324 template <class T>
00325 IT_Bus::AnyType&
00326 ValueImplT<T>::copy(
00327 const IT_Bus::AnyType & rhs
00328 )
00329 {
00330 m_data = IT_DYNAMIC_CAST(const ValueImplT<T>&, rhs).m_data;
00331 return *this;
00332 }
00333
00334 template <class T>
00335 void
00336 ValueImplT<T>::copy(
00337 const IT_Reflect::BuiltInType* other
00338 ) throw((ReflectException))
00339 {
00340 const IT_Reflect::Value<T>* value =
00341 IT_DYNAMIC_CAST(const IT_Reflect::Value<T>*, other);
00342 if (value == 0)
00343 {
00344 throw ReflectException(get_type_name(), other->get_type_name());
00345 }
00346 this->m_data = value->get_value();
00347 }
00348
00349 template <class T>
00350 IT_Bus::Boolean
00351 ValueImplT<T>::equals(
00352 const IT_Reflect::BuiltInType* other
00353 ) const throw(())
00354 {
00355 const IT_Reflect::Value<T>* value =
00356 IT_DYNAMIC_CAST(const IT_Reflect::Value<T>*, other);
00357 if (value == 0)
00358 {
00359 return IT_FALSE;
00360 }
00361 return this->m_data == value->get_value();
00362 }
00363
00364 template <class T>
00365 BuiltInType::ValueKind
00366 ValueImplT<T>::get_value_kind() const throw(())
00367 {
00368 return BuiltInType::ValueKind(IT_Bus::SchemaTypeTraits<T>::value_kind);
00369 }
00370 }
00371
00372 #endif