it_bus/reflect/nillable_ptr_impl_t.h

00001 #ifndef _IT_REFLECT_NILLABLE_PTR_IMPL_T_H_
00002 #define _IT_REFLECT_NILLABLE_PTR_IMPL_T_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 
00007 #include <it_bus/reflect/nillable.h>
00008 #include <it_bus/reflect/reflection_impl.h>
00009 
00010 namespace IT_Reflect
00011 
00012 {
00016     template <class NillableT, class T>
00017     class NillablePtrImplT : public virtual ReflectionImpl
00018     {
00019       public:
00024         NillablePtrImplT(
00025             const NillableT* data
00026         ) IT_THROW_DECL(());
00027 
00031         virtual ~NillablePtrImplT() IT_THROW_DECL(());
00032 
00037         virtual IT_Bus::Boolean
00038         get_is_nil() const IT_THROW_DECL(());
00039 
00044         virtual void
00045         set_is_nil() IT_THROW_DECL(());
00046         
00051         virtual const Reflection*
00052         get_value() const IT_THROW_DECL((ReflectException));
00053 
00059         virtual Reflection*
00060         use_value() IT_THROW_DECL((ReflectException));
00061         
00067         virtual IT_Bus::AnyType*
00068         clone() const IT_THROW_DECL(());
00069 
00074         void reset(
00075             T* value
00076         );
00077 
00078       protected:
00084         IT_Bus::AnyType&
00085         get_data() const IT_THROW_DECL(());
00086 
00087       private:
00088         NillableT* m_data;
00089     };
00090     
00091 
00092     template <class NillableT, class T>
00093     NillablePtrImplT<NillableT, T>::NillablePtrImplT(
00094         const NillableT* data
00095     ) IT_THROW_DECL(())
00096         :
00097         m_data(data)
00098     {
00099         // Complete.
00100     }
00101 
00102     template <class NillableT, class T>
00103     NillablePtrImplT<NillableT, T>::~NillablePtrImplT(
00104     ) IT_THROW_DECL(())
00105     {
00106         // Complete.
00107     }
00108 
00109     template <class NillableT, class T>
00110     IT_Bus::Boolean
00111     NillablePtrImplT<NillableT, T>::get_is_nil(
00112     ) const IT_THROW_DECL(())
00113     {
00114         return this->m_data->is_nil();
00115     }
00116 
00117     template <class NillableT, class T>
00118     void
00119     NillablePtrImplT<NillableT, T>::set_is_nil(
00120     ) IT_THROW_DECL(())
00121     {
00122         this->m_data->set_nil();
00123     }
00124 
00125     template <class NillableT, class T>
00126     const Reflection*
00127     NillablePtrImplT<NillableT, T>::get_value(
00128     ) const IT_THROW_DECL((ReflectException))
00129     {
00130         return get_is_nil() ?
00131             0 : Traits<T>::get_reflection(*this->m_data->get());
00132     }
00133 
00134     template <class NillableT, class T>
00135     Reflection*
00136     NillablePtrImplT<NillableT, T>::use_value(
00137     ) IT_THROW_DECL((ReflectException))
00138     {
00139         if (get_is_nil())
00140         {
00141             this->m_data->reset(new T);
00142         }
00143         return Traits<T>::get_reflection(*this->m_data->get());
00144     }
00145 
00146     template <class NillableT, class T>
00147     IT_Bus::AnyType*
00148     NillablePtrImplT<NillableT,T>::clone() const IT_THROW_DECL(())
00149     {
00150         return new NillableT(*m_data);
00151     }
00152     
00153     template <class NillableT, class T>
00154     void
00155     NillablePtrImplT<NillableT,T>::reset(
00156         T* value
00157     )
00158     {
00159         m_data = value;
00160     }
00161     
00162     template <class NillableT, class T>
00163     IT_Bus::AnyType&
00164     NillablePtrImplT<NillableT,T>::get_data() const IT_THROW_DECL(())
00165     {
00166         return *m_data;
00167     }
00168 }
00169 
00170 
00171 #endif  

Generated on Thu Sep 7 11:39:01 2006 for Artix by  doxygen 1.4.7