00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OWNABLE_H
00021 #define OWNABLE_H
00022
00023 #include "worldsimconfig.h"
00024 #include <QList>
00025
00026 namespace farsa {
00027
00037 class FARSA_WSIM_API Ownable
00038 {
00039 public:
00046 struct Owned {
00054 Owned(Ownable *o, bool d = true) :
00055 object(o),
00056 destroy(d)
00057 {
00058 }
00059
00066 bool operator==(const Owned& other)
00067 {
00068 return (object == other.object);
00069 }
00070
00074 Ownable *object;
00075
00080 bool destroy;
00081 };
00082
00086 typedef QList<Owned> OwnedList;
00087
00088 public:
00092 Ownable();
00093
00099 virtual ~Ownable();
00100
00108 void setOwner(Ownable *owner, bool destroy = true);
00109
00115 Ownable* owner() const
00116 {
00117 return m_owner;
00118 }
00119
00125 const QList<Owned>& owned() const
00126 {
00127 return m_owned;
00128 }
00129
00130 private:
00138 void addToOwned(Ownable *obj, bool destroy);
00139
00145 void removeFromOwned(Ownable *obj);
00146
00150 Ownable* m_owner;
00151
00155 QList<Owned> m_owned;
00156 };
00157
00158 }
00159
00160 #endif