Class Store

Inheritance Relationships

Derived Type

Class Documentation

class Store

Interface for adding attributes to a live configuration store.

The handlers should be called when the configuration is updated. There is no requirement to check the previous value has changed.

The value provided to the Handlers is optional to support values being explicitly unset. Store implementations default absent keys to preset.

The key is passed to the handler as it can be useful (e.g. for diagnostics)

This could be supported by various backends (an ini file, a YAML node, etc)

Remark

Since MirAL 5.5

Subclassed by miral::live_config::IniFile

Public Types

using HandleInt = std::function<void(Key const &key, std::optional<int> value)>
using HandleInts = std::function<void(Key const &key, std::optional<std::span<int const>> value)>
using HandleBool = std::function<void(Key const &key, std::optional<bool> value)>
using HandleFloat = std::function<void(Key const &key, std::optional<float> value)>
using HandleFloats = std::function<void(Key const &key, std::optional<std::span<float const>> value)>
using HandleString = std::function<void(Key const &key, std::optional<std::string_view> value)>
using HandleStrings = std::function<void(Key const &key, std::optional<std::span<std::string const>> value)>
using HandleDone = std::function<void()>

Public Functions

virtual void add_int_attribute(Key const &key, std::string_view description, HandleInt handler) = 0
virtual void add_ints_attribute(Key const &key, std::string_view description, HandleInts handler) = 0
virtual void add_bool_attribute(Key const &key, std::string_view description, HandleBool handler) = 0
virtual void add_float_attribute(Key const &key, std::string_view description, HandleFloat handler) = 0
virtual void add_floats_attribute(Key const &key, std::string_view description, HandleFloats handler) = 0
virtual void add_string_attribute(Key const &key, std::string_view description, HandleString handler) = 0
virtual void add_strings_attribute(Key const &key, std::string_view description, HandleStrings handler) = 0
virtual void add_int_attribute(Key const &key, std::string_view description, int preset, HandleInt handler) = 0
virtual void add_ints_attribute(Key const &key, std::string_view description, std::span<int const> preset, HandleInts handler) = 0
virtual void add_bool_attribute(Key const &key, std::string_view description, bool preset, HandleBool handler) = 0
virtual void add_float_attribute(Key const &key, std::string_view description, float preset, HandleFloat handler) = 0
virtual void add_floats_attribute(Key const &key, std::string_view description, std::span<float const> preset, HandleFloats handler) = 0
virtual void add_string_attribute(Key const &key, std::string_view description, std::string_view preset, HandleString handler) = 0
virtual void add_strings_attribute(Key const &key, std::string_view description, std::span<std::string const> preset, HandleStrings handler) = 0
virtual void on_done(HandleDone handler) = 0

Called following a set of related updates (e.g. a file reload) to allow multiple attributes to be updated transactionally.

Store() = default
virtual ~Store() = default
Store(Store const&) = delete
Store &operator=(Store const&) = delete