interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

/home/tetron/hack/vos/libs/vos/extensions/revcontrol/versioned.hh

Go to the documentation of this file.
00001 #ifndef _VERSIONED_HH_
00002 #define _VERSIONED_HH_
00003 
00004 #include <vos/vos/vos.hh>
00005 #include <vos/extensions/revcontrol/revdefs.hh>
00006 #include <vos/extensions/revcontrol/changelog.hh>
00007 
00008 #ifndef VERSIONED_EXPORTS
00009 IMPORT_METAOBJECT_FACTORIES(VersionedVobject)
00010 #endif
00011 
00012 namespace VOS {
00013     struct Conflict
00014     {
00015         VUtil::vRef<Vobject> vobject;
00016         std::string block;
00017         std::string message;
00018         std::string headversion;
00019         std::string localversion;
00020         std::string mergedversion;
00021     };
00022 
00023     struct Status
00024     {
00025         VUtil::vRef<Vobject> vobject;
00026         bool modified;
00027         std::string block;
00028         std::string timestamp;
00029         int version;
00030     };
00031 
00032     class VERSIONED_API VersionedVobject : public MetaObject, public VobjectExtension,
00033                              public SiteExtension, public PersistBlockListener
00034     {
00035     private:
00036         int version;
00037         std::string timestamp;
00038         std::map<std::string, bool> modified;
00039         Persistance* persist;
00040         ChangeLog* log;
00041         bool doingUpdate;
00042 
00043         void mergeChildren(const std::string& data, int headversion, std::vector<Conflict>& conflicts);
00044         void mergeACLs(const std::string& data, int headversion, std::vector<Conflict>& conflicts);
00045         void mergeDefaultPolicy(const std::string& data, int headversion, std::vector<Conflict>& conflicts);
00046         void mergeTypes(const std::string& data, int headversion, std::vector<Conflict>& conflicts);
00047         void mergeBlock(const std::string& key, const std::string& data, int headversion, std::vector<Conflict>& conflicts);
00048 
00049     public:
00050         VersionedVobject(VobjectBase* superobject);
00051 
00052         static MetaObject* new_VersionedVobject(VobjectBase* superobject, const std::string& type);
00053 
00054         int getVersion() { return version; }
00055 
00056         VUtil::vRef<Site> getRepository();
00057 
00058         virtual void update(std::vector<Conflict>& conflicts, int version = -1);
00059         virtual void update(std::vector<Conflict>& conflicts, std::string tag);
00060         virtual void update(Site* rvv, std::vector<Conflict>& conflicts, int version = -1);
00061         virtual void update(Site* rvv, std::vector<Conflict>& conflicts, std::string tag);
00062 
00063         virtual void commit(std::string comment);
00064         virtual void commit(Site* rvv, std::string comment);
00065 
00066         virtual void tagVersion(std::string tagname, std::string comment, int version = -1);
00067         virtual void tagVersion(Site* rvv, std::string tagname, std::string comment, int version = -1);
00068 
00069         const std::string getVOSType();
00070 
00071         void getStatus(std::vector<Status>& stat);
00072         void writeStatus();
00073 
00074         virtual void destroy() { }
00075 
00076         virtual void notifyBlockChanging(const std::string& key, const std::string& data);
00077         virtual void notifyBlockChanged(const std::string& key, const std::string& data);
00078 
00079         virtual void post_createVobject(VobjectState& state, Vobject* requester, VobjectBase* newvobject);
00080         virtual void post_renameVobject(VobjectState& state, Vobject* requester,
00081                                         const std::string& oldname, const std::string& newname);
00082 
00083         virtual bool pre_addType(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00084                                  Vobject* requester, const std::string& s);
00085         virtual void post_addType(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00086                                   Vobject* requester, const std::string& s);
00087 
00088         virtual bool pre_removeType(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00089                                      Vobject* requester, const std::string& s);
00090         virtual void post_removeType(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00091                                      Vobject* requester, const std::string& s);
00092 
00093         virtual bool pre_insertChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00094                                       Vobject* requester,
00095                                       int position, const std::string& contextual_name, Vobject* child);
00096         virtual void post_insertChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00097                                       Vobject* requester,
00098                                       int position, const std::string& contextual_name, Vobject* child);
00099 
00100         virtual bool pre_setChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00101                                    Vobject* requester,
00102                                    int position, const std::string& contextual_name, Vobject* child);
00103         virtual void post_setChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00104                                    Vobject* requester,
00105                                    int position, const std::string& contextual_name, Vobject* child,
00106                                    const std::string& oldcontextual_name, Vobject* oldchild);
00107 
00108         virtual bool pre_removeChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00109                                       Vobject* requester,
00110                                       ParentChildRelation* pcr,
00111                                      bool strict);
00112         virtual void post_removeChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00113                                       Vobject* requester,
00114                                       ParentChildRelation* pcr,
00115                                       bool strict);
00116 
00117         virtual bool pre_addToACL(AccessControlState* acs, Vobject* requester, const std::string& ACLname, Vobject* id);
00118         virtual void post_addToACL(AccessControlState* acs, Vobject* requester, const std::string& ACLname, Vobject* id,
00119                                    const std::string& oldACLname);
00120 
00121         virtual bool pre_removeFromACL(AccessControlState* acs, Vobject* requester, const std::string& ACLname, Vobject* id);
00122         virtual void post_removeFromACL(AccessControlState* acs, Vobject* requester, const std::string& ACLname, Vobject* id);
00123 
00124         virtual bool pre_deleteACL(AccessControlState* acs, Vobject* requester, std::string& policies);
00125         virtual void post_deleteACL(AccessControlState* acs, Vobject* requester, std::string& policies,
00126                                     AccessControlList* oldacl);
00127 
00128         virtual bool pre_setDefaultPolicy(AccessControlState* acs, Vobject* requester, const std::string& policy);
00129         virtual void post_setDefaultPolicy(AccessControlState* acs, Vobject* requester, const std::string& policy,
00130                                            const std::string& oldpolicy);
00131 
00132         void storeOriginalChildren();
00133         void storeOriginalDefaultPolicy();
00134         void storeOriginalTypes();
00135         void storeOriginalACLs();
00136     };
00137 }
00138 
00139 #endif