ScopedConfiguration
#include <icy/configuration.h>
class ScopedConfigurationDefined in src/base/include/icy/configuration.h:195
ScopedConfiguration provides multiple levels of configuration for a module. Multiple levels means that there is a module level scope, and a default scope. When a property is accessed, the module scope value will be used if available, otherwise the default scope value will be used.
Example scoping: Module: channels.[name].modes.[name].[value] Default: modes.[name].[value]
Public Attributes
| Return | Name | Description |
|---|---|---|
Configuration & | config | |
std::string | currentScope | |
std::string | defaultScope |
config
Configuration & configType: Configuration &
Defined in src/base/include/icy/configuration.h:278
currentScope
std::string currentScopeDefined in src/base/include/icy/configuration.h:279
defaultScope
std::string defaultScopeDefined in src/base/include/icy/configuration.h:280
Public Methods
| Return | Name | Description |
|---|---|---|
ScopedConfiguration | ||
ScopedConfiguration | ||
std::string | getString const | Returns the string value, trying currentScope first then defaultScope. |
int | getInt const | Returns the int value, trying currentScope first then defaultScope. |
double | getDouble const | Returns the double value, trying currentScope first then defaultScope. |
bool | getBool const | Returns the bool value, trying currentScope first then defaultScope. |
void | setString | Writes a string value under the scoped key. |
void | setInt | Writes an int value under the scoped key. |
void | setDouble | Writes a double value under the scoped key. |
void | setBool | Writes a bool value under the scoped key. |
std::string | getCurrentScope const | |
std::string | getDafaultKey const | |
std::string | getScopedKey const |
ScopedConfiguration
ScopedConfiguration(Configuration & config, const std::string & currentScope, const std::string & defaultScope)Defined in src/base/include/icy/configuration.h:201
Parameters
| Parameter | Type | Description |
|---|---|---|
config | Configuration & | Backing configuration store. |
currentScope | const std::string & | Key prefix for the module-level scope. |
defaultScope | const std::string & | Key prefix for the default/fallback scope. |
ScopedConfiguration
ScopedConfiguration(const ScopedConfiguration & that)Defined in src/base/include/icy/configuration.h:203
getString
const
std::string getString(const std::string & key, const std::string & defaultValue, bool forceDefaultScope = false) constDefined in src/base/include/icy/configuration.h:210
Returns the string value, trying currentScope first then defaultScope.
Returns
Property value or defaultValue.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
defaultValue | const std::string & | Fallback when neither scope has the key. |
forceDefaultScope | bool | If true, skips currentScope and reads from defaultScope only. |
getInt
const
int getInt(const std::string & key, int defaultValue, bool forceDefaultScope = false) constDefined in src/base/include/icy/configuration.h:219
Returns the int value, trying currentScope first then defaultScope.
Returns
Property value or defaultValue.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
defaultValue | int | Fallback when neither scope has the key. |
forceDefaultScope | bool | If true, reads from defaultScope only. |
getDouble
const
double getDouble(const std::string & key, double defaultValue, bool forceDefaultScope = false) constDefined in src/base/include/icy/configuration.h:227
Returns the double value, trying currentScope first then defaultScope.
Returns
Property value or defaultValue.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
defaultValue | double | Fallback when neither scope has the key. |
forceDefaultScope | bool | If true, reads from defaultScope only. |
getBool
const
bool getBool(const std::string & key, bool defaultValue, bool forceDefaultScope = false) constDefined in src/base/include/icy/configuration.h:235
Returns the bool value, trying currentScope first then defaultScope.
Returns
Property value or defaultValue.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
defaultValue | bool | Fallback when neither scope has the key. |
forceDefaultScope | bool | If true, reads from defaultScope only. |
setString
void setString(const std::string & key, const std::string & value, bool defaultScope = false)Defined in src/base/include/icy/configuration.h:242
Writes a string value under the scoped key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
value | const std::string & | Value to store. |
defaultScope | bool | If true, writes to defaultScope; otherwise to currentScope. |
setInt
void setInt(const std::string & key, int value, bool defaultScope = false)Defined in src/base/include/icy/configuration.h:249
Writes an int value under the scoped key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
value | int | Value to store. |
defaultScope | bool | If true, writes to defaultScope; otherwise to currentScope. |
setDouble
void setDouble(const std::string & key, double value, bool defaultScope = false)Defined in src/base/include/icy/configuration.h:255
Writes a double value under the scoped key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
value | double | Value to store. |
defaultScope | bool | If true, writes to defaultScope; otherwise to currentScope. |
setBool
void setBool(const std::string & key, bool value, bool defaultScope = false)Defined in src/base/include/icy/configuration.h:262
Writes a bool value under the scoped key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
value | bool | Value to store. |
defaultScope | bool | If true, writes to defaultScope; otherwise to currentScope. |
getCurrentScope
const
std::string getCurrentScope(const std::string & key) constDefined in src/base/include/icy/configuration.h:266
Returns
Fully qualified key in currentScope.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
getDafaultKey
const
std::string getDafaultKey(const std::string & key) constDefined in src/base/include/icy/configuration.h:270
Returns
Fully qualified key in defaultScope.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
getScopedKey
const
std::string getScopedKey(const std::string & key, bool defaultScope = false) constDefined in src/base/include/icy/configuration.h:275
Returns
Fully qualified scoped key string.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | const std::string & | Property key (without scope prefix). |
defaultScope | bool | If true, returns the defaultScope key; otherwise currentScope key. |
Private Methods
| Return | Name | Description |
|---|---|---|
ScopedConfiguration & | operator= |
operator=
ScopedConfiguration & operator=(const ScopedConfiguration &)