00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __INIREAD_H
00025 #define __INIREAD_H
00026
00027 #include <map>
00028 #include <list>
00029 #include <string>
00030
00031
00038 class ConfigListener
00039 {
00040 public:
00044 virtual ~ConfigListener();
00045
00050 virtual void optionChanged(const std::string &name) = 0;
00051 };
00052
00058 class Configuration
00059 {
00060 public:
00065 void init(const std::string &filename);
00066
00071 void write();
00072
00078 void setValue(const std::string &key, std::string value);
00079
00085 void setValue(const std::string &key, float value);
00086
00092 std::string getValue(const std::string &key, std::string deflt);
00093
00099 float getValue(const std::string &key, float deflt);
00100
00104 void addListener(const std::string &key, ConfigListener *listener);
00105
00110 void removeListener(const std::string &key, ConfigListener *listener);
00111
00112 private:
00113 std::map<std::string, std::string> options;
00114 std::map<std::string, std::list<ConfigListener*> > listeners;
00115
00116 std::string configPath;
00117 };
00118
00119 extern Configuration config;
00120
00121 #ifndef DEFAULT_SERVER_PORT
00122 #define DEFAULT_SERVER_PORT 9601
00123 #endif
00124 #endif