summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-07-17 22:51:18 +0200
committerMax Kellermann <max@musicpd.org>2018-07-17 22:53:17 +0200
commit86c531b37d9984c50f34e9f326f25339b76b0eec (patch)
treea68caea47a50504fad614998e79c73ae92c96130
parenta5b14a2ea76981fe4164e2be23a092835ff721c1 (diff)
config/Data: move std::chrono parsers from Global.hxx
-rw-r--r--src/Main.cxx9
-rw-r--r--src/config/Data.hxx17
-rw-r--r--src/config/Global.hxx20
3 files changed, 22 insertions, 24 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 205143f97..53e81ac98 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -53,6 +53,7 @@
#include "net/Init.hxx"
#include "lib/icu/Init.hxx"
#include "config/Global.hxx"
+#include "config/Data.hxx"
#include "config/Param.hxx"
#include "config/Defaults.hxx"
#include "config/Option.hxx"
@@ -252,7 +253,7 @@ glue_sticker_init()
}
static void
-glue_state_file_init()
+glue_state_file_init(const ConfigData &config)
{
auto path_fs = config_get_path(ConfigOption::STATE_FILE);
if (path_fs.IsNull()) {
@@ -268,8 +269,8 @@ glue_state_file_init()
}
const auto interval =
- config_get_unsigned(ConfigOption::STATE_FILE_INTERVAL,
- StateFile::DEFAULT_INTERVAL);
+ config.GetUnsigned(ConfigOption::STATE_FILE_INTERVAL,
+ StateFile::DEFAULT_INTERVAL);
instance->state_file = new StateFile(std::move(path_fs), interval,
instance->partitions.front(),
@@ -609,7 +610,7 @@ try {
}
#endif
- glue_state_file_init();
+ glue_state_file_init(raw_config);
#ifdef ENABLE_DATABASE
if (config_get_bool(ConfigOption::AUTO_UPDATE, false)) {
diff --git a/src/config/Data.hxx b/src/config/Data.hxx
index 8c7a1e5fc..7d21a8767 100644
--- a/src/config/Data.hxx
+++ b/src/config/Data.hxx
@@ -23,6 +23,7 @@
#include "Option.hxx"
#include <array>
+#include <chrono>
struct ConfigParam;
struct ConfigBlock;
@@ -55,9 +56,25 @@ struct ConfigData {
unsigned GetUnsigned(ConfigOption option,
unsigned default_value) const;
+ std::chrono::steady_clock::duration
+ GetUnsigned(ConfigOption option,
+ std::chrono::steady_clock::duration default_value) const {
+ // TODO: allow unit suffixes
+ auto u = GetUnsigned(option, default_value.count());
+ return std::chrono::steady_clock::duration(u);
+ }
+
unsigned GetPositive(ConfigOption option,
unsigned default_value) const;
+ std::chrono::steady_clock::duration
+ GetPositive(ConfigOption option,
+ std::chrono::steady_clock::duration default_value) const {
+ // TODO: allow unit suffixes
+ auto u = GetPositive(option, default_value.count());
+ return std::chrono::steady_clock::duration(u);
+ }
+
bool GetBool(ConfigOption option, bool default_value) const;
gcc_pure
diff --git a/src/config/Global.hxx b/src/config/Global.hxx
index c2abd0aa8..b5b5605eb 100644
--- a/src/config/Global.hxx
+++ b/src/config/Global.hxx
@@ -23,8 +23,6 @@
#include "Option.hxx"
#include "Compiler.h"
-#include <chrono>
-
class Path;
class AllocatedPath;
struct ConfigData;
@@ -76,27 +74,9 @@ config_get_path(enum ConfigOption option);
unsigned
config_get_unsigned(enum ConfigOption option, unsigned default_value);
-static inline std::chrono::steady_clock::duration
-config_get_unsigned(ConfigOption option,
- std::chrono::steady_clock::duration default_value)
-{
- // TODO: allow unit suffixes
- auto u = config_get_unsigned(option, default_value.count());
- return std::chrono::steady_clock::duration(u);
-}
-
unsigned
config_get_positive(enum ConfigOption option, unsigned default_value);
-static inline std::chrono::steady_clock::duration
-config_get_positive(ConfigOption option,
- std::chrono::steady_clock::duration default_value)
-{
- // TODO: allow unit suffixes
- auto u = config_get_positive(option, default_value.count());
- return std::chrono::steady_clock::duration(u);
-}
-
bool config_get_bool(enum ConfigOption option, bool default_value);
#endif