00001 #ifndef CAFE_CONFIG_HPP__
00002 #define CAFE_CONFIG_HPP__
00003
00004 #include <string>
00005 #include <vector>
00006 #include <set>
00007
00008 class TEnv;
00009 class TDirectory;
00010
00011 namespace cafe {
00012
00036 class Config {
00037 public:
00038 explicit Config(const std::string& name);
00039 virtual ~Config();
00040
00044
00045
00047 std::string get(const std::string& key, const std::string& def);
00048
00051 std::string get(const std::string& key, const char *def);
00052
00054 int get(const std::string& key, int def);
00055
00057 double get(const std::string& key, double def);
00058
00060 bool get(const std::string& key, bool def);
00061
00063 std::vector<std::string> getVString(const std::string& key, const std::string& delim = " ");
00064
00066 std::vector<float> getVFloat(const std::string& key, const std::string& delim = " ");
00067
00069 std::vector<int> getVInt(const std::string& key, const std::string& delim = " ");
00070
00072
00074 void set(const std::string& key, const std::string& value);
00075
00077 void dumpConfig(std::ostream& stream);
00078
00080 void dumpConfig(TDirectory* const dir, std::string const name = "configDB");
00081
00086 static std::vector<std::string> checkConfiguration();
00087
00089 static std::vector<std::string> variables(const std::string& name) ;
00090
00095 static void resolve();
00096
00097 private:
00098 static std::string replace(TEnv *env, const std::string& input);
00099 private:
00100 std::string _name;
00101 static TEnv& getEnv();
00102
00104 static std::set<std::string> s_accessed;
00105 };
00106 }
00107
00108 #endif // CAFE_CONFIG_HPP__