00001 00002 00003 00004 00005 00006 00007 00008 #ifndef CFG_TABLE_H 00009 #define CFG_TABLE_H 00010 #include <iostream> 00011 #include <string> 00012 #include <list> 00013 #include <map> 00014 namespace cfg { 00015 class Config; 00016 class Observer; 00017 } 00018 00019 namespace cfg { 00021 class Table { 00022 public: 00024 typedef std::list<Observer*> ObsList; 00025 00027 typedef std::list<Config*> ConfigList; 00028 00030 typedef std::pair<std::string,std::string> NVPair; 00031 00033 typedef std::list<NVPair> NVPairList; 00034 00036 typedef std::map<Observer*,NVPairList> ObsTable; 00037 00038 public: 00039 static Table& Instance(); 00040 00041 Config* GetConfig (const char* name, const char* version) const; 00042 void GetObservers(const char* name, 00043 const char* version, 00044 ObsList& obslist) const; 00045 void Print(std::ostream& os=std::cout) const; 00046 00047 void AdoptConfig(Config* cfg); 00048 ConfigList& GetList() { return fConfigList; } 00049 void SetWatch(const char* cfg, const char* ver, Observer* obs); 00050 void RemoveWatch(const char* config, Observer* obs); 00051 void RemoveAllWatches(Observer* obs); 00052 00053 private: 00054 static Table* fInstance; 00055 mutable ConfigList fConfigList; 00056 mutable ObsTable fObsTable; 00057 }; 00058 } 00059 00060 #endif // CFGTABLE_H 00061
1.3.5