/* * StorageManager.cpp * * Copyright (C) 2009 Matthias Schiffer * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along * with this program. If not, see . */ #include "StorageManager.h" #include "StorageBackend.h" #include namespace Mad { namespace Common { void StorageManager::setBackend(boost::shared_ptr newBackend) { boost::lock_guard lock(mutex); backend = newBackend; } void StorageManager::unsetBackend(boost::shared_ptr oldBackend) { boost::lock_guard lock(mutex); if(backend == oldBackend) backend.reset(); } std::set StorageManager::listTypes() throw (Core::Exception) { boost::shared_lock lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); return backend->listTypes(); } std::set StorageManager::list(const Core::String &type) throw (Core::Exception) { boost::shared_lock lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); return backend->list(type); } bool StorageManager::exists(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::shared_lock lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); return backend->exists(type, name); } void StorageManager::store(const Core::String &type, const Core::String &name, const XmlData *data) throw (Core::Exception) { boost::shared_lock lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); backend->store(type, name, data); } boost::shared_ptr StorageManager::load(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::shared_lock lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); return backend->load(type, name); } void StorageManager::copy(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) { boost::shared_lock lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); backend->copy(type, name, newName); } void StorageManager::rename(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) { boost::shared_lock lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); backend->rename(type, name, newName); } void StorageManager::remove(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::shared_lock lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); backend->remove(type, name); } } }