Add a default value for the settings

The default value is initialized when creating the setting and unchanged
after that
This commit is contained in:
regnat 2020-09-09 11:36:48 +02:00
parent 3c525d1590
commit 35042c9623

View file

@ -222,6 +222,7 @@ class BaseSetting : public AbstractSetting
protected:
T value;
const T defaultValue;
public:
@ -231,6 +232,7 @@ public:
const std::set<std::string> & aliases = {})
: AbstractSetting(name, description, aliases)
, value(def)
, defaultValue(def)
{ }
operator const T &() const { return value; }
@ -257,6 +259,7 @@ public:
{
auto obj = AbstractSetting::toJSONObject();
obj.emplace("value", value);
obj.emplace("defaultValue", defaultValue);
return obj;
}
};