diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-04-02 19:07:14 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-04-02 19:07:14 +0000 |
commit | 43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0 (patch) | |
tree | 1a497ed7219d0450a0b33baf6a20d4b48f6b5404 /src/configuration.h | |
parent | e89ecd460dd2aa14aa7fd01292628fb74cb34692 (diff) | |
download | mana-43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0.tar.gz mana-43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0.tar.bz2 mana-43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0.tar.xz mana-43d51d4a7c00bb425d004acf7eeb5e4aa4e969b0.zip |
Added ConfigListener class to allow listening for changes to config options,
and added a GUI opacity slider to the setup window that utilizes this.
Diffstat (limited to 'src/configuration.h')
-rw-r--r-- | src/configuration.h | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/configuration.h b/src/configuration.h index 6f1cfb11..8c5a0470 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -24,12 +24,23 @@ #ifndef __INIREAD_H #define __INIREAD_H -#define INI_DELIMITER "=" -#define INI_COMMENTER "#" - #include <map> +#include <list> #include <string> + +/** + * The listener interface for receiving notifications about changes to + * configuration options. + * + * \ingroup CORE + */ +class ConfigListener +{ + public: + virtual void optionChanged(const std::string &name) = 0; +}; + /** * INI configuration handler for reading (and writing). * @@ -41,44 +52,56 @@ class Configuration { * \brief Reads INI file and parse all options into memory. * \param filename Full path to INI file (~/.manaworld/tmw.ini) */ - void init(std::string filename); + void init(const std::string &filename); /** * \brief Writes the current settings back to an ini-file. * \param filename Full path to INI file (~/.manaworld/tmw.ini) */ - bool write(std::string filename); + bool write(const std::string &filename); /** * \brief Sets an option using a string value. * \param key Option identifier. * \param value Value. */ - void setValue(std::string key, std::string value); + void setValue(const std::string &key, std::string value); /** * \brief Sets an option using a numeric value. * \param key Option identifier. * \param value Value. */ - void setValue(std::string key, float value); + void setValue(const std::string &key, float value); /** * \brief Gets a value as string. * \param key Option identifier. * \param deflt Default option if not there or error. */ - std::string getValue(std::string key, std::string deflt); + std::string getValue(const std::string &key, std::string deflt); /** * \brief Gets a value as numeric (float). * \param key Option identifier. * \param deflt Default option if not there or error. */ - float getValue(std::string key, float deflt); + float getValue(const std::string &key, float deflt); + + /** + * Adds a listener to the listen list of the specified config option. + */ + void addListener(const std::string &key, ConfigListener *listener); + + /** + * Removes a listener from the listen list of the specified config + * option. + */ + void removeListener(const std::string &key, ConfigListener *listener); private: std::map<std::string, std::string> options; + std::map<std::string, std::list<ConfigListener*> > listeners; }; #endif |