#include <Table.h>
Public Types | |
| typedef std::list< Observer * > | ObsList |
| List of observers. | |
| typedef std::list< Config * > | ConfigList |
| List of configurations. | |
| typedef std::pair< std::string, std::string > | NVPair |
| Configuration name/verison pair. | |
| typedef std::list< NVPair > | NVPairList |
| List of configuration name/verison pair. | |
| typedef std::map< Observer *, NVPairList > | ObsTable |
| Table of observers. | |
Public Member Functions | |
| Config * | GetConfig (const char *name, const char *version) const |
| void | GetObservers (const char *name, const char *version, ObsList &obslist) const |
| void | Print (std::ostream &os=std::cout) const |
| void | AdoptConfig (Config *cfg) |
| ConfigList & | GetList () |
| void | SetWatch (const char *cfg, const char *ver, Observer *obs) |
| void | RemoveWatch (const char *config, Observer *obs) |
| void | RemoveAllWatches (Observer *obs) |
Static Public Member Functions | |
| Table & | Instance () |
Private Attributes | |
| ConfigList | fConfigList |
| List of configurations defined. | |
| ObsTable | fObsTable |
| Table of registered clients. | |
Static Private Attributes | |
| Table * | fInstance = 0 |
| Sole instance of the table class. | |
Definition at line 21 of file Table.h.
|
|
List of configurations.
Definition at line 27 of file Table.h. Referenced by evdb::JobMenu::BuildConfigMenu(), evdb::EditMenu::EditMenu(), and GetList(). |
|
|
Configuration name/verison pair.
Definition at line 30 of file Table.h. Referenced by SetWatch(). |
|
|
List of configuration name/verison pair.
Definition at line 33 of file Table.h. Referenced by GetObservers(), RemoveAllWatches(), RemoveWatch(), and SetWatch(). |
|
|
List of observers.
Definition at line 24 of file Table.h. Referenced by cfg::ConfigEditor::Apply(), GetObservers(), Print(), and cfg::ConfigBuilder::Publish(). |
|
|
Table of observers.
|
|
|
Definition at line 103 of file Table.cxx. References fConfigList, cfg::Config::GetName(), and cfg::Config::GetVersion(). Referenced by cfg::ConfigEditor::Apply(), main(), and cfg::ConfigBuilder::Publish().
00104 {
00105 //======================================================================
00106 // Place the configuration into the list
00107 //======================================================================
00108 std::string n(cfg->GetName());
00109 std::string v(cfg->GetVersion());
00110
00111 // Check if a configuration matching this name and version exists.
00112 // If yes, replace it
00113 ConfigList::iterator itr (fConfigList.begin());
00114 ConfigList::iterator itrEnd(fConfigList.end());
00115 for (; itr!=itrEnd; ++itr) {
00116 cfg::Config* inlist = *itr;
00117 if (n == inlist->GetName() && v == inlist->GetVersion()) {
00118 // replace existing config with new
00119 delete inlist;
00120 *itr = cfg;
00121 return;
00122 }
00123 }
00124
00125 // Insert the configuration into the list
00126 fConfigList.push_back(cfg);
00127 }
|
|
||||||||||||
|
Definition at line 26 of file Table.cxx. References fConfigList, cfg::Config::GetName(), and cfg::Config::GetVersion(). Referenced by cfg::configBuilder::Build(), and cfg::Observer::SetWatch().
00028 {
00029 //======================================================================
00030 // Find and return the configuration that matches the requested name
00031 // and version
00032 //======================================================================
00033 std::string n(name);
00034 std::string v(version);
00035
00036 // Loop over configurations looking for one that matches
00037 ConfigList::iterator itr (fConfigList.begin());
00038 ConfigList::iterator itrEnd(fConfigList.end());
00039 for (; itr!=itrEnd; ++itr) {
00040 cfg::Config* cfg = *itr;
00041 if (n == cfg->GetName() && v == cfg->GetVersion()) return cfg;
00042 }
00043
00044 // Not found
00045 return 0;
00046 }
|
|
|
Definition at line 48 of file Table.h. References ConfigList, and fConfigList.
00048 { return fConfigList; }
|
|
||||||||||||||||
|
Definition at line 50 of file Table.cxx. References fObsTable, NVPairList, and ObsList. Referenced by cfg::ConfigEditor::Apply(), Print(), and cfg::ConfigBuilder::Publish().
00053 {
00054 //======================================================================
00055 // Unpack the observers of configuration "name.version" to the list
00056 // obslist
00057 //======================================================================
00058 ObsTable::iterator otItr (fObsTable.begin());
00059 ObsTable::iterator otItrEnd(fObsTable.end());
00060 for (; otItr!=otItrEnd; ++otItr) {
00061 cfg::Observer* obs = otItr->first;
00062 NVPairList& nvlist = otItr->second;
00063
00064 NVPairList::iterator nvItr(nvlist.begin());
00065 NVPairList::iterator nvItrEnd(nvlist.end());
00066 for (; nvItr != nvItrEnd; ++nvItr) {
00067 std::string& n = nvItr->first;
00068 std::string& v = nvItr->second;
00069
00070 if (n == name && v == version) obslist.push_back(obs);
00071
00072 } // Loop on configuration name/version pairs
00073 } // Loop on all observers
00074 }
|
|
|
Definition at line 15 of file Table.cxx. References fInstance. Referenced by cfg::ConfigEditor::Apply(), cfg::configBuilder::Build(), evdb::JobMenu::BuildConfigMenu(), evdb::EditMenu::EditMenu(), main(), cfg::ConfigBuilder::Publish(), cfg::Observer::RemoveAllWatches(), cfg::Observer::RemoveWatch(), and cfg::Observer::SetWatch().
00016 {
00017 //======================================================================
00018 // Return the sole instance of this class
00019 //======================================================================
00020 if (fInstance == 0) fInstance = new cfg::Table;
00021 return (*fInstance);
00022 }
|
|
|
Definition at line 78 of file Table.cxx. References fConfigList, cfg::Config::GetName(), GetObservers(), cfg::Config::GetVersion(), and ObsList. Referenced by main().
00079 {
00080 //======================================================================
00081 // Print all the configurations and their watchers
00082 //======================================================================
00083 ConfigList::const_iterator itr(fConfigList.begin());
00084 ConfigList::const_iterator itrEnd(fConfigList.end());
00085 for (; itr!=itrEnd; ++itr) {
00086 cfg::Config* c = *itr;
00087 os << c->GetName() << "." << c->GetVersion() << "\t";
00088
00089 os << "obs={ ";
00090 ObsList obslist;
00091 this->GetObservers(c->GetName(), c->GetVersion(), obslist);
00092 ObsList::const_iterator itr2(obslist.begin());
00093 ObsList::const_iterator itrEnd2(obslist.end());
00094 for (; itr2!=itrEnd2; ++itr2) {
00095 os << *itr2 << " ";
00096 }
00097 os << "}" << std::endl;
00098 }
00099 }
|
|
|
Definition at line 180 of file Table.cxx. References fObsTable, and NVPairList. Referenced by main(), and cfg::Observer::RemoveAllWatches().
00181 {
00182 // Erase the configuration list for this observer
00183 NVPairList& nvplist = fObsTable[obs];
00184 nvplist.clear();
00185
00186 fObsTable.erase(obs);
00187 }
|
|
||||||||||||
|
Definition at line 158 of file Table.cxx. References fObsTable, and NVPairList. Referenced by main(), and cfg::Observer::RemoveWatch().
00159 {
00160 //======================================================================
00161 // Drop the watch set by observer obs to the configuration named
00162 // "config"
00163 //======================================================================
00164 // Get the list of configuration name/version pairs
00165 NVPairList& nvlist = fObsTable[obs];
00166
00167 // Erase each entry which matches the config name
00168 NVPairList::iterator itr(nvlist.begin());
00169 NVPairList::iterator itrEnd(nvlist.end());
00170 for (; itr!=itrEnd; ++itr) {
00171 if (itr->first == config) {
00172 nvlist.erase(itr);
00173 return;
00174 }
00175 }
00176 }
|
|
||||||||||||||||
|
Definition at line 131 of file Table.cxx. References fObsTable, NVPair, and NVPairList. Referenced by cfg::Observer::SetWatch().
00134 {
00135 //======================================================================
00136 // Set a watch from observer obs to configuration with name
00137 // config.version
00138 //======================================================================
00139 NVPairList& nvlist = fObsTable[obs];
00140
00141 NVPairList::iterator itr (nvlist.begin());
00142 NVPairList::iterator itrEnd(nvlist.end());
00143
00144 // Look if there is already a watch for this configuration. If yes,
00145 // update the version watched
00146 for (; itr!=itrEnd; ++itr) {
00147 if (itr->first == config) {
00148 itr->second = version;
00149 return;
00150 }
00151 }
00152 // Reach here if no watch was set for this config
00153 nvlist.push_back(NVPair(config,version));
00154 }
|
|
|
List of configurations defined.
Definition at line 55 of file Table.h. Referenced by AdoptConfig(), GetConfig(), GetList(), and Print(). |
|
|
Sole instance of the table class.
Definition at line 11 of file Table.cxx. Referenced by Instance(). |
|
|
Table of registered clients.
Definition at line 56 of file Table.h. Referenced by GetObservers(), RemoveAllWatches(), RemoveWatch(), and SetWatch(). |
1.3.5