xbmc
ISetting.h
1 /*
2  * Copyright (C) 2013-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "SettingRequirement.h"
12 
13 #include <string>
14 
15 class CSettingsManager;
16 class TiXmlNode;
17 
22 class ISetting
23 {
24 public:
31  ISetting(const std::string &id, CSettingsManager *settingsManager = nullptr);
32  virtual ~ISetting() = default;
33 
45  virtual bool Deserialize(const TiXmlNode *node, bool update = false);
46 
52  const std::string& GetId() const { return m_id; }
58  virtual bool IsVisible() const { return m_visible; }
64  virtual void SetVisible(bool visible) { m_visible = visible; }
70  int GetLabel() const { return m_label; }
76  void SetLabel(int label) { m_label = label; }
82  int GetHelp() const { return m_help; }
88  void SetHelp(int help) { m_help = help; }
94  virtual bool MeetsRequirements() const { return m_meetsRequirements; }
98  virtual void CheckRequirements();
104  virtual void SetRequirementsMet(bool requirementsMet) { m_meetsRequirements = requirementsMet; }
105 
114  static bool DeserializeIdentification(const TiXmlNode *node, std::string &identification);
115 
116 protected:
117  static constexpr int DefaultLabel = -1;
126  static bool DeserializeIdentificationFromAttribute(const TiXmlNode* node,
127  const std::string& attribute,
128  std::string& identification);
129 
130  std::string m_id;
131  CSettingsManager *m_settingsManager;
132 
133 private:
134  bool m_visible = true;
135  int m_label = DefaultLabel;
136  int m_help = -1;
137  bool m_meetsRequirements = true;
138  CSettingRequirement m_requirementCondition;
139 };
static bool DeserializeIdentification(const TiXmlNode *node, std::string &identification)
Deserializes the given XML node to retrieve a setting object&#39;s identifier.
Definition: ISetting.cpp:49
virtual bool Deserialize(const TiXmlNode *node, bool update=false)
Deserializes the given XML node into the properties of the setting object.
Definition: ISetting.cpp:23
Definition: SettingRequirement.h:42
virtual void SetVisible(bool visible)
Sets the visibility state of the setting object.
Definition: ISetting.h:64
virtual void SetRequirementsMet(bool requirementsMet)
Sets whether the setting object meets all necessary requirements.
Definition: ISetting.h:104
const std::string & GetId() const
Gets the identifier of the setting object.
Definition: ISetting.h:52
void SetLabel(int label)
Sets the localizeable label ID of the setting group.
Definition: ISetting.h:76
Interface defining the base of all setting objects.
Definition: ISetting.h:22
virtual void CheckRequirements()
Checks if the setting object meets all necessary requirements.
Definition: ISetting.cpp:73
static bool DeserializeIdentificationFromAttribute(const TiXmlNode *node, const std::string &attribute, std::string &identification)
Deserializes the given XML node to retrieve a setting object&#39;s identifier from the given attribute...
Definition: ISetting.cpp:54
virtual bool IsVisible() const
Whether the setting object is visible or hidden.
Definition: ISetting.h:58
int GetLabel() const
Gets the localizeable label ID of the setting group.
Definition: ISetting.h:70
void SetHelp(int help)
Sets the localizeable help ID of the setting group.
Definition: ISetting.h:88
Settings manager responsible for initializing, loading and handling all settings. ...
Definition: SettingsManager.h:41
ISetting(const std::string &id, CSettingsManager *settingsManager=nullptr)
Creates a new setting object with the given identifier.
Definition: ISetting.cpp:17
int GetHelp() const
Gets the localizeable help ID of the setting group.
Definition: ISetting.h:82
virtual bool MeetsRequirements() const
Whether the setting object meets all necessary requirements.
Definition: ISetting.h:94