26 : name_(name), doc_string_(doc_string) {
41 ListenerMap::iterator it = listeners_.find(key);
42 if (it != listeners_.end())
43 it->second.enabled = enable;
47 listeners_.erase(key);
51 for (ListenerMap::const_iterator it = listeners_.begin();
52 it != listeners_.end(); ++it) {
53 if (it->second.enabled)
54 it->second.listener(
this);
void NotifyListeners()
Notify listeners that this setting has changed.
void RegisterListener(const std::string &key, const Listener &listener)
Adds a function that will be called when this setting's value changes.
void UnregisterListener(const std::string &key)
Removes the listener identified by key, if one exists.
static void RegisterSetting(SettingBase *setting)
Adds the setting to the manager and its groups.
void EnableListener(const std::string &key, bool enable)
Enables or disables the listener identified by key, if one exists.
std::function< void(SettingBase *setting)> Listener
A function that is called when the value changes.
SettingBase(const std::string &name, const std::string &doc_string)
The constructor and destructor are protected because this is an abstract base class.
static void UnregisterSetting(SettingBase *setting)
Removes the setting from the manager and its groups.