00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TORC_GENERIC_OM_PARENTEDOBJECT_HPP
00017 #define TORC_GENERIC_OM_PARENTEDOBJECT_HPP
00018
00019 #include "torc/generic/om/DumpRestoreConfig.hpp"
00020
00021 #include <string>
00022
00023
00024 #include <boost/shared_ptr.hpp>
00025 #include <boost/weak_ptr.hpp>
00026 #ifdef GENOM_SERIALIZATION
00027 #include <boost/serialization/access.hpp>
00028 #include <boost/serialization/weak_ptr.hpp>
00029 #endif //GENOM_SERIALIZATION
00030
00031 namespace torc {
00032
00033 namespace generic {
00034
00035
00036
00037
00038
00039
00040 template<typename _ParentType>
00041 class ParentedObject {
00042
00043 #ifdef GENOM_SERIALIZATION
00044 friend class boost::serialization::access;
00045 #endif
00046
00047 protected:
00048 ParentedObject();
00049
00050
00051 public:
00052 virtual
00053 ~ParentedObject() throw();
00054
00055
00056 private:
00057 ParentedObject(const ParentedObject<_ParentType> & source) throw();
00058
00059 ParentedObject<_ParentType> &
00060 operator=(const ParentedObject<_ParentType> & source) throw();
00061
00062
00063 public:
00064
00065
00066
00067
00068
00069 inline const boost::shared_ptr<_ParentType>
00070 getParent() const throw();
00071
00072
00073
00074
00075
00076
00077 virtual void
00078 setParent(const boost::shared_ptr<_ParentType> & inSource) throw();
00079
00080 private:
00081 #ifdef GENOM_SERIALIZATION
00082 template<class Archive> void
00083 serialize( Archive &ar, unsigned int );
00084 #endif //GENOM_SERIALIZATION
00085
00086 boost::weak_ptr<_ParentType> mParent;
00087 };
00088
00089 template<typename _ParentType>
00090 ParentedObject<_ParentType>::ParentedObject()
00091 :mParent() {
00092 }
00093
00094 template<typename _ParentType>
00095 ParentedObject<_ParentType>::~ParentedObject() throw() {
00096 }
00097
00098
00099
00100
00101
00102
00103 template<typename _ParentType>
00104 inline const boost::shared_ptr<_ParentType>
00105 ParentedObject<_ParentType>::getParent() const throw() {
00106 return mParent.lock();
00107 }
00108
00109
00110
00111
00112
00113
00114 template<typename _ParentType>
00115 void
00116 ParentedObject<_ParentType>::setParent(
00117 const boost::shared_ptr<_ParentType> & inSource) throw() {
00118 mParent = inSource;
00119 }
00120
00121 #ifdef GENOM_SERIALIZATION
00122 template<typename _ParentType>
00123 template<class Archive> void
00124 ParentedObject<_ParentType>::serialize( Archive &ar, unsigned int ) {
00125 ar & mParent;
00126 }
00127 #endif //GENOM_SERIALIZATION
00128
00129 }
00130
00131 }
00132 #endif // TORC_GENERIC_OM_PARENTEDOBJECT_HPP