diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-09-13 19:04:14 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-09-13 19:04:14 +0200 |
commit | 7f4f260d732c849c1e88fcb91023faab5316d9c6 (patch) | |
tree | f58ad5026eee9cb0c2c8e8742147f29404cdd721 /src/Common | |
parent | 09b8df5200de1c8c20ea2856a8c6aa76b0811bd1 (diff) | |
download | mad-7f4f260d732c849c1e88fcb91023faab5316d9c6.tar mad-7f4f260d732c849c1e88fcb91023faab5316d9c6.zip |
StorageManager can delete stored data now
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/StorageBackend.h | 6 | ||||
-rw-r--r-- | src/Common/StorageManager.cpp | 16 | ||||
-rw-r--r-- | src/Common/StorageManager.h | 4 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/Common/StorageBackend.h b/src/Common/StorageBackend.h index 1d53570..abec185 100644 --- a/src/Common/StorageBackend.h +++ b/src/Common/StorageBackend.h @@ -38,9 +38,15 @@ class StorageBackend { virtual std::set<std::string> listTypes() throw (Core::Exception) = 0; virtual std::set<std::string> list(const std::string &type) throw (Core::Exception) = 0; + virtual bool exists(const std::string &type, const std::string &name) throw (Core::Exception) { + return (list(type).count(name) > 0); + } + virtual void store(const std::string &type, const std::string &name, const XmlData *data) throw (Core::Exception) = 0; virtual boost::shared_ptr<XmlData> load(const std::string &type, const std::string &name) throw (Core::Exception) = 0; + virtual void remove(const std::string &type, const std::string &name) throw (Core::Exception) = 0; + public: virtual ~StorageBackend() {} }; diff --git a/src/Common/StorageManager.cpp b/src/Common/StorageManager.cpp index ac83476..3b14554 100644 --- a/src/Common/StorageManager.cpp +++ b/src/Common/StorageManager.cpp @@ -52,6 +52,14 @@ std::set<std::string> StorageManager::list(const std::string &type) throw (Core: return backend->list(type); } +bool StorageManager::exists(const std::string &type, const std::string &name) throw (Core::Exception) { + boost::shared_lock<boost::shared_mutex> lock(mutex); + if(!backend) + throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); + + return backend->exists(type, name); +} + void StorageManager::store(const std::string &type, const std::string &name, const XmlData *data) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) @@ -68,5 +76,13 @@ boost::shared_ptr<XmlData> StorageManager::load(const std::string &type, const s return backend->load(type, name); } +void StorageManager::remove(const std::string &type, const std::string &name) throw (Core::Exception) { + boost::shared_lock<boost::shared_mutex> lock(mutex); + if(!backend) + throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); + + backend->remove(type, name); +} + } } diff --git a/src/Common/StorageManager.h b/src/Common/StorageManager.h index 98533fb..594c294 100644 --- a/src/Common/StorageManager.h +++ b/src/Common/StorageManager.h @@ -54,8 +54,12 @@ class MAD_COMMON_EXPORT StorageManager { std::set<std::string> listTypes() throw (Core::Exception); std::set<std::string> list(const std::string &type) throw (Core::Exception); + bool exists(const std::string &type, const std::string &name) throw (Core::Exception); + void store(const std::string &type, const std::string &name, const XmlData *data) throw (Core::Exception); boost::shared_ptr<XmlData> load(const std::string &type, const std::string &name) throw (Core::Exception); + + void remove(const std::string &type, const std::string &name) throw (Core::Exception); }; } |