00001
00002
00003
00004
00006
00007
00008
00009
00010
00011
00012
00013
00014
00016
00017 #ifndef __IConfigManager_h_INCLUDED__
00018 #define __IConfigManager_h_INCLUDED__
00019
00020 #include "IRoot.h"
00021 #include "IObject.h"
00022
00023 #include <sstream>
00024 #include <vector>
00025 #include <string>
00026
00027 namespace mortic
00028 {
00030
00039 class IConfigSet
00040 {
00041 friend class IRoot;
00042 public:
00044 IConfigSet()
00045 { }
00047 ~IConfigSet()
00048 { }
00049
00051
00057 void setOption(std::string section, std::string key, std::string value)
00058 {
00059 sections.push_back(section);
00060 keys.push_back(key);
00061 values.push_back(value);
00062 }
00063
00064 std::vector<std::string> sections;
00065 std::vector<std::string> keys;
00066 std::vector<std::string> values;
00067 };
00068
00070
00091 class IConfigManager : public IObject
00092 {
00093 public:
00095
00098 IConfigManager(IRoot* root) : IObject(root, "ConfigManager")
00099 { }
00100
00102
00104 virtual ~IConfigManager()
00105 { }
00106
00108
00119 virtual std::string getOption(std::string section, std::string key, std::string def) = 0;
00120
00122
00130 template<typename T> T getOption(std::string section, std::string key, T def)
00131 {
00132 std::stringstream out;
00133 std::stringstream in;
00134 T outvar;
00135 out << def;
00136 in << getOption(section, key, out.str());
00137 in >> outvar;
00138 return outvar;
00139 }
00140
00142
00147 virtual void setOption(std::string section, std::string key, std::string value) = 0;
00148
00150
00157 template<typename T> void setOption(std::string section, std::string key, T value)
00158 {
00159 std::stringstream tmp;
00160 tmp << value;
00161 setOption(section, key, tmp.str());
00162 }
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 };
00178
00179 }
00180 ;
00181 #endif // __IConfigManager_h_INCLUDED__