/home/tetron/hack/vos/libs/vos/vos/vobjectstate.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _VOBJECTSTATE_HH_
00025 #define _VOBJECTSTATE_HH_
00026
00027
00028
00029
00030
00031 #include <deque>
00032 #include <stdexcept>
00033 #include <boost/thread/recursive_mutex.hpp>
00034
00035 #include <vos/vutil/refcount.hh>
00036 #include <vos/vutil/url.hh>
00037 #include <vos/vutil/log.hh>
00038 #include <vos/vos/listener.hh>
00039 #include <vos/vos/parentchildrel.hh>
00040
00041
00042 namespace VOS
00043 {
00044 class Site;
00045 class Message;
00046 class MessageBlock;
00047 class TypeChangeListener;
00048 class ParentChangeListener;
00049 class ChildChangeListener;
00050 class ParentChildRelation;
00051 class VobjectBase;
00052 class VobjectEvent;
00053
00054 class PCRIterator;
00055 typedef PCRIterator ChildListIterator;
00056 typedef PCRIterator ParentSetIterator;
00057 class StringIterator;
00058 typedef StringIterator TypeSetIterator;
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 class VOS_API VobjectState
00073 {
00074 public:
00075 typedef std::set<ParentChildRelation*> ParentSet;
00076 typedef std::deque<ParentChildRelation*> ChildList;
00077 typedef std::set<std::string> TypeSet;
00078 private:
00079 VobjectBase* myvobject;
00080
00081 ParentSet parents;
00082
00083 ChildList children;
00084 std::map<std::string, ParentChildRelation*> children_map;
00085
00086 TypeSet types;
00087
00088 void adjustChildMap(ParentChildRelation* pcr, int ofs);
00089 public:
00090 boost::recursive_mutex state_mutex;
00091
00092 VUtil::ListenerBase<TypeChangeListener, VobjectEvent> typeListeners;
00093 VUtil::ListenerBase<ParentChangeListener, VobjectEvent> parentListeners;
00094 VUtil::ListenerBase<ChildChangeListener, VobjectEvent> childListeners;
00095
00096 VobjectState(VobjectBase* myvobject);
00097 ~VobjectState();
00098
00099 VUtil::vRef<VobjectBase> getBase();
00100
00101 void addType(const std::string& s);
00102 void removeType(const std::string& s);
00103 TypeSetIterator getTypes();
00104
00105 int numChildren();
00106 void insertChild(int pos, const std::string& c, Vobject* vobj);
00107 void setChild(int pos, const std::string& c, Vobject* vobj);
00108 void removeChild(int pos);
00109 void fixPosition(int& pos, int forinsert = 0);
00110
00111 bool hasChild(const std::string& c);
00112 bool hasChild(int pos);
00113
00114 VUtil::vRef<ParentChildRelation> findChild(int pos);
00115 VUtil::vRef<ParentChildRelation> findChild(const std::string& c);
00116 ChildListIterator getChildren(int start = 0, int end = -1);
00117 void clearChildren();
00118
00119 ParentSetIterator getParents();
00120 VUtil::vRef<ParentChildRelation> findParent(Vobject& parent);
00121 VUtil::vRef<ParentChildRelation> findParent(Vobject* parent);
00122 void addParent(ParentChildRelation* pcr);
00123 void removeParent(ParentChildRelation* pcr);
00124 };
00125 }
00126
00127 #endif
00128