Merge pull request #2628 from pieh/kill_pvrwindow_thread
[vuplus_xbmc] / xbmc / settings / Settings.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include <set>
23 #include <string>
24
25 #include "settings/ISettingCallback.h"
26 #include "settings/ISettingCreator.h"
27 #include "settings/Setting.h"
28 #include "threads/CriticalSection.h"
29
30 class CSettingSection;
31 class CSettingsManager;
32 class TiXmlElement;
33 class TiXmlNode;
34
35 class CSettings : public ISettingCreator
36 {
37 public:
38   CSettings();
39   virtual ~CSettings();
40
41   static CSettings& Get();
42
43   // implementation of ISettingCreator
44   virtual CSetting* CreateSetting(const std::string &settingType, const std::string &settingId, CSettingsManager *settingsManager = NULL) const;
45
46   bool Initialize();
47   bool Load();
48   bool Load(const std::string &file);
49   bool Load(const TiXmlElement *root, bool hide = false);
50   void SetLoaded();
51   bool Save();
52   bool Save(const std::string &file);
53   void Unload();
54   void Uninitialize();
55
56   void RegisterCallback(ISettingCallback *callback, const std::set<std::string> &settingList);
57   void UnregisterCallback(ISettingCallback *callback);
58
59   CSetting* GetSetting(const std::string &id) const;
60   CSettingSection* GetSection(const std::string &section) const;
61   SettingDependencyMap GetDependencies(const std::string &id) const;
62   SettingDependencyMap GetDependencies(const CSetting *setting) const;
63   void* GetSettingOptionsFiller(const CSetting *setting);
64     
65   bool GetBool(const std::string &id) const;
66   int GetInt(const std::string &id) const;
67   double GetNumber(const std::string &id) const;
68   std::string GetString(const std::string &id) const;
69
70   bool SetBool(const std::string &id, bool value);
71   bool ToggleBool(const std::string &id);
72   bool SetInt(const std::string &id, int value);
73   bool SetNumber(const std::string &id, double value);
74   bool SetString(const std::string &id, const std::string &value);
75
76   bool LoadSetting(const TiXmlNode *node, const std::string &settingId);
77
78 private:
79   CSettings(const CSettings&);
80   CSettings const& operator=(CSettings const&);
81
82   bool Initialize(const std::string &file);
83   bool InitializeDefinitions();
84   void InitializeSettingTypes();
85   void InitializeVisibility();
86   void InitializeDefaults();
87   void InitializeOptionFillers();
88   void InitializeConditions();
89   void InitializeISettingsHandlers();
90   void InitializeISubSettings();
91   void InitializeISettingCallbacks();
92   bool Reset();
93   
94   bool m_initialized;
95   CSettingsManager *m_settingsManager;
96   CCriticalSection m_critical;
97 };