Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.
CSetting Class Referenceabstract

Setting base class containing all the properties which are common to all settings independent of the setting type. More...

#include <Setting.h>

Inheritance diagram for CSetting:
ISetting ISettingCallback CTraitedSetting< bool, SettingType::Boolean > CTraitedSetting< int, SettingType::Integer > CTraitedSetting< double, SettingType::Number > CTraitedSetting< std::string, SettingType::String > CSettingAction CSettingList CSettingReference CTraitedSetting< TValue, TSettingType >

Public Member Functions

 CSetting (const std::string &id, CSettingsManager *settingsManager=nullptr)
 
 CSetting (const std::string &id, const CSetting &setting)
 
 ~CSetting () override=default
 
virtual std::shared_ptr< CSettingClone (const std::string &id) const =0
 
bool Deserialize (const TiXmlNode *node, bool update=false) override
 Deserializes the given XML node into the properties of the setting object. More...
 
virtual SettingType GetType () const =0
 
virtual bool FromString (const std::string &value)=0
 
virtual std::string ToString () const =0
 
virtual bool Equals (const std::string &value) const =0
 
virtual bool CheckValidity (const std::string &value) const =0
 
virtual void Reset ()=0
 
bool IsEnabled () const
 
void SetEnabled (bool enabled)
 
bool IsDefault () const
 
const std::string & GetParent () const
 
void SetParent (const std::string &parentSetting)
 
SettingLevel GetLevel () const
 
void SetLevel (SettingLevel level)
 
std::shared_ptr< const ISettingControlGetControl () const
 
std::shared_ptr< ISettingControlGetControl ()
 
void SetControl (std::shared_ptr< ISettingControl > control)
 
const SettingDependenciesGetDependencies () const
 
void SetDependencies (const SettingDependencies &dependencies)
 
const std::set< CSettingUpdate > & GetUpdates () const
 
void SetCallback (ISettingCallback *callback)
 
bool IsVisible () const override
 Whether the setting object is visible or hidden. More...
 
void OnSettingAction (std::shared_ptr< const CSetting > setting) override
 The given setting has been activated. More...
 
- Public Member Functions inherited from ISetting
 ISetting (const std::string &id, CSettingsManager *settingsManager=nullptr)
 Creates a new setting object with the given identifier. More...
 
virtual ~ISetting ()=default
 
const std::string & GetId () const
 Gets the identifier of the setting object. More...
 
virtual void SetVisible (bool visible)
 Sets the visibility state of the setting object. More...
 
int GetLabel () const
 Gets the localizeable label ID of the setting group. More...
 
void SetLabel (int label)
 Sets the localizeable label ID of the setting group. More...
 
int GetHelp () const
 Gets the localizeable help ID of the setting group. More...
 
void SetHelp (int help)
 Sets the localizeable help ID of the setting group. More...
 
virtual bool MeetsRequirements () const
 Whether the setting object meets all necessary requirements. More...
 
virtual void CheckRequirements ()
 Checks if the setting object meets all necessary requirements. More...
 
virtual void SetRequirementsMet (bool requirementsMet)
 Sets whether the setting object meets all necessary requirements. More...
 

Protected Member Functions

bool OnSettingChanging (std::shared_ptr< const CSetting > setting) override
 The value of the given setting is being changed. More...
 
void OnSettingChanged (std::shared_ptr< const CSetting > setting) override
 The value of the given setting has changed. More...
 
bool OnSettingUpdate (std::shared_ptr< CSetting > setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override
 The given setting needs to be updated. More...
 
void OnSettingPropertyChanged (std::shared_ptr< const CSetting > setting, const char *propertyName) override
 The given property of the given setting has changed. More...
 
void Copy (const CSetting &setting)
 
template<class TSetting >
std::shared_ptr< TSetting > shared_from_base ()
 
- Protected Member Functions inherited from ISettingCallback
virtual ~ISettingCallback ()=default
 

Protected Attributes

ISettingCallbackm_callback = nullptr
 
bool m_enabled = true
 
std::string m_parentSetting
 
SettingLevel m_level = SettingLevel::Standard
 
std::shared_ptr< ISettingControlm_control
 
SettingDependencies m_dependencies
 
std::set< CSettingUpdatem_updates
 
bool m_changed = false
 
CSharedSection m_critical
 
- Protected Attributes inherited from ISetting
std::string m_id
 
CSettingsManagerm_settingsManager
 

Additional Inherited Members

- Static Public Member Functions inherited from ISetting
static bool DeserializeIdentification (const TiXmlNode *node, std::string &identification)
 Deserializes the given XML node to retrieve a setting object's identifier. More...
 

Detailed Description

Setting base class containing all the properties which are common to all settings independent of the setting type.

Constructor & Destructor Documentation

◆ CSetting() [1/2]

CSetting::CSetting ( const std::string &  id,
CSettingsManager settingsManager = nullptr 
)

◆ CSetting() [2/2]

CSetting::CSetting ( const std::string &  id,
const CSetting setting 
)

◆ ~CSetting()

CSetting::~CSetting ( )
overridedefault

Member Function Documentation

◆ CheckValidity()

virtual bool CSetting::CheckValidity ( const std::string &  value) const
pure virtual

◆ Clone()

virtual std::shared_ptr< CSetting > CSetting::Clone ( const std::string &  id) const
pure virtual

◆ Copy()

void CSetting::Copy ( const CSetting setting)
protected

◆ Deserialize()

bool CSetting::Deserialize ( const TiXmlNode *  node,
bool  update = false 
)
overridevirtual

Deserializes the given XML node into the properties of the setting object.

If the update parameter is true, the checks for mandatory properties are skipped and values are only updated.

Parameters
nodeXML node containing the properties of the setting object
updateWhether to perform checks for mandatory properties or not
Returns
True if deserialization was successful, false otherwise

Reimplemented from ISetting.

Reimplemented in CSettingList, CSettingBool, CSettingInt, CSettingNumber, CSettingString, CSettingAction, CSettingAddon, and CSettingPath.

◆ Equals()

virtual bool CSetting::Equals ( const std::string &  value) const
pure virtual

◆ FromString()

virtual bool CSetting::FromString ( const std::string &  value)
pure virtual

◆ GetControl() [1/2]

std::shared_ptr< ISettingControl > CSetting::GetControl ( )
inline

◆ GetControl() [2/2]

std::shared_ptr< const ISettingControl > CSetting::GetControl ( ) const
inline

◆ GetDependencies()

const SettingDependencies & CSetting::GetDependencies ( ) const
inline

◆ GetLevel()

SettingLevel CSetting::GetLevel ( ) const
inline

◆ GetParent()

const std::string & CSetting::GetParent ( ) const
inline

◆ GetType()

◆ GetUpdates()

const std::set< CSettingUpdate > & CSetting::GetUpdates ( ) const
inline

◆ IsDefault()

bool CSetting::IsDefault ( ) const
inline

◆ IsEnabled()

bool CSetting::IsEnabled ( ) const

◆ IsVisible()

bool CSetting::IsVisible ( ) const
overridevirtual

Whether the setting object is visible or hidden.

Returns
True if the setting object is visible, false otherwise

Reimplemented from ISetting.

◆ OnSettingAction()

void CSetting::OnSettingAction ( std::shared_ptr< const CSetting setting)
overridevirtual

The given setting has been activated.

This callback is triggered whenever the given setting has been activated. This callback is only fired for CSettingAction settings.

Parameters
settingThe setting which has been activated.

Reimplemented from ISettingCallback.

◆ OnSettingChanged()

void CSetting::OnSettingChanged ( std::shared_ptr< const CSetting setting)
overrideprotectedvirtual

The value of the given setting has changed.

This callback is triggered whenever the value of a setting has been successfully changed (i.e. none of the OnSettingChanging() handlers) has reverted the change.

Parameters
settingThe setting whose value has been changed

Reimplemented from ISettingCallback.

◆ OnSettingChanging()

bool CSetting::OnSettingChanging ( std::shared_ptr< const CSetting setting)
overrideprotectedvirtual

The value of the given setting is being changed.

This callback is triggered whenever the value of a setting is being changed. The given CSetting already contains the new value and the handler of the callback has the possibility to allow or revert changing the value of the setting. In case of a revert OnSettingChanging() is called again to inform all listeners that the value change has been reverted.

Parameters
settingThe setting whose value is being changed (already containing the changed value)
Returns
True if the new value is acceptable otherwise false

Reimplemented from ISettingCallback.

◆ OnSettingPropertyChanged()

void CSetting::OnSettingPropertyChanged ( std::shared_ptr< const CSetting setting,
const char *  propertyName 
)
overrideprotectedvirtual

The given property of the given setting has changed.

This callback is triggered when a property (e.g. enabled or the list of dynamic options) has changed.

Parameters
settingThe setting which has a changed property
propertyNameThe string representation of the changed property

Reimplemented from ISettingCallback.

◆ OnSettingUpdate()

bool CSetting::OnSettingUpdate ( std::shared_ptr< CSetting setting,
const char *  oldSettingId,
const TiXmlNode *  oldSettingNode 
)
overrideprotectedvirtual

The given setting needs to be updated.

This callback is triggered when a setting needs to be updated because its value is outdated. This only happens when initially loading the value of a setting and will not be triggered afterwards.

Parameters
settingThe setting which needs to be updated.
oldSettingIdThe id of the previous setting.
oldSettingNodeThe old setting node
Returns
True if the setting has been successfully updated otherwise false

Reimplemented from ISettingCallback.

◆ Reset()

virtual void CSetting::Reset ( )
pure virtual

◆ SetCallback()

void CSetting::SetCallback ( ISettingCallback callback)
inline

◆ SetControl()

void CSetting::SetControl ( std::shared_ptr< ISettingControl control)
inline

◆ SetDependencies()

void CSetting::SetDependencies ( const SettingDependencies dependencies)
inline

◆ SetEnabled()

void CSetting::SetEnabled ( bool  enabled)

◆ SetLevel()

void CSetting::SetLevel ( SettingLevel  level)
inline

◆ SetParent()

void CSetting::SetParent ( const std::string &  parentSetting)
inline

◆ shared_from_base()

template<class TSetting >
std::shared_ptr< TSetting > CSetting::shared_from_base ( )
inlineprotected

◆ ToString()

virtual std::string CSetting::ToString ( ) const
pure virtual

Member Data Documentation

◆ m_callback

ISettingCallback* CSetting::m_callback = nullptr
protected

◆ m_changed

bool CSetting::m_changed = false
protected

◆ m_control

std::shared_ptr<ISettingControl> CSetting::m_control
protected

◆ m_critical

CSharedSection CSetting::m_critical
mutableprotected

◆ m_dependencies

SettingDependencies CSetting::m_dependencies
protected

◆ m_enabled

bool CSetting::m_enabled = true
protected

◆ m_level

SettingLevel CSetting::m_level = SettingLevel::Standard
protected

◆ m_parentSetting

std::string CSetting::m_parentSetting
protected

◆ m_updates

std::set<CSettingUpdate> CSetting::m_updates
protected

The documentation for this class was generated from the following files: