aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/plugins/simple/SimpleDatabasePlugin.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-26 08:39:44 +0100
committerMax Kellermann <max@duempel.org>2014-02-27 20:49:13 +0100
commite9a85aa4e4d0634548b5c97461beb27ae5559338 (patch)
tree7cdfdd0ae0d990a8adbecc34f32d073627483205 /src/db/plugins/simple/SimpleDatabasePlugin.hxx
parent2a16fc74fd354484a70efcc5b6dbfcdd73ee5f5a (diff)
downloadmpd-e9a85aa4e4d0634548b5c97461beb27ae5559338.tar.gz
mpd-e9a85aa4e4d0634548b5c97461beb27ae5559338.tar.xz
mpd-e9a85aa4e4d0634548b5c97461beb27ae5559338.zip
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.
Diffstat (limited to '')
-rw-r--r--src/db/plugins/simple/SimpleDatabasePlugin.hxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.hxx b/src/db/plugins/simple/SimpleDatabasePlugin.hxx
index 9836a6bcf..a03969f92 100644
--- a/src/db/plugins/simple/SimpleDatabasePlugin.hxx
+++ b/src/db/plugins/simple/SimpleDatabasePlugin.hxx
@@ -32,16 +32,28 @@ struct Directory;
struct DatabasePlugin;
class EventLoop;
class DatabaseListener;
+class PrefixedLightSong;
class SimpleDatabase : public Database {
AllocatedPath path;
std::string path_utf8;
+ /**
+ * The path where cache files for Mount() are located.
+ */
+ AllocatedPath cache_path;
+
Directory *root;
time_t mtime;
/**
+ * A buffer for GetSong() when prefixing the #LightSong
+ * instance from a mounted #Database.
+ */
+ mutable PrefixedLightSong *prefixed_light_song;
+
+ /**
* A buffer for GetSong().
*/
mutable LightSong light_song;
@@ -52,6 +64,8 @@ class SimpleDatabase : public Database {
SimpleDatabase();
+ SimpleDatabase(AllocatedPath &&_path);
+
public:
static Database *Create(EventLoop &loop, DatabaseListener &listener,
const config_param &param,
@@ -73,6 +87,20 @@ public:
return mtime > 0;
}
+ /**
+ * @param db the #Database to be mounted; must be "open"; on
+ * success, this object gains ownership of the given #Database
+ */
+ gcc_nonnull_all
+ bool Mount(const char *uri, Database *db, Error &error);
+
+ gcc_nonnull_all
+ bool Mount(const char *local_uri, const char *storage_uri,
+ Error &error);
+
+ gcc_nonnull_all
+ bool Unmount(const char *uri);
+
/* virtual methods from class Database */
virtual bool Open(Error &error) override;
virtual void Close() override;
@@ -107,6 +135,8 @@ private:
bool Check(Error &error) const;
bool Load(Error &error);
+
+ Database *LockUmountSteal(const char *uri);
};
extern const DatabasePlugin simple_db_plugin;