Base module

ScopedConfiguration

[ScopedConfiguration]({#ref classicy_1_1ScopedConfiguration #}) provides multiple levels of configuration for a module.

ScopedConfiguration

#include <icy/configuration.h>

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

ReturnNameDescription
Configuration &config
std::stringcurrentScope
std::stringdefaultScope

config

Configuration & config

currentScope

std::string currentScope

defaultScope

std::string defaultScope

Public Methods

ReturnNameDescription
ScopedConfiguration#### Parameters
ScopedConfiguration
std::stringgetString constReturns the string value, trying currentScope first then defaultScope.
intgetInt constReturns the int value, trying currentScope first then defaultScope.
doublegetDouble constReturns the double value, trying currentScope first then defaultScope.
boolgetBool constReturns the bool value, trying currentScope first then defaultScope.
voidsetStringWrites a string value under the scoped key.
voidsetIntWrites an int value under the scoped key.
voidsetDoubleWrites a double value under the scoped key.
voidsetBoolWrites a bool value under the scoped key.
std::stringgetCurrentScope const#### Parameters
std::stringgetDafaultKey const#### Parameters
std::stringgetScopedKey const#### Parameters

ScopedConfiguration

ScopedConfiguration(Configuration & config, const std::string & currentScope, const std::string & defaultScope)

Parameters

  • config Backing configuration store.

  • currentScope Key prefix for the module-level scope.

  • defaultScope Key prefix for the default/fallback scope.


ScopedConfiguration

ScopedConfiguration(const ScopedConfiguration & that)

getString

const

std::string getString(const std::string & key, const std::string & defaultValue, bool forceDefaultScope) const

Returns the string value, trying currentScope first then defaultScope.

Parameters

  • key Property key (without scope prefix).

  • defaultValue Fallback when neither scope has the key.

  • forceDefaultScope If true, skips currentScope and reads from defaultScope only.

Returns

Property value or defaultValue.


getInt

const

int getInt(const std::string & key, int defaultValue, bool forceDefaultScope) const

Returns the int value, trying currentScope first then defaultScope.

Parameters

  • key Property key (without scope prefix).

  • defaultValue Fallback when neither scope has the key.

  • forceDefaultScope If true, reads from defaultScope only.

Returns

Property value or defaultValue.


getDouble

const

double getDouble(const std::string & key, double defaultValue, bool forceDefaultScope) const

Returns the double value, trying currentScope first then defaultScope.

Parameters

  • key Property key (without scope prefix).

  • defaultValue Fallback when neither scope has the key.

  • forceDefaultScope If true, reads from defaultScope only.

Returns

Property value or defaultValue.


getBool

const

bool getBool(const std::string & key, bool defaultValue, bool forceDefaultScope) const

Returns the bool value, trying currentScope first then defaultScope.

Parameters

  • key Property key (without scope prefix).

  • defaultValue Fallback when neither scope has the key.

  • forceDefaultScope If true, reads from defaultScope only.

Returns

Property value or defaultValue.


setString

void setString(const std::string & key, const std::string & value, bool defaultScope)

Writes a string value under the scoped key.

Parameters

  • key Property key (without scope prefix).

  • value Value to store.

  • defaultScope If true, writes to defaultScope; otherwise to currentScope.


setInt

void setInt(const std::string & key, int value, bool defaultScope)

Writes an int value under the scoped key.

Parameters

  • key Property key (without scope prefix).

  • value Value to store.

  • defaultScope If true, writes to defaultScope; otherwise to currentScope.


setDouble

void setDouble(const std::string & key, double value, bool defaultScope)

Writes a double value under the scoped key.

Parameters

  • key Property key (without scope prefix).

  • value Value to store.

  • defaultScope If true, writes to defaultScope; otherwise to currentScope.


setBool

void setBool(const std::string & key, bool value, bool defaultScope)

Writes a bool value under the scoped key.

Parameters

  • key Property key (without scope prefix).

  • value Value to store.

  • defaultScope If true, writes to defaultScope; otherwise to currentScope.


getCurrentScope

const

std::string getCurrentScope(const std::string & key) const

Parameters

  • key Property key (without scope prefix).

Returns

Fully qualified key in currentScope.


getDafaultKey

const

std::string getDafaultKey(const std::string & key) const

Parameters

  • key Property key (without scope prefix).

Returns

Fully qualified key in defaultScope.


getScopedKey

const

std::string getScopedKey(const std::string & key, bool defaultScope) const

Parameters

  • key Property key (without scope prefix).

  • defaultScope If true, returns the defaultScope key; otherwise currentScope key.

Returns

Fully qualified scoped key string.