#include <Registry.h>
Inheritance diagram for Registry:

Public Types | |
| typedef std::map< std::string, RegistryItem * > | tRegMap |
| typedef void(* | ErrorHandler )(void) |
Public Member Functions | |
| Registry (bool readonly=true) | |
| Registry (const Registry &rhs) | |
| Deep copy constructor. | |
| virtual | ~Registry () |
| Registry & | operator= (const Registry &rhs) |
| Deep assignment. | |
| void | Merge (const Registry &rhs) |
| Copy rhs into this, respects this's locks. | |
| unsigned int | Size () const |
| Return number of entries. | |
| bool | KeyExists (const char *key) const |
| Check if key exists. | |
| void | RemoveKey (const char *key) |
| void | Clear (Option_t *option="") |
| Clear Registry - deletes all items. | |
| void | Dump (void) const |
| Dump to cerr. | |
| virtual std::ostream & | PrintStream (std::ostream &os) const |
| Print to cout (without extraneous bits of Dump()). | |
| virtual std::istream & | ReadStream (std::istream &is) |
| virtual void | Print (Option_t *option="") const |
| virtual std::ostream & | PrettyPrint (std::ostream &os) const |
| virtual bool | ValuesLocked (void) const |
| Control if an existing value can be set. | |
| virtual void | LockValues (void) |
| virtual void | UnLockValues (void) |
| virtual bool | KeysLocked (void) const |
| Control if new key/value pairs can be added. | |
| virtual void | LockKeys (void) |
| virtual void | UnLockKeys (void) |
| void | SetDirty (bool is_dirty=true) |
| bool | IsDirty () |
| void | SetErrorHandler (ErrorHandler eh) |
| bool | Get (const char *key, char &c) const |
| bool | Get (const char *key, const char *&s) const |
| bool | Get (const char *key, int &i) const |
| bool | Get (const char *key, double &d) const |
| bool | Get (const char *key, Registry &r) const |
| const type_info & | GetType (const char *key) const |
| std::string | GetTypeAsString (const char *key) const |
| Return "int", "double", "char", "string", "Registry" or "void". | |
| std::string | GetValueAsString (const char *key) const |
| see format.txt | |
| char | GetChar (const char *key) const |
| const char * | GetCharString (const char *key) const |
| int | GetInt (const char *key) const |
| double | GetDouble (const char *key) const |
| Registry | GetRegistry (const char *key) const |
| bool | Set (const char *key, char c) |
| bool | Set (const char *key, const char *s) |
| bool | Set (const char *key, int i) |
| bool | Set (const char *key, double d) |
| bool | Set (const char *key, Registry r) |
| RegistryKey | Key (void) const |
Private Attributes | |
| bool | fValuesLocked |
| bool | fKeysLocked |
| ErrorHandler | fErrorHandler |
| tRegMap | fMap |
| bool | fDirty |
Friends | |
| class | RegistryKey |
| not written out | |
Registry
Contact: bv@bnl.gov
Created on: Wed Oct 25 17:13:16 2000
Definition at line 29 of file Registry.h.
|
|
Definition at line 33 of file Registry.h. |
|
|
Definition at line 32 of file Registry.h. |
|
|
Create a Registry. If readonly is false, any key's value can be set multiple times, o.w. only the first setting is allowed. See methods below regarding locking of keys and values. Definition at line 28 of file Registry.cxx. References MSG. 00029 : fValuesLocked(readonly), 00030 fKeysLocked(false), 00031 fErrorHandler(0) 00032 { 00033 MSG("Registry",Msg::kVerbose) << "Creating Registry at " << (void * ) this << endl; 00034 this->SetDirty(); 00035 }
|
|
|
Deep copy constructor.
Definition at line 38 of file Registry.cxx. References fKeysLocked, fMap, fValuesLocked, Key(), MSG, s(), and SetDirty(). 00038 : TNamed(rhs)
00039 {
00040 MSG("Registry",Msg::kVerbose) << "Creating Registry at " << (void * ) this << endl;
00041 RegistryKey rk = rhs.Key();
00042 const char* s;
00043
00044 while ( (s = rk()) ) fMap[s] = rhs.fMap.find(s)->second->Dup();
00045
00046 fValuesLocked = rhs.fValuesLocked;
00047 fKeysLocked = rhs.fKeysLocked;
00048 this->SetDirty();
00049 this->SetName(rhs.GetName());
00050 }
|
|
|
Definition at line 190 of file Registry.cxx. References fMap. 00191 {
00192 tRegMap::iterator mit = fMap.begin();
00193 while (mit != fMap.end()) {
00194 delete mit->second;
00195 ++mit;
00196 }
00197 }
|
|
|
Clear Registry - deletes all items.
Definition at line 120 of file Registry.cxx. References fMap, fValuesLocked, MSG, and SetDirty(). Referenced by AlgEventSRList::AddObjectToEvent(), DbuDaqFileSummary::FillMapFromString(), CfgPromptConfigurable::InitializeConfig(), operator=(), DbiConfigStream::operator>>(), NueReweight::Reset(), RegistryValidate::RunAllTests(), AlgSliceSRList::SlicetheSnarl(), AlgSliceSRList::SlicetheSnarl_ASAP(), and AlgSliceSRList::SlicetheSnarl_MST(). 00121 {
00122 if (fValuesLocked || fKeysLocked) {
00123 MSG("Registry",Msg::kWarning)
00124 << "Clear: can't, there are locks in \""
00125 << this->GetName() << "\"\n";
00126 return;
00127 }
00128
00129 tRegMap::iterator mit = fMap.begin();
00130 while (mit != fMap.end()) {
00131 delete mit->second;
00132 ++mit;
00133 }
00134 fMap.clear();
00135 this->SetDirty();
00136 }
|
|
|
Dump to cerr.
Definition at line 138 of file Registry.cxx. References fKeysLocked, fMap, fValuesLocked, MSG, and Size(). 00139 {
00140 this->TNamed::Dump();
00141 tRegMap::const_iterator mit = fMap.begin();
00142 MSG("Registry",Msg::kInfo)
00143 << "Registry: `" << this->GetName() << "', "
00144 << this->Size() << " entries."
00145 << " (Locks: [Keys|Values] `key', `value'):\n";
00146 while (mit != fMap.end()) {
00147 MSG("Registry",Msg::kInfo)
00148 << " [" << (fKeysLocked ? 'L' : 'U') << "|"
00149 << (fValuesLocked ? 'L' : 'U') << "] "
00150 << "`" << mit->first << "', `";
00151 mit->second->Dump();
00152 MSG("Registry",Msg::kInfo) << "'\n";
00153 ++mit;
00154 }
00155
00156 }
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 328 of file Registry.cxx. References RegistryItemXxx< T >::Get(). 00329 {
00330 tRegMap::const_iterator mit = fMap.find(key);
00331 if (mit == fMap.end()) return false;
00332 // try correct type
00333 RegistryItemXxx<double>* rixd =
00334 dynamic_cast<RegistryItemXxx<double>*>(mit->second);
00335 if (rixd) {
00336 val = *(rixd->Get());
00337 return true;
00338 }
00339 // try int
00340 RegistryItemXxx<int>* rixi =
00341 dynamic_cast<RegistryItemXxx<int>*>(mit->second);
00342 if (rixi) {
00343 val = *(rixi->Get());
00344 return true;
00345 }
00346 return false;
00347 }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
Access a value. Returns value if key lookup succeeds, else prints warning message. Use above Get() methods for a safer access method. |
|
|
|
|
|
Referenced by Calibrator::ConfigScheme(), RegistryGui::GetRegistry(), and RegistryValidate::RunAllTests(). |
|
|
Return the type_info of the value corresponding to the given key. If key doesn't exist, type_info for type void is returned. Definition at line 374 of file Registry.cxx. References RegistryItem::GetType(). Referenced by StopMuFinderFar::Configure(), dump_keys(), DbuDaqFileSummary::FillMapFromString(), and CfgPromptConfigurable::SafeMerge(). 00375 {
00376 tRegMap::const_iterator mit = fMap.find(key);
00377 if (mit == fMap.end()) return typeid(void);
00378 return mit->second->GetType();
00379 }
|
|
|
Return "int", "double", "char", "string", "Registry" or "void".
Definition at line 380 of file Registry.cxx. References fMap, and RegistryItem::GetTypeAsString(). Referenced by RegistryGui::SetRegistry(). 00381 {
00382 tRegMap::const_iterator mit = fMap.find(key);
00383 if (mit == fMap.end()) return "void";
00384 return mit->second->GetTypeAsString();
00385 }
|
|
|
see format.txt
Definition at line 387 of file Registry.cxx. References fMap, and RegistryItem::PrintStream(). Referenced by CfgPromptConfigurable::SafeMerge(), RegistryGui::SetPossiblesMenu(), and RegistryGui::SetRegistry(). 00388 {
00389 ostringstream os;
00390 tRegMap::const_iterator mit = fMap.find(key);
00391 if (mit == fMap.end()) return "";
00392 mit->second->PrintStream(os);
00393 return os.str();
00394 }
|
|
|
Definition at line 87 of file Registry.h. Referenced by CfgConfigurable::Update(). 00087 { return fDirty; }
|
|
|
Definition at line 223 of file Registry.cxx. References RegistryKey. Referenced by dump_keys(), DbuDaqFileSummary::FillMapFromString(), Merge(), operator=(), JobCDialog::Querry(), CfgDialog::Query(), Registry(), Cfg::RegistryToString(), CfgPromptConfigurable::SafeMerge(), RegistryGui::SetPossiblesMenu(), and RegistryGui::SetRegistry(). 00224 {
00225 return RegistryKey(this);
00226 }
|
|
|
Check if key exists.
Definition at line 106 of file Registry.cxx. References fMap. Referenced by JobCDemoModuleA::Config(), StopMuFinderFar::Configure(), UgliLoanPool::Instance(), PlexLoanPool::Instance(), RegistryValidate::RunAllTests(), CfgPromptConfigurable::SafeMerge(), JobCModule::SetUniqueName(), PlexLoanPool::~PlexLoanPool(), and UgliLoanPool::~UgliLoanPool().
|
|
|
Control if new key/value pairs can be added.
Definition at line 78 of file Registry.h. Referenced by DbiConfigStream::operator>>(), CfgPromptConfigurable::SafeMerge(), and JobCModule::SetUniqueName(). 00078 { return fKeysLocked; }
|
|
|
|
|
Copy rhs into this, respects this's locks.
Definition at line 76 of file Registry.cxx. References fKeysLocked, fMap, Key(), MSG, s(), and SetDirty(). Referenced by ThruMuonListModule::Config(), MSTClusterListModule::Config(), FitTrackMSListModule::Config(), FitThruMuonListModule::Config(), DigiPairListModule::Config(), DetSim::Config(), CutDigiPairListModule::Config(), BandClusterListModule::Config(), AlignmentModule::Config(), DetSim::DefaultConfig(), Cluster3DModule::DefaultConfig(), UgliLoanPool::Instance(), PlexLoanPool::Instance(), BfldLoanPool::Instance(), RegistryValidate::RunAllTests(), JobCModule::Set(), CfgConfigurable::Set(), and testConf(). 00077 {
00078 if (this == &rhs) return;
00079
00080 RegistryKey rk = rhs.Key();
00081 const char* s;
00082 while ( (s = rk()) ) {
00083 tRegMap::iterator mit = fMap.find(s);
00084 bool exists = mit != fMap.end();
00085
00086 if (fKeysLocked && !exists) {
00087 MSG("Registry",Msg::kWarning)
00088 << "Merge: can't, add new key " << s <<", keys locked."
00089 << " merger=" << this->GetName()
00090 << ", mergie=" << rhs.GetName() << endl;
00091 continue;
00092 }
00093 if (exists && fValuesLocked) {
00094 MSG("Registry",Msg::kWarning)
00095 << "Merge: can't, merge key " << s <<", values locked."
00096 << " merger=" << this->GetName()
00097 << ", mergie=" << rhs.GetName() << endl;
00098 continue;
00099 }
00100 if (exists) delete mit->second;
00101 fMap[s] = rhs.fMap.find(s)->second->Dup();
00102 }
00103 this->SetDirty();
00104 }
|
|
|
Deep assignment.
Definition at line 52 of file Registry.cxx. References Clear(), fKeysLocked, fMap, fValuesLocked, Key(), s(), SetDirty(), Size(), UnLockKeys(), and UnLockValues(). 00053 {
00054 if (this == &rhs) return *this;
00055
00056 UnLockValues();
00057 UnLockKeys();
00058
00059 // If we are already holding something - clear it.
00060 if (Size() != 0) Clear();
00061
00062 RegistryKey rk = rhs.Key();
00063 const char* s;
00064
00065 while ( (s = rk()) ) fMap[s] = rhs.fMap.find(s)->second->Dup();
00066
00067 fValuesLocked = rhs.fValuesLocked;
00068 fKeysLocked = rhs.fKeysLocked;
00069 this->SetDirty();
00070 this->SetName(rhs.GetName());
00071
00072 // Do like copy ctor.
00073 return *this;
00074 }
|
|
|
Definition at line 158 of file Registry.cxx. References fKeysLocked, fMap, fValuesLocked, PrintStream(), and Size(). Referenced by Print(), CalScheme::PrintConfig(), JobCModule::Report(), and CfgPromptConfigurable::SafeMerge(). 00159 {
00160 static int print_depth = 0;
00161
00162 // print (to cout) the registry
00163 tRegMap::const_iterator mit = this->fMap.begin();
00164 for(int i=0; i<print_depth; ++i) os << " ";
00165 os << "\"" << this->GetName() << "\", "
00166 << this->Size() << " entries."
00167 << " keys " << (this->fKeysLocked ? "locked" : "unlocked")
00168 << ", values " << (this->fValuesLocked ? "locked" : "unlocked")
00169 << "\n";
00170
00171 print_depth+=4;
00172 while (mit != this->fMap.end()) {
00173 for(int i=0; i<print_depth; ++i) os << " ";
00174
00175 os << mit->first << " = ";
00176 mit->second->PrintStream(os);
00177 os << endl;
00178 ++mit;
00179 }
00180 print_depth-=4;
00181 return os;
00182 }
|
|
|
Definition at line 184 of file Registry.cxx. References PrettyPrint(). Referenced by MadMKAnalysis::CreatePAN(), RegistryValidate::DumpRegistry(), PerValidate::OutputStreamMgr(), UgliLoanPool::Print(), PlexLoanPool::Print(), BfldLoanPool::Print(), AltAlgStpPatternRecList::RunAlg(), and AltAlgSliceList::RunAlg(). 00185 {
00186 this->PrettyPrint(cout);
00187 }
|
|
|
Print to cout (without extraneous bits of Dump()).
Definition at line 451 of file Registry.cxx. References done(), fMap, RegistryItem::GetTypeAsString(), and RegistryItem::PrintStream(). Referenced by DbuDaqFileSummary::GetStringFromMap(), operator<<(), DbiConfigStream::operator<<(), PrettyPrint(), RegistryValidate::ReadWriteTest(), and OltNewModule::WriteConfig(). 00452 {
00453 os << "['" << this->GetName() << "'";
00454
00455 tRegMap::const_iterator mit, done = fMap.end();
00456 for (mit = fMap.begin(); mit != done; ++mit) {
00457 os << " '" << mit->first << "'=(";
00458 os << mit->second->GetTypeAsString();
00459 os << ")";
00460 mit->second->PrintStream(os);
00461 }
00462
00463 os << "]";
00464 return os;
00465 }
|
|
|
Definition at line 475 of file Registry.cxx. References bail(), fMap, name, Util::read_quoted_string(), and RegistryItem::ReadStream(). Referenced by DbuDaqFileSummary::FillMapFromString(), RegistryGui::GetRegistry(), DbiConfigStream::operator>>(), and RegistryValidate::ReadWriteTest(). 00476 {
00477 Registry reg;
00478
00479 char c;
00480 if (!is.get(c)) return bail(is);
00481 if (c != '[') {
00482 is.putback(c);
00483 return bail(is);
00484 }
00485 string name = Util::read_quoted_string(is);
00486 reg.SetName(name.c_str());
00487
00488 while (is.get(c)) {
00489 if (isspace(c)) continue;
00490 if (c == ']') {
00491 *this = reg;
00492 return is;
00493 }
00494 is.putback(c);
00495
00496 // get the key
00497 string key = read_quoted_string(is);
00498 if (key == "") return bail(is);
00499
00500 // skip the "="
00501 if (!is.get(c)) return bail(is);
00502
00503 // get the "("
00504 if (!is.get(c) || c != '(') {
00505 is.putback(c);
00506 return bail(is);
00507 }
00508
00509 // get the type
00510 string type;
00511 while (is.get(c)) {
00512 if (c == ')') break;
00513 type += c;
00514 }
00515
00516 // factory:
00517 RegistryItem* ri = 0;
00518 if (type == "char")
00519 ri = new RegistryItemXxx<char>();
00520 else if (type == "int")
00521 ri = new RegistryItemXxx<int>();
00522 else if (type == "double")
00523 ri = new RegistryItemXxx<double>();
00524 else if (type == "string")
00525 ri = new RegistryItemXxx<const char*>();
00526 else if (type == "Registry")
00527 ri = new RegistryItemXxx<Registry>();
00528 else return bail(is);
00529
00530 ri->ReadStream(is);
00531 reg.fMap[key] = ri;
00532 }
00533 return is;
00534
00535 }
|
|
|
Definition at line 111 of file Registry.cxx. References fMap, and SetDirty(). Referenced by ThruMuonListModule::Config(), MSTClusterListModule::Config(), FitThruMuonListModule::Config(), DigiPairListModule::Config(), DbiTableProxyRegistry::Config(), CutDigiPairListModule::Config(), BandClusterListModule::Config(), RecRecordImp< T >::HasBeenModified(), RecMinos::HasBeenModified(), UgliLoanPool::ReadFromFile(), PlexLoanPool::ReadFromFile(), RegistryValidate::RunAllTests(), DbiSimFlagAssociation::Set(), and DbiRollbackDates::Set(). 00112 {
00113 tRegMap::iterator dead = fMap.find(key);
00114 if (dead == fMap.end()) return;
00115 fMap.erase(dead);
00116 delete dead->second;
00117 this->SetDirty();
00118 }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 271 of file Registry.cxx. 00272 {
00273 tRegMap::iterator mit = fMap.find(key);
00274 if (mit != fMap.end()) { // Found it
00275 if (fValuesLocked) {
00276 MSG("Registry",Msg::kWarning)
00277 << "Set: Values are locked - not overwriting `"
00278 << key << "\" with \"" << val << "\" in registry \"" << this->GetName() << "\"\n";
00279 return false;
00280 }
00281 if (! dynamic_cast<RegistryItemXxx<const char*>*>(mit->second) ) {
00282 MSG("Registry",Msg::kWarning)
00283 << "Set: attempt to overwrite old value for key \""
00284 << key << "\" with different type value "
00285 << val << " in registry \"" << this->GetName() << "\"\n";
00286 return false;
00287 }
00288 delete mit->second;
00289 fMap.erase(mit);
00290 }
00291 else { // didn't find it
00292 if (fKeysLocked) {
00293 MSG("Registry",Msg::kWarning)
00294 << "Registry::Set: Keys are locked - not adding `"
00295 << key << "' in registry \"" << this->GetName() << "\"\n";
00296 return false;
00297 }
00298 }
00299
00300 char** cpp = new char*;
00301 (*cpp) = new char [strlen(val)+1];
00302 strcpy(*cpp,val);
00303 const char** ccpp = const_cast<const char**>(cpp);
00304 RegistryItem* ri = new RegistryItemXxx< const char* >(ccpp);
00305 fMap[key] = ri;
00306 this->SetDirty();
00307 return true;
00308 }
|
|
||||||||||||
|
|
Access an internal "dirty" flag Registry maintains (but does not use) It will be set any time a non-const method is accessed, or explicitly via SetDirty(). Initially a Registry is dirty (original sin?). Definition at line 86 of file Registry.h. References fDirty. Referenced by Clear(), CfgPromptConfigurable::InitializeConfig(), Merge(), operator=(), Registry(), RemoveKey(), CfgPromptConfigurable::Set(), and CfgConfigurable::Update(). 00086 { fDirty = is_dirty; }
|
|
|
Definition at line 90 of file Registry.h. References fErrorHandler. Referenced by RegistryValidate::RunAllTests(). 00090 { fErrorHandler = eh; }
|
|
|
Return number of entries.
Definition at line 52 of file Registry.h. References fMap. Referenced by Calibrator::ConfigScheme(), SliceSRListModule::DefaultConfig(), SleepModule::DefaultConfig(), HistManModule::DefaultConfig(), CDFMonitoringModule::DefaultConfig(), BeamMonBaseModule::DefaultConfigWritable(), Dump(), dump_keys(), operator=(), PrettyPrint(), RegistryValidate::ReadWriteTest(), and RegistryValidate::RunAllTests(). 00052 { return fMap.size(); }
|
|
|
|
|
Control if an existing value can be set.
Definition at line 73 of file Registry.h. Referenced by JobCModule::Config(), DbiConfigStream::operator>>(), and CfgPromptConfigurable::SafeMerge(). 00073 { return fValuesLocked; }
|
|
|
not written out
Definition at line 153 of file Registry.h. Referenced by Key(). |
|
|
Definition at line 157 of file Registry.h. Referenced by SetDirty(). |
|
|
Definition at line 151 of file Registry.h. Referenced by SetErrorHandler(). |
|
|
Definition at line 150 of file Registry.h. Referenced by Dump(), LockKeys(), Merge(), operator=(), PrettyPrint(), Registry(), and UnLockKeys(). |
|
|
Definition at line 155 of file Registry.h. Referenced by Clear(), Dump(), GetTypeAsString(), GetValueAsString(), KeyExists(), Merge(), Registry::RegistryKey::operator()(), operator=(), PrettyPrint(), PrintStream(), ReadStream(), Registry(), Registry::RegistryKey::RegistryKey(), RemoveKey(), Size(), and ~Registry(). |
|
|
Definition at line 149 of file Registry.h. Referenced by Clear(), Dump(), LockValues(), operator=(), PrettyPrint(), Registry(), and UnLockValues(). |
1.3.9.1