Ion
|
An EnvironmentSetting is a Setting can take its initial value from the named system environment variable passed to its constructor. More...
#include "setting.h"
Public Types | |
typedef std::function< void(SettingBase *setting)> | Listener |
A function that is called when the value changes. More... | |
Public Member Functions | |
EnvironmentSetting (const std::string &setting_name, const std::string &env_var_name, const T &default_value, const std::string &doc_string) | |
Creates a new setting with the passed setting_name and attempts to set its initial value from the environment variable env_var_name. More... | |
bool | operator== (const T &value) const |
Equality testers. More... | |
const std::string | ToString () const override |
Returns a string version of this setting. More... | |
bool | FromString (const std::string &str) override |
Parses the passed string to set the value of this and returns whether the parsing was successful. More... | |
T * | GetMutableValue () |
Direct value mutators. More... | |
const T & | GetValue () const |
void | SetValue (const T &value) |
operator T () const | |
const std::string & | GetName () const |
Returns the name associated with this. More... | |
const std::string & | GetDocString () const |
Returns the documentation string associated with this. More... | |
void | SetTypeDescriptor (const std::string &desc) |
Sets/returns a string containing information about the Setting's type. More... | |
const std::string & | GetTypeDescriptor () const |
void | RegisterListener (const std::string &key, const Listener &listener) |
Adds a function that will be called when this setting's value changes. More... | |
void | EnableListener (const std::string &key, bool enable) |
Enables or disables the listener identified by key, if one exists. More... | |
void | UnregisterListener (const std::string &key) |
Removes the listener identified by key, if one exists. More... | |
void | NotifyListeners () |
Notify listeners that this setting has changed. More... | |
Friends | |
bool | operator== (const T &value, const EnvironmentSetting< T > &setting) |
An EnvironmentSetting is a Setting can take its initial value from the named system environment variable passed to its constructor.
Note that the value of the EnvironmentSetting does not change if the environment variable changes after construction.
|
inherited |
|
inline |
Creates a new setting with the passed setting_name and attempts to set its initial value from the environment variable env_var_name.
If the variable does not exist or cannot be converted to type T, then the setting takes on the passed default value.
Definition at line 311 of file setting.h.
References ion::base::Setting< T >::FromString(), and ion::port::GetEnvironmentVariableValue().
|
inherited |
Enables or disables the listener identified by key, if one exists.
Definition at line 40 of file setting.cc.
|
inlineoverridevirtualinherited |
Parses the passed string to set the value of this and returns whether the parsing was successful.
If the parsing does not succeed then nothing should change in this.
Implements ion::base::SettingBase.
Definition at line 190 of file setting.h.
Referenced by ion::base::EnvironmentSetting< T >::EnvironmentSetting().
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inherited |
Notify listeners that this setting has changed.
Definition at line 50 of file setting.cc.
Referenced by ion::base::Setting< bool >::operator=(), ion::base::Setting< std::atomic< T > >::operator=(), ion::base::Setting< bool >::SetValue(), and ion::base::Setting< std::atomic< T > >::SetValue().
|
inlineinherited |
|
inline |
Equality testers.
Definition at line 322 of file setting.h.
References ion::base::Setting< T >::operator==().
|
inherited |
Adds a function that will be called when this setting's value changes.
The function is identified by the passed key. The same key must be used to remove the listener.
Definition at line 35 of file setting.cc.
|
inlineinherited |
Sets/returns a string containing information about the Setting's type.
This string can be used, for example, in an interactive program to present a specialized interface for displaying or modifying the settings. See the remote::SettingHandler documentation for examples.
Definition at line 65 of file setting.h.
Referenced by ion::base::SetTypeDescriptorForType().
|
inlineinherited |
Definition at line 203 of file setting.h.
Referenced by ion::base::Setting< bool >::FromString(), and ion::base::Setting< std::atomic< T > >::FromString().
|
inlineoverridevirtualinherited |
Returns a string version of this setting.
The same string may be passed to FromString to reconstruct an identical setting.
Implements ion::base::SettingBase.
|
inherited |
Removes the listener identified by key, if one exists.
Definition at line 46 of file setting.cc.
|
friend |