summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-07-17 22:57:08 +0200
committerMax Kellermann <max@musicpd.org>2018-07-17 22:57:08 +0200
commitd2594c638071c20d640424ad76c98d0bea57c4fa (patch)
tree4e51d7c0c0c3c243b151cb7a2cd6552e51b778e9 /src
parent667daab0565168172c7e03dee8ee0a2fff32e376 (diff)
storage/Configured: use struct ConfigData
Diffstat (limited to 'src')
-rw-r--r--src/Main.cxx8
-rw-r--r--src/storage/Configured.cxx20
-rw-r--r--src/storage/Configured.hxx5
3 files changed, 17 insertions, 16 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 0d3634ad5..26b74b70c 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -166,9 +166,9 @@ glue_mapper_init(const ConfigData &config)
#ifdef ENABLE_DATABASE
static void
-InitStorage(EventLoop &event_loop)
+InitStorage(const ConfigData &config, EventLoop &event_loop)
{
- auto storage = CreateConfiguredStorage(event_loop);
+ auto storage = CreateConfiguredStorage(config, event_loop);
if (storage == nullptr)
return;
@@ -193,7 +193,7 @@ glue_db_init_and_load(const ConfigData &config)
return true;
if (instance->database->GetPlugin().flags & DatabasePlugin::FLAG_REQUIRE_STORAGE) {
- InitStorage(instance->io_thread.GetEventLoop());
+ InitStorage(config, instance->io_thread.GetEventLoop());
if (instance->storage == nullptr) {
delete instance->database;
@@ -204,7 +204,7 @@ glue_db_init_and_load(const ConfigData &config)
return true;
}
} else {
- if (IsStorageConfigured())
+ if (IsStorageConfigured(config))
LogDefault(config_domain,
"Ignoring the storage configuration "
"because the database does not need it");
diff --git a/src/storage/Configured.cxx b/src/storage/Configured.cxx
index f6a53c838..d3cd5cc40 100644
--- a/src/storage/Configured.cxx
+++ b/src/storage/Configured.cxx
@@ -22,7 +22,7 @@
#include "Registry.hxx"
#include "StorageInterface.hxx"
#include "plugins/LocalStorage.hxx"
-#include "config/Global.hxx"
+#include "config/Data.hxx"
#include "config/Domain.hxx"
#include "fs/StandardDirectory.hxx"
#include "fs/CheckFile.hxx"
@@ -42,9 +42,9 @@ CreateConfiguredStorageUri(EventLoop &event_loop, const char *uri)
}
static AllocatedPath
-GetConfiguredMusicDirectory()
+GetConfiguredMusicDirectory(const ConfigData &config)
{
- AllocatedPath path = config_get_path(ConfigOption::MUSIC_DIR);
+ AllocatedPath path = config.GetPath(ConfigOption::MUSIC_DIR);
if (path.IsNull())
path = GetUserMusicDir();
@@ -52,9 +52,9 @@ GetConfiguredMusicDirectory()
}
static std::unique_ptr<Storage>
-CreateConfiguredStorageLocal()
+CreateConfiguredStorageLocal(const ConfigData &config)
{
- AllocatedPath path = GetConfiguredMusicDirectory();
+ AllocatedPath path = GetConfiguredMusicDirectory(config);
if (path.IsNull())
return nullptr;
@@ -64,17 +64,17 @@ CreateConfiguredStorageLocal()
}
std::unique_ptr<Storage>
-CreateConfiguredStorage(EventLoop &event_loop)
+CreateConfiguredStorage(const ConfigData &config, EventLoop &event_loop)
{
- auto uri = config_get_string(ConfigOption::MUSIC_DIR);
+ auto uri = config.GetString(ConfigOption::MUSIC_DIR);
if (uri != nullptr && uri_has_scheme(uri))
return CreateConfiguredStorageUri(event_loop, uri);
- return CreateConfiguredStorageLocal();
+ return CreateConfiguredStorageLocal(config);
}
bool
-IsStorageConfigured() noexcept
+IsStorageConfigured(const ConfigData &config) noexcept
{
- return config_get_string(ConfigOption::MUSIC_DIR) != nullptr;
+ return config.GetParam(ConfigOption::MUSIC_DIR) != nullptr;
}
diff --git a/src/storage/Configured.hxx b/src/storage/Configured.hxx
index 084f720a4..068c7a498 100644
--- a/src/storage/Configured.hxx
+++ b/src/storage/Configured.hxx
@@ -25,6 +25,7 @@
#include <memory>
+struct ConfigData;
class Storage;
class EventLoop;
@@ -35,13 +36,13 @@ class EventLoop;
* Throws #std::runtime_error on error.
*/
std::unique_ptr<Storage>
-CreateConfiguredStorage(EventLoop &event_loop);
+CreateConfiguredStorage(const ConfigData &config, EventLoop &event_loop);
/**
* Returns true if there is configuration for a #Storage instance.
*/
gcc_const
bool
-IsStorageConfigured() noexcept;
+IsStorageConfigured(const ConfigData &config) noexcept;
#endif