![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/Settings.h>
Provides a type-safe way to access a setting value. More...
Provides a type-safe way to access a setting value.
Can be used like a type, e.g.:
If nothing is stored in the backend, the defaultValue is used.
Public Types | |
using | MakeDefaultValueFunc = T (*)() |
Public Member Functions | |
Setting (const std::string &name, T defaultValue) | |
Setting (const std::string &name, MakeDefaultValueFunc makeDefaultValueFunc) | |
Setting (LegacyInterfaceSettings &settings, const std::string &name, T defaultValue) | |
Constructs a Setting fully initializing the default value. | |
Setting (LegacyInterfaceSettings &settings, const std::string &name, MakeDefaultValueFunc makeDefaultValueFunc) | |
Alternative constructor using lazy initialization of the default value. | |
void | setValue (const T &value) |
Sets the setting to the given value. | |
T | value (bool *exists=nullptr) const |
Retrieves the current value of the setting. | |
T | defaultValue () const |
Returns the default value of the setting. | |
operator T () const | |
Calls value() | |
Setting< T > & | operator= (const T &value) |
Calls setValue(value) | |
void | configure (const Properties *p) |
void | configuration (Properties *p) const |
Public Attributes | |
const std::string | name |
Setting | ( | const std::string & | name, |
T | defaultValue ) |
Setting | ( | const std::string & | name, |
MakeDefaultValueFunc | makeDefaultValueFunc ) |
Setting | ( | LegacyInterfaceSettings & | settings, |
const std::string & | name, | ||
T | defaultValue ) |
Constructs a Setting fully initializing the default value.
Use this overload only where T
is a primitive/cheap to generate value.
Setting | ( | LegacyInterfaceSettings & | settings, |
const std::string & | name, | ||
MakeDefaultValueFunc | makeDefaultValueFunc ) |
Alternative constructor using lazy initialization of the default value.
Use this overload if generating the default value is expensive, makeDefaultValueFunc must not be 0.
T value | ( | bool * | exists = nullptr | ) | const |
Retrieves the current value of the setting.
If no value is stored yet, the default value is returned. The optional 'exists' value is set to true if the value exists in the backend or false if the default value was returned.