ImFusion SDK 4.3
Settings::Setting< T > Class Template Reference

#include <ImFusion/Base/Settings.h>

Provides a type-safe way to access a setting value. More...

Detailed Description

template<typename T>
class ImFusion::Settings::Setting< T >

Provides a type-safe way to access a setting value.

Can be used like a type, e.g.:

Settings settings;
Setting<bool> s = settings.showLoadOptionsOnStart;
bool show = s; // same as: show = settings.value();
s = true; // same as: s.setValue(true);
Setting(const std::string &name, T defaultValue)
Settings()
Creates a new Settings object.

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.
 
value (bool *exists=nullptr) const
 Retrieves the current value of the setting.
 
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
 

Constructor & Destructor Documentation

◆ Setting() [1/4]

template<typename T>
Setting ( const std::string & name,
T defaultValue )
Deprecated
"Use GlobalSettings instead"

◆ Setting() [2/4]

template<typename T>
Setting ( const std::string & name,
MakeDefaultValueFunc makeDefaultValueFunc )
Deprecated
"Use GlobalSettings instead"

◆ Setting() [3/4]

template<typename T>
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.

Deprecated
"Use GlobalSettings instead"

◆ Setting() [4/4]

template<typename T>
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.

Deprecated
"Use GlobalSettings instead"

Member Function Documentation

◆ value()

template<typename T>
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.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close