xbmc
SettingSection.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 "ISetting.h"
12 #include "Setting.h"
13 #include "SettingCategoryAccess.h"
14 #include "utils/logtypes.h"
15 
16 #include <string>
17 #include <utility>
18 #include <vector>
19 
20 class CSettingsManager;
21 
28 class CSettingGroup : public ISetting
29 {
30 public:
37  CSettingGroup(const std::string &id, CSettingsManager *settingsManager = nullptr);
38  ~CSettingGroup() override = default;
39 
40  // implementation of ISetting
41  bool Deserialize(const TiXmlNode *node, bool update = false) override;
42 
48  const SettingList& GetSettings() const { return m_settings; }
57  SettingList GetSettings(SettingLevel level) const;
58 
59  void AddSetting(const std::shared_ptr<CSetting>& setting);
60  void AddSettings(const SettingList &settings);
61 
62  bool ReplaceSetting(const std::shared_ptr<const CSetting>& currentSetting,
63  const std::shared_ptr<CSetting>& newSetting);
64 
65  std::shared_ptr<const ISettingControl> GetControl() const { return m_control; }
66  std::shared_ptr<ISettingControl> GetControl() { return m_control; }
67  void SetControl(std::shared_ptr<ISettingControl> control) { m_control = std::move(control); }
68 
69 private:
70  SettingList m_settings;
71  std::shared_ptr<ISettingControl> m_control;
72 
73  static Logger s_logger;
74 };
75 
76 using SettingGroupPtr = std::shared_ptr<CSettingGroup>;
77 using SettingGroupList = std::vector<SettingGroupPtr>;
78 
85 class CSettingCategory : public ISetting
86 {
87 public:
94  CSettingCategory(const std::string &id, CSettingsManager *settingsManager = nullptr);
95  ~CSettingCategory() override = default;
96 
97  // implementation of ISetting
98  bool Deserialize(const TiXmlNode *node, bool update = false) override;
99 
106  const SettingGroupList& GetGroups() const { return m_groups; }
115  SettingGroupList GetGroups(SettingLevel level) const;
116 
122  bool CanAccess() const;
123 
124  void AddGroup(const SettingGroupPtr& group);
125  void AddGroupToFront(const SettingGroupPtr& group);
126  void AddGroups(const SettingGroupList &groups);
127 
128 private:
129  SettingGroupList m_groups;
130  CSettingCategoryAccess m_accessCondition;
131 
132  static Logger s_logger;
133 };
134 
135 using SettingCategoryPtr = std::shared_ptr<CSettingCategory>;
136 using SettingCategoryList = std::vector<SettingCategoryPtr>;
137 
144 class CSettingSection : public ISetting
145 {
146 public:
153  CSettingSection(const std::string &id, CSettingsManager *settingsManager = nullptr);
154  ~CSettingSection() override = default;
155 
156  // implementation of ISetting
157  bool Deserialize(const TiXmlNode *node, bool update = false) override;
158 
165  const SettingCategoryList& GetCategories() const { return m_categories; }
174  SettingCategoryList GetCategories(SettingLevel level) const;
175 
176  void AddCategory(const SettingCategoryPtr& category);
177  void AddCategories(const SettingCategoryList &categories);
178 
179 private:
180  SettingCategoryList m_categories;
181 
182  static Logger s_logger;
183 };
184 
185 using SettingSectionPtr = std::shared_ptr<CSettingSection>;
186 using SettingSectionList = std::vector<SettingSectionPtr>;
Category of groups of settings being part of a section.
Definition: SettingSection.h:85
const SettingList & GetSettings() const
Gets the full list of settings belonging to the setting group.
Definition: SettingSection.h:48
Definition: SettingCategoryAccess.h:42
Interface defining the base of all setting objects.
Definition: ISetting.h:22
Section of setting categories.
Definition: SettingSection.h:144
const SettingCategoryList & GetCategories() const
Gets the full list of setting categories belonging to the setting section.
Definition: SettingSection.h:165
Definition: settings.py:1
Definition: SmartPlayList.cpp:137
bool Deserialize(const TiXmlNode *node, bool update=false) override
Deserializes the given XML node into the properties of the setting object.
Definition: SettingSection.cpp:70
Settings manager responsible for initializing, loading and handling all settings. ...
Definition: SettingsManager.h:41
CSettingGroup(const std::string &id, CSettingsManager *settingsManager=nullptr)
Creates a new setting group with the given identifier.
Definition: SettingSection.cpp:62
Group of settings being part of a category.
Definition: SettingSection.h:28
SettingLevel
Levels which every setting is assigned to.
Definition: SettingLevel.h:15
const SettingGroupList & GetGroups() const
Gets the full list of setting groups belonging to the setting category.
Definition: SettingSection.h:106