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:
parent
3c525d1590
commit
35042c9623
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue