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

/home/tetron/hack/vos/libs/vos/extensions/fspersist/fspersist.hh

Go to the documentation of this file.
00001 #ifndef _FSPERSIST_HH_
00002 #define _FSPERSIST_HH_
00003 
00004 #include <vos/vos/vos.hh>
00005 
00006 #if defined(WIN32)
00007 # ifdef FSPERSIST_EXPORTS
00008 #  define FSPERSIST_API __declspec(dllexport)
00009 # else
00010 #  define FSPERSIST_API __declspec(dllimport)
00011 # endif
00012 #else
00013 # ifdef HAVE_GCC_VISIBILITY
00014 #  define FSPERSIST_API __attribute__ ((visibility("default")))
00015 # else
00016 #  define FSPERSIST_API
00017 # endif
00018 #endif
00019 
00020 
00021 namespace VOS {
00022     class FSPERSIST_API FileSystemError : public std::runtime_error
00023     {
00024     public:
00025         FileSystemError(const std::string& s) : std::runtime_error(s) { };
00026     };
00027 
00028     class FSPERSIST_API FileSystemPersistance : public VobjectExtension, public SiteExtension, public Persistance
00029     {
00030     protected:
00031         std::string rootdir;
00032         bool readingDB;
00033 
00034         virtual void writeTypes(const std::string& dbpath, Vobject* vobj);
00035         virtual void writeDefaultPolicy(const std::string& dbpath, Vobject* vobj);
00036         virtual void writeACLs(const std::string& dbpath, Vobject* vobj);
00037         virtual void writeChildren(const std::string& dbpath, Vobject* vobj);
00038         virtual void readTypes(const char* dbpath, std::deque<std::string>& types);
00039         virtual void readDefaultPolicy(const char* dbpath, Vobject* obj);
00040         virtual void readACLs(const char* dbpath, Vobject* obj);
00041         virtual void readChildList(const char* dbpath, std::deque< std::pair<std::string, std::string> >& childlist);
00042 
00043     public:
00044         FileSystemPersistance(const std::string& dbpath);
00045 
00046         virtual void wipeDatabase();
00047 
00048         virtual void siteExtensionAttachedTo(Site* vb);
00049 
00050         virtual void destroy() { }
00051 
00052         virtual void post_createVobject(VobjectState& state, Vobject* requester, VobjectBase* newvobject);
00053         virtual void post_renameVobject(VobjectState& state, Vobject* requester,
00054                                         const std::string& oldname, const std::string& newname);
00055 
00056         virtual void post_addType(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00057                                   Vobject* requester, const std::string& s);
00058         virtual void post_removeType(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00059                                      Vobject* requester, const std::string& s);
00060         virtual void post_insertChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00061                                       Vobject* requester,
00062                                       int position, const std::string& contextual_name, Vobject* child);
00063         virtual void post_setChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00064                                    Vobject* requester,
00065                                    int position, const std::string& contextual_name, Vobject* child,
00066                                    const std::string& oldcontextual_name, Vobject* oldchild);
00067         virtual void post_removeChild(VobjectState& state, boost::recursive_mutex::scoped_lock& state_lock,
00068                                       Vobject* requester,
00069                                       ParentChildRelation* pcr,
00070                                       bool strict);
00071         virtual void post_addToACL(AccessControlState* acs, Vobject* requester, const std::string& ACLname, Vobject* id,
00072                                    const std::string& oldACLname);
00073         virtual void post_removeFromACL(AccessControlState* acs, Vobject* requester, const std::string& ACLname, Vobject* id);
00074         virtual void post_deleteACL(AccessControlState* acs, Vobject* requester,
00075                                     const std::string& policies, AccessControlList* oldacl);
00076         virtual void post_setDefaultPolicy(AccessControlState* acs, Vobject* requester, const std::string& policy,
00077                                            const std::string& oldpolicy);
00078 
00079         virtual void beginTransaction();
00080         virtual void endTransaction();
00081         virtual bool storeBlock(Vobject* from, const std::string& key, const std::string& data);
00082         virtual bool getBlock(Vobject* from, const std::string& key, std::string& data);
00083         virtual bool blockExists(Vobject* from, const std::string& key);
00084         virtual bool removeBlock(Vobject* from, const std::string& key);
00085         virtual bool isLoadingDB() { return readingDB; }
00086     };
00087 }
00088 
00089 #endif