Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
settingmanager.h
Go to the documentation of this file.
1 
18 #ifndef ION_BASE_SETTINGMANAGER_H_
19 #define ION_BASE_SETTINGMANAGER_H_
20 
21 #include <map>
22 #include <string>
23 
24 #include "base/macros.h"
25 #include "ion/base/setting.h"
26 #include "ion/base/sharedptr.h"
27 
28 namespace ion {
29 namespace base {
30 
34 class ION_API SettingManager {
35  public:
37  typedef std::map<std::string, SettingBase*> SettingMap;
38 
39  ~SettingManager();
40 
42  static SettingBase* GetSetting(const std::string& name);
44  static const SettingMap& GetAllSettings();
45 
47  static void RegisterSetting(SettingBase* setting);
48 
50  static void UnregisterSetting(SettingBase* setting);
51 
57  static void RegisterGroupListener(const std::string& group,
58  const std::string& key,
59  const SettingBase::Listener& listener);
60 
62  static void EnableGroupListener(const std::string& group,
63  const std::string& key,
64  bool enable);
65 
67  static void UnregisterGroupListener(const std::string& group,
68  const std::string& key);
69 
70  private:
71  class SettingData;
73 
76 
78  static SettingManager* GetInstance();
79 
80  DISALLOW_COPY_AND_ASSIGN(SettingManager);
81 };
82 
83 } // namespace base
84 } // namespace ion
85 
86 #endif // ION_BASE_SETTINGMANAGER_H_
Base class for Setting, which encapsulates the name of the setting and any functors that should be ca...
Definition: setting.h:43
std::map< std::string, SettingBase * > SettingMap
Maps a setting's name to setting itself and its groups.
std::string name
Definition: printer.cc:324
std::function< void(SettingBase *setting)> Listener
A function that is called when the value changes.
Definition: setting.h:46
SettingManager tracks all existing SettingBase instances, and allows callers to obtain a map of all s...