db/simple: mount points

A SimpleDatabase instance can now "mount" other Database instances at
certain locations.  This is used to use a new SimpleDatabase instance
for each storage mount (issued with the "mount" protocol command).
Each such instance has its own database file, stored in the directory
that is specified with the "cache_directory" option.
This commit is contained in:
Max Kellermann
2014-02-26 08:39:44 +01:00
parent 2a16fc74fd
commit e9a85aa4e4
19 changed files with 603 additions and 24 deletions

View File

@@ -21,19 +21,30 @@
#define MPD_UPDATE_QUEUE_HXX
#include "check.h"
#include "Compiler.h"
#include <string>
#include <list>
class SimpleDatabase;
class Storage;
struct UpdateQueueItem {
SimpleDatabase *db;
Storage *storage;
std::string path_utf8;
unsigned id;
bool discard;
UpdateQueueItem():id(0) {}
UpdateQueueItem(const char *_path, bool _discard,
UpdateQueueItem(SimpleDatabase &_db,
Storage &_storage,
const char *_path, bool _discard,
unsigned _id)
:path_utf8(_path), id(_id), discard(_discard) {}
:db(&_db), storage(&_storage), path_utf8(_path),
id(_id), discard(_discard) {}
bool IsDefined() const {
return id != 0;
@@ -46,13 +57,21 @@ class UpdateQueue {
std::list<UpdateQueueItem> update_queue;
public:
bool Push(const char *path, bool discard, unsigned id);
gcc_nonnull_all
bool Push(SimpleDatabase &db, Storage &storage,
const char *path, bool discard, unsigned id);
UpdateQueueItem Pop();
void Clear() {
update_queue.clear();
}
gcc_nonnull_all
void Erase(SimpleDatabase &db);
gcc_nonnull_all
void Erase(Storage &storage);
};
#endif