00001 #ifndef _IT_REFLECT_VALUE_REF_CXX_
00002 #define _IT_REFLECT_VALUE_REF_CXX_
00003
00004
00005
00006
00007 #include <it_bus/reflect/value_ref_base.h>
00008 #include <it_bus/any_simple_type.h>
00009 #include <it_bus/any_simple_type_reader.h>
00010 #include <it_bus/any_simple_type_writer.h>
00011 #include <it_bus/complex_type_reader.h>
00012 #include <it_bus/complex_type_writer.h>
00013
00014 namespace IT_Reflect
00015 {
00022 template <class T>
00023 class ValueRef :
00024 public IT_Reflect::ValueRefBase<T>,
00025 public IT_Bus::AnySimpleType
00026 {
00027 public:
00031 ValueRef(
00032 const T& value
00033 ) IT_THROW_DECL(());
00034
00038 ValueRef(
00039 const T* value
00040 ) IT_THROW_DECL(());
00041
00045 ~ValueRef() IT_THROW_DECL(());
00046
00047 virtual const IT_Bus::AnyType&
00048 get_reflected() const IT_THROW_DECL(());
00049
00050 virtual IT_Bus::AnyType&
00051 get_reflected() IT_THROW_DECL(());
00052
00053
00054
00055
00056 virtual const IT_Bus::QName&
00057 get_type() const;
00058
00059 virtual AnyType::Kind
00060 get_kind() const;
00061
00062 virtual IT_Reflect::Reflection*
00063 get_reflection() IT_THROW_DECL(());
00064
00065 virtual const IT_Reflect::Reflection*
00066 get_reflection() const IT_THROW_DECL(());
00067
00068 virtual void
00069 read(
00070 const IT_Bus::QName& name,
00071 IT_Bus::ComplexTypeReader& reader
00072 ) IT_THROW_DECL((IT_Bus::DeserializationException));
00073
00074 virtual void
00075 write(
00076 const IT_Bus::QName& name,
00077 IT_Bus::ComplexTypeWriter& writer
00078 ) const IT_THROW_DECL((IT_Bus::SerializationException));
00079
00080 virtual void
00081 read_value(
00082 IT_Bus::AnySimpleTypeReader& reader
00083 ) IT_THROW_DECL((IT_Bus::DeserializationException));
00084
00085 virtual void
00086 write_value(
00087 IT_Bus::AnySimpleTypeWriter& writer
00088 ) const IT_THROW_DECL((IT_Bus::SerializationException));
00089
00090 virtual
00091 IT_Bus::AnyType&
00092 copy(
00093 const IT_Bus::AnyType & rhs
00094 );
00095
00101 virtual IT_Bus::AnyType*
00102 clone() const IT_THROW_DECL((ReflectException));
00103 };
00104
00105
00106
00107
00108
00109 template <class T>
00110 ValueRef<T>::ValueRef(
00111 const T& value
00112 ) IT_THROW_DECL(())
00113 :
00114 ValueRefBase<T>(IT_CONST_CAST(T*, &value))
00115 {
00116
00117 }
00118
00119 template <class T>
00120 ValueRef<T>::ValueRef(
00121 const T* value
00122 ) IT_THROW_DECL(())
00123 :
00124 ValueRefBase<T>(IT_CONST_CAST(T*, value))
00125 {
00126
00127 }
00128
00129 template <class T>
00130 ValueRef<T>::~ValueRef() IT_THROW_DECL(())
00131 {
00132
00133 }
00134
00135 template <class T>
00136 const IT_Bus::AnyType&
00137 ValueRef<T>::get_reflected() const IT_THROW_DECL(())
00138 {
00139 return *this;
00140 }
00141
00142 template <class T>
00143 IT_Bus::AnyType&
00144 ValueRef<T>::get_reflected() IT_THROW_DECL(())
00145 {
00146 return *this;
00147 }
00148
00149
00150
00151
00152 template <class T>
00153 const IT_Bus::QName&
00154 ValueRef<T>::get_type() const
00155 {
00156 return IT_Bus::SchemaTypeTraits<T>::type_name();
00157 }
00158
00159 template <class T>
00160 IT_Bus::AnyType::Kind
00161 ValueRef<T>::get_kind(
00162 ) const
00163 {
00164 return IT_Bus::AnyType::BUILT_IN;
00165 }
00166
00167 template <class T>
00168 IT_Reflect::Reflection*
00169 ValueRef<T>::get_reflection() IT_THROW_DECL(())
00170 {
00171 this->_add_ref();
00172 return this;
00173 }
00174
00175 template <class T>
00176 const IT_Reflect::Reflection*
00177 ValueRef<T>::get_reflection() const IT_THROW_DECL(())
00178 {
00179 this->_add_ref();
00180 return this;
00181 }
00182
00183 template <class T>
00184 void
00185 ValueRef<T>::read(
00186 const IT_Bus::QName& name,
00187 IT_Bus::ComplexTypeReader& reader
00188 ) IT_THROW_DECL((IT_Bus::DeserializationException))
00189 {
00190 reader.read(name, *this->m_value);
00191 }
00192
00193 template <class T>
00194 void
00195 ValueRef<T>::write(
00196 const IT_Bus::QName& name,
00197 IT_Bus::ComplexTypeWriter& writer
00198 ) const IT_THROW_DECL((IT_Bus::SerializationException))
00199 {
00200 writer.write(name, *this->m_value);
00201 }
00202
00203 template <class T>
00204 void
00205 ValueRef<T>::read_value(
00206 IT_Bus::AnySimpleTypeReader& reader
00207 ) IT_THROW_DECL((IT_Bus::DeserializationException))
00208 {
00209 reader.read(*this->m_value);
00210 }
00211
00212 template <class T>
00213 void
00214 ValueRef<T>::write_value(
00215 IT_Bus::AnySimpleTypeWriter& writer
00216 ) const IT_THROW_DECL((IT_Bus::SerializationException))
00217 {
00218 writer.write(*this->m_value);
00219 }
00220
00221 template <class T>
00222 IT_Bus::AnyType&
00223 ValueRef<T>::copy(
00224 const IT_Bus::AnyType & rhs
00225 )
00226 {
00227 const ValueRef<T>* other = IT_DYNAMIC_CAST(const ValueRef<T>*, &rhs);
00228 if (other)
00229 {
00230 *this->m_value = *other->m_value;
00231 }
00232 return *this;
00233 }
00234
00235 template <class T>
00236 IT_Bus::AnyType*
00237 ValueRef<T>::clone() const IT_THROW_DECL((ReflectException))
00238 {
00239 return new ValueRef<T>(this->m_value);
00240 }
00241 }
00242
00243 #endif