00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022
00023 #ifndef H_SPK_REGWRAPPER
00024 #define H_SPK_REGWRAPPER
00025
00026 #include "Core/SPK_DEF.h"
00027 #include "Core/SPK_Registerable.h"
00028
00029
00030 namespace SPK
00031 {
00045 template<class T>
00046 class RegWrapper : public Registerable
00047 {
00048 SPK_IMPLEMENT_REGISTERABLE(RegWrapper<T>)
00049
00050 public :
00051
00053
00055
00060 RegWrapper<T>(const T& object = T());
00061
00068 static RegWrapper<T>* create(const T& object = T());
00069
00071
00073
00078 T& get();
00079
00084 const T& get() const;
00085
00086 private :
00087
00088 T object;
00089 };
00090
00091
00092 template<class T>
00093 inline RegWrapper<T>* RegWrapper<T>::create(const T& object)
00094 {
00095 RegWrapper<T>* obj = new RegWrapper<T>(object);
00096 registerObject(obj);
00097 return obj;
00098
00099 }
00100
00101 template<class T>
00102 inline T& RegWrapper<T>::get()
00103 {
00104 return object;
00105 }
00106
00107 template<class T>
00108 inline const T& RegWrapper<T>::get() const
00109 {
00110 return object;
00111 }
00112 }
00113
00114 #endif