summaryrefslogtreecommitdiff
path: root/include/mbgl/platform/settings.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/platform/settings.hpp')
-rw-r--r--include/mbgl/platform/settings.hpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/mbgl/platform/settings.hpp b/include/mbgl/platform/settings.hpp
new file mode 100644
index 0000000000..80bfe1d60f
--- /dev/null
+++ b/include/mbgl/platform/settings.hpp
@@ -0,0 +1,48 @@
+#pragma once
+
+#include <mapbox/value.hpp>
+
+#include <memory>
+
+namespace mbgl {
+namespace platform {
+
+#define DECLARE_MAPBOX_SETTING(name, value) constexpr const char* name = "mapbox_" #value
+
+// The value for EXPERIMENTAL_THREAD_PRIORITY_* keys, must be a double.
+DECLARE_MAPBOX_SETTING(EXPERIMENTAL_THREAD_PRIORITY_WORKER, thread_priority_worker);
+DECLARE_MAPBOX_SETTING(EXPERIMENTAL_THREAD_PRIORITY_FILE, thread_priority_file);
+DECLARE_MAPBOX_SETTING(EXPERIMENTAL_THREAD_PRIORITY_NETWORK, thread_priority_network);
+DECLARE_MAPBOX_SETTING(EXPERIMENTAL_THREAD_PRIORITY_DATABASE, thread_priority_database);
+
+// Settings class provides non-persistent, in-process key-value storage.
+class Settings final {
+public:
+ // Returns singleton instance
+ static Settings& getInstance() noexcept;
+
+ // Sets setting value for a specified key.
+ void set(const std::string& key, mapbox::base::Value value) noexcept;
+
+ // Sets multiple setting values by merging current Settings object
+ // with provided `values` object.
+ void set(mapbox::base::ValueObject values) noexcept;
+
+ // Returns setting value for a specified key or NullValue if element
+ // for specified key is missing.
+ mapbox::base::Value get(const std::string& key) const noexcept;
+
+ // Returns values for settings whose keys are equal to the ones provided in `keys` argument.
+ // Null values would be provided for keys whose elements are missing in Settings.
+ mapbox::base::ValueObject get(const std::vector<std::string>& keys) const noexcept;
+
+private:
+ Settings();
+
+private:
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+} // namespace platform
+} // namespace mbgl