Class sh::configuration::ConfigurationManager

class sh::configuration::ConfigurationManager : public QObject, public sh::base::Singleton

Manages the Shallot configuration.

This is the more static part of Shallot. Much more stuff, i.e. everything you see in ‘Manage saved settings’, is in sh::settings::SettingsManager.

Public Functions

std::shared_ptr<ConfigurationValue> registerConfigValue(QString name, QVariant deflt, ConfigurationValueType *valuetype = 0, QString desc = "", ConfigurationCategory cat = CategoryNone, QString longdesc = "", QString changehint = "")

Creates and registers a new ConfigurationValue. This is typically done once at the beginning. Each registered instance is shown in the ‘Tuning’ dialog and can be set (for making changes) and observed (for applying changes) in code as well. Useful e.g. for some internal bookkeeping or for exotic machine-wide configuration values (path to some tool, …).

QList<std::shared_ptr<ConfigurationValue>> getAllConfigurationValues()

Returns a list of all registered configuration value instances.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

Returns if this singleton is alive (true until its shutdown begins).

Private Functions

QVariant getFixedConfigValue(QString key)

Returns a non-null value if ‘key’ was set in a fixed way (e.g. via command line).

ConfigurationManager()

Private Members

QHash<QString, std::shared_ptr<ConfigurationValue>> _configvalues
QHash<QString, QVariant> _fixed_configvalues
bool _fixed_configvalues_initialized = false
QMutex _mutex
class ConfigurationValueImpl : public sh::configuration::ConfigurationValue

Public Functions

ConfigurationValueImpl(QString name, QVariant deflt, QString desc, QString longdesc, ConfigurationCategory cat, ConfigurationValueType *valuetype, QString changehint, ConfigurationManager *mgr)
void setConfigValue(QVariant value) override

Sets a new configuration value.

QVariant getConfigValueVariant() override

Returns the current value of this instance as variant.

bool mayChange() override

Returns if changes are allowed.

int getConfigValueInt()

Returns the current value of this instance as integer.

double getConfigValueFloat()

Returns the current value of this instance as floating point number.

bool getConfigValueBool()

Returns the current value of this instance as boolean.

QString getConfigValueString()

Returns the current value of this instance as string.

void consumeValue(QObject *o, std::function<void()> h)

Adds a consumer function, triggered directly and whenever the value changes.

Parameters
  • o: For lifetime monitoring.

QString name()

Returns the internal name of this configuration.

QString description()

Returns the short description of this configuration.

QString longDescription()

Returns the long description of this configuration.

ConfigurationCategory category()

Returns the category of this configuration (mainly for UI structuring).

QString changeHint()

Returns the change hint text of this configuration.

QVariant defaultValue()

Returns the default value of this configuration.

ConfigurationValueType *valueType()

Returns the value type of this configuration.

Public Static Functions

ConfigurationValueType *valueTypeString()

Returns the string type for configuration values.

ConfigurationValueType *valueTypeInteger()

Returns the integer type for configuration values.

ConfigurationValueType *valueTypeFloat()

Returns the floating point number type for configuration values.

ConfigurationValueType *valueTypeBoolean()

Returns the boolean type for configuration values.

ConfigurationValueType *valueTypeLocalFilePath()

Returns the filepath type for configuration values.

Private Members

ConfigurationManager *mgr