Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
|
Settings manager responsible for initializing, loading and handling all settings. More...
#include <SettingsManager.h>
Public Member Functions | |
CSettingsManager () | |
Creates a new (uninitialized) settings manager. | |
~CSettingsManager () override | |
std::shared_ptr< CSetting > | CreateSetting (const std::string &settingType, const std::string &settingId, CSettingsManager *settingsManager=nullptr) const override |
Creates a new setting of the given custom setting type. | |
std::shared_ptr< ISettingControl > | CreateControl (const std::string &controlType) const override |
Creates a new setting control of the given custom setting control type. | |
uint32_t | GetVersion () const |
uint32_t | GetMinimumSupportedVersion () const |
uint32_t | ParseVersion (const TiXmlElement *root) const |
Try to get the version of the setting definitions/values represented by the given XML element. | |
bool | Initialize (const TiXmlElement *root) |
Initializes the settings manager using the setting definitions represented by the given XML element. | |
bool | Load (const TiXmlElement *root, bool &updated, bool triggerEvents=true, std::map< std::string, std::shared_ptr< CSetting > > *loadedSettings=nullptr) |
Loads setting values from the given XML element. | |
bool | Save (const ISettingsValueSerializer *serializer, std::string &serializedValues) const |
Saves the setting values using the given serializer. | |
void | Unload () |
Unloads the previously loaded setting values. | |
void | Clear () |
Clears the complete settings manager. | |
bool | LoadSetting (const TiXmlNode *node, const std::string &settingId) |
Loads the setting being represented by the given XML node with the given identifier. | |
bool | LoadSetting (const TiXmlNode *node, const std::string &settingId, bool &updated) |
Loads the setting being represented by the given XML node with the given identifier. | |
void | SetInitialized () |
Tells the settings system that the initialization is complete. | |
bool | IsInitialized () const |
Returns whether the settings system has been initialized or not. | |
void | SetLoaded () |
Tells the settings system that all setting values have been loaded. | |
bool | IsLoaded () const |
Returns whether the settings system has been loaded or not. | |
void | AddSection (const std::shared_ptr< CSettingSection > §ion) |
Adds the given section, its categories, groups and settings. | |
bool | AddSetting (const std::shared_ptr< CSetting > &setting, const std::shared_ptr< CSettingSection > §ion, const std::shared_ptr< CSettingCategory > &category, const std::shared_ptr< CSettingGroup > &group) |
Adds the given setting to the given group in the given category in the given section;. | |
void | RegisterCallback (ISettingCallback *callback, const std::set< std::string > &settingList) |
Registers the given ISettingCallback implementation to be triggered for the given list of settings. | |
void | UnregisterCallback (ISettingCallback *callback) |
Unregisters the given ISettingCallback implementation. | |
void | RegisterSettingType (const std::string &settingType, ISettingCreator *settingCreator) |
Registers a custom setting type and its ISettingCreator implementation. | |
void | RegisterSettingControl (const std::string &controlType, ISettingControlCreator *settingControlCreator) |
Registers a custom setting control type and its ISettingControlCreator implementation. | |
void | RegisterSettingsHandler (ISettingsHandler *settingsHandler, bool bFront=false) |
Registers the given ISettingsHandler implementation. | |
void | UnregisterSettingsHandler (ISettingsHandler *settingsHandler) |
Unregisters the given ISettingsHandler implementation. | |
void | RegisterSettingOptionsFiller (const std::string &identifier, IntegerSettingOptionsFiller optionsFiller) |
Registers the given integer setting options filler under the given identifier. | |
void | RegisterSettingOptionsFiller (const std::string &identifier, StringSettingOptionsFiller optionsFiller) |
Registers the given string setting options filler under the given identifier. | |
void | UnregisterSettingOptionsFiller (const std::string &identifier) |
Unregisters the setting options filler registered under the given identifier. | |
void * | GetSettingOptionsFiller (const std::shared_ptr< const CSetting > &setting) |
Gets the implementation of the setting options filler used by the given setting. | |
bool | HasSettings () const |
Checks whether any settings have been initialized. | |
std::shared_ptr< CSetting > | GetSetting (const std::string &id) const |
Gets the setting with the given identifier. | |
std::vector< std::shared_ptr< CSettingSection > > | GetSections () const |
Gets the full list of setting sections. | |
std::shared_ptr< CSettingSection > | GetSection (std::string section) const |
Gets the setting section with the given identifier. | |
SettingDependencyMap | GetDependencies (const std::string &id) const |
Gets a map of settings (and their dependencies) which depend on the setting with the given identifier. | |
SettingDependencyMap | GetDependencies (const std::shared_ptr< const CSetting > &setting) const |
Gets a map of settings (and their dependencies) which depend on the given setting. | |
bool | GetBool (const std::string &id) const |
Gets the boolean value of the setting with the given identifier. | |
int | GetInt (const std::string &id) const |
Gets the integer value of the setting with the given identifier. | |
double | GetNumber (const std::string &id) const |
Gets the real number value of the setting with the given identifier. | |
std::string | GetString (const std::string &id) const |
Gets the string value of the setting with the given identifier. | |
std::vector< std::shared_ptr< CSetting > > | GetList (const std::string &id) const |
Gets the values of the list setting with the given identifier. | |
bool | SetBool (const std::string &id, bool value) |
Sets the boolean value of the setting with the given identifier. | |
bool | ToggleBool (const std::string &id) |
Toggles the boolean value of the setting with the given identifier. | |
bool | SetInt (const std::string &id, int value) |
Sets the integer value of the setting with the given identifier. | |
bool | SetNumber (const std::string &id, double value) |
Sets the real number value of the setting with the given identifier. | |
bool | SetString (const std::string &id, const std::string &value) |
Sets the string value of the setting with the given identifier. | |
bool | SetList (const std::string &id, const std::vector< std::shared_ptr< CSetting > > &value) |
Sets the values of the list setting with the given identifier. | |
bool | SetDefault (const std::string &id) |
Sets the value of the setting to its default. | |
void | SetDefaults () |
Sets the value of all settings to their default. | |
const CSettingConditionsManager & | GetConditions () const |
Gets the setting conditions manager used by the settings manager. | |
void | AddCondition (const std::string &condition) |
Adds the given static condition. | |
void | AddDynamicCondition (const std::string &identifier, SettingConditionCheck condition, void *data=nullptr) |
Adds the given dynamic condition. | |
void | RemoveDynamicCondition (const std::string &identifier) |
Removes the given dynamic condition. | |
Public Member Functions inherited from ISettingCreator | |
virtual | ~ISettingCreator ()=default |
Public Member Functions inherited from ISettingControlCreator | |
virtual | ~ISettingControlCreator ()=default |
Static Public Attributes | |
static const uint32_t | Version = 2 |
static const uint32_t | MinimumSupportedVersion = 0 |
Settings manager responsible for initializing, loading and handling all settings.
CSettingsManager::CSettingsManager | ( | ) |
Creates a new (uninitialized) settings manager.
|
override |
void CSettingsManager::AddCondition | ( | const std::string & | condition | ) |
Adds the given static condition.
A static condition is just a string. If a static condition is evaluated, the result depends on whether the condition's value is defined or not.
condition | Static condition string/value |
void CSettingsManager::AddDynamicCondition | ( | const std::string & | identifier, |
SettingConditionCheck | condition, | ||
void * | data = nullptr ) |
Adds the given dynamic condition.
A dynamic condition has an identifier and an implementation which is triggered when the condition is evaluated.
identifier | Identifier of the dynamic condition |
condition | Implementation of the dynamic condition |
data | Opaque data pointer, will be passed back to SettingConditionCheck function |
void CSettingsManager::AddSection | ( | const std::shared_ptr< CSettingSection > & | section | ) |
Adds the given section, its categories, groups and settings.
This is possible before and after the setting definitions have been initialized.
bool CSettingsManager::AddSetting | ( | const std::shared_ptr< CSetting > & | setting, |
const std::shared_ptr< CSettingSection > & | section, | ||
const std::shared_ptr< CSettingCategory > & | category, | ||
const std::shared_ptr< CSettingGroup > & | group ) |
Adds the given setting to the given group in the given category in the given section;.
If the given section has not been added yet, it is added. If the given category has not been added to the given section yet, it is added. If the given group has not been added to the given category yet, it is added. If the given setting has not been added to the given group yet, it is added.
This is possible before and after the setting definitions have been initialized.
setting | New setting to be added |
section | Section the new setting should be added to |
category | Category the new setting should be added to |
group | Group the new setting should be added to |
void CSettingsManager::Clear | ( | ) |
Clears the complete settings manager.
This removes all initialized settings, groups, categories and sections and returns to the uninitialized state. Any registered callbacks or implementations stay registered.
|
overridevirtual |
Creates a new setting control of the given custom setting control type.
controlType | string representation of the setting control type |
Implements ISettingControlCreator.
|
overridevirtual |
Creates a new setting of the given custom setting type.
settingType | string representation of the setting type |
settingId | Identifier of the setting to be created |
settingsManager | Reference to the settings manager |
Implements ISettingCreator.
bool CSettingsManager::GetBool | ( | const std::string & | id | ) | const |
Gets the boolean value of the setting with the given identifier.
id | Setting identifier |
|
inline |
Gets the setting conditions manager used by the settings manager.
SettingDependencyMap CSettingsManager::GetDependencies | ( | const std::shared_ptr< const CSetting > & | setting | ) | const |
Gets a map of settings (and their dependencies) which depend on the given setting.
It is important to note that the returned dependencies are not the dependencies of the given setting but the settings (and their dependencies) which depend on the given setting.
setting | Setting object |
SettingDependencyMap CSettingsManager::GetDependencies | ( | const std::string & | id | ) | const |
Gets a map of settings (and their dependencies) which depend on the setting with the given identifier.
It is important to note that the returned dependencies are not the dependencies of the setting with the given identifier but the settings (and their dependencies) which depend on the setting with the given identifier.
id | Setting identifier |
int CSettingsManager::GetInt | ( | const std::string & | id | ) | const |
Gets the integer value of the setting with the given identifier.
id | Setting identifier |
std::vector< std::shared_ptr< CSetting > > CSettingsManager::GetList | ( | const std::string & | id | ) | const |
Gets the values of the list setting with the given identifier.
id | Setting identifier |
|
inline |
double CSettingsManager::GetNumber | ( | const std::string & | id | ) | const |
Gets the real number value of the setting with the given identifier.
id | Setting identifier |
SettingSectionPtr CSettingsManager::GetSection | ( | std::string | section | ) | const |
Gets the setting section with the given identifier.
section | Setting section identifier |
SettingSectionList CSettingsManager::GetSections | ( | ) | const |
Gets the full list of setting sections.
SettingPtr CSettingsManager::GetSetting | ( | const std::string & | id | ) | const |
Gets the setting with the given identifier.
id | Setting identifier |
void * CSettingsManager::GetSettingOptionsFiller | ( | const std::shared_ptr< const CSetting > & | setting | ) |
Gets the implementation of the setting options filler used by the given setting.
setting | Setting object |
std::string CSettingsManager::GetString | ( | const std::string & | id | ) | const |
Gets the string value of the setting with the given identifier.
id | Setting identifier |
|
inline |
bool CSettingsManager::HasSettings | ( | ) | const |
Checks whether any settings have been initialized.
bool CSettingsManager::Initialize | ( | const TiXmlElement * | root | ) |
Initializes the settings manager using the setting definitions represented by the given XML element.
root | XML element representing setting definitions |
|
inline |
Returns whether the settings system has been initialized or not.
|
inline |
Returns whether the settings system has been loaded or not.
bool CSettingsManager::Load | ( | const TiXmlElement * | root, |
bool & | updated, | ||
bool | triggerEvents = true, | ||
std::map< std::string, std::shared_ptr< CSetting > > * | loadedSettings = nullptr ) |
Loads setting values from the given XML element.
root | XML element containing setting values |
updated | Whether some settings were automatically updated |
triggerEvents | Whether to trigger ISettingCallback methods |
loadedSettings | A list to fill with all the successfully loaded settings |
bool CSettingsManager::LoadSetting | ( | const TiXmlNode * | node, |
const std::string & | settingId ) |
Loads the setting being represented by the given XML node with the given identifier.
node | XML node representing the setting to load |
settingId | Setting identifier |
bool CSettingsManager::LoadSetting | ( | const TiXmlNode * | node, |
const std::string & | settingId, | ||
bool & | updated ) |
Loads the setting being represented by the given XML node with the given identifier.
node | XML node representing the setting to load |
settingId | Setting identifier |
updated | Set to true if the setting's value was updated |
uint32_t CSettingsManager::ParseVersion | ( | const TiXmlElement * | root | ) | const |
Try to get the version of the setting definitions/values represented by the given XML element.
root | XML element representing setting definitions/values |
void CSettingsManager::RegisterCallback | ( | ISettingCallback * | callback, |
const std::set< std::string > & | settingList ) |
Registers the given ISettingCallback implementation to be triggered for the given list of settings.
settingsHandler | ISettingsHandler implementation |
settingList | List of settings to trigger the given ISettingCallback implementation |
void CSettingsManager::RegisterSettingControl | ( | const std::string & | controlType, |
ISettingControlCreator * | settingControlCreator ) |
Registers a custom setting control type and its ISettingControlCreator implementation.
When a setting control definition for a registered custom setting control type is found its ISettingControlCreator implementation is called to create and deserialize the setting control definition.
controlType | String representation of the custom setting control type |
settingControlCreator | ISettingControlCreator implementation |
void CSettingsManager::RegisterSettingOptionsFiller | ( | const std::string & | identifier, |
IntegerSettingOptionsFiller | optionsFiller ) |
Registers the given integer setting options filler under the given identifier.
identifier | Setting options filler identifier |
optionsFiller | Integer setting options filler implementation |
void CSettingsManager::RegisterSettingOptionsFiller | ( | const std::string & | identifier, |
StringSettingOptionsFiller | optionsFiller ) |
Registers the given string setting options filler under the given identifier.
identifier | Setting options filler identifier |
optionsFiller | String setting options filler implementation |
void CSettingsManager::RegisterSettingsHandler | ( | ISettingsHandler * | settingsHandler, |
bool | bFront = false ) |
Registers the given ISettingsHandler implementation.
settingsHandler | ISettingsHandler implementation |
bFront | If True, insert the handler in front of other registered handlers, insert at the end otherwise. |
void CSettingsManager::RegisterSettingType | ( | const std::string & | settingType, |
ISettingCreator * | settingCreator ) |
Registers a custom setting type and its ISettingCreator implementation.
When a setting definition for a registered custom setting type is found its ISettingCreator implementation is called to create and deserialize the setting definition.
settingType | String representation of the custom setting type |
settingCreator | ISettingCreator implementation |
void CSettingsManager::RemoveDynamicCondition | ( | const std::string & | identifier | ) |
Removes the given dynamic condition.
identifier | Identifier of the dynamic condition |
bool CSettingsManager::Save | ( | const ISettingsValueSerializer * | serializer, |
std::string & | serializedValues ) const |
Saves the setting values using the given serializer.
serializer | Settings value serializer to use |
Sets the boolean value of the setting with the given identifier.
id | Setting identifier |
value | Boolean value to set |
bool CSettingsManager::SetDefault | ( | const std::string & | id | ) |
Sets the value of the setting to its default.
id | Setting identifier |
void CSettingsManager::SetDefaults | ( | ) |
Sets the value of all settings to their default.
void CSettingsManager::SetInitialized | ( | ) |
Tells the settings system that the initialization is complete.
Setting values can only be loaded after a complete and successful initialization of the settings system.
Sets the integer value of the setting with the given identifier.
id | Setting identifier |
value | Integer value to set |
bool CSettingsManager::SetList | ( | const std::string & | id, |
const std::vector< std::shared_ptr< CSetting > > & | value ) |
Sets the values of the list setting with the given identifier.
id | Setting identifier |
value | Values to set |
|
inline |
Tells the settings system that all setting values have been loaded.
This manual trigger is necessary to enable the ISettingCallback methods being executed.
bool CSettingsManager::SetNumber | ( | const std::string & | id, |
double | value ) |
Sets the real number value of the setting with the given identifier.
id | Setting identifier |
value | Real number value to set |
bool CSettingsManager::SetString | ( | const std::string & | id, |
const std::string & | value ) |
Sets the string value of the setting with the given identifier.
id | Setting identifier |
value | String value to set |
bool CSettingsManager::ToggleBool | ( | const std::string & | id | ) |
Toggles the boolean value of the setting with the given identifier.
id | Setting identifier |
void CSettingsManager::Unload | ( | ) |
Unloads the previously loaded setting values.
The values of all the settings are reset to their default values.
void CSettingsManager::UnregisterCallback | ( | ISettingCallback * | callback | ) |
Unregisters the given ISettingCallback implementation.
callback | ISettingCallback implementation |
void CSettingsManager::UnregisterSettingOptionsFiller | ( | const std::string & | identifier | ) |
Unregisters the setting options filler registered under the given identifier.
identifier | Setting options filler identifier |
void CSettingsManager::UnregisterSettingsHandler | ( | ISettingsHandler * | settingsHandler | ) |
Unregisters the given ISettingsHandler implementation.
settingsHandler | ISettingsHandler implementation |
|
static |
|
static |