#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 void | Browse (TBrowser *) |
| 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 }
|
|
|
Definition at line 74 of file Registry.h. 00074 {}
|
|
|
|
Dump to cerr.
Definition at line 138 of file Registry.cxx. References fKeysLocked, fMap, fValuesLocked, Nav::GetName(), 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 334 of file Registry.cxx. References RegistryItemXxx< T >::Get(), and MSG. 00335 {
00336 tRegMap::const_iterator mit = fMap.find(key);
00337 if (mit == fMap.end()) return false;
00338 // try correct type
00339 RegistryItemXxx<double>* rixd =
00340 dynamic_cast<RegistryItemXxx<double>*>(mit->second);
00341 if (rixd) {
00342 val = *(rixd->Get());
00343 return true;
00344 }
00345 // try int
00346 RegistryItemXxx<int>* rixi =
00347 dynamic_cast<RegistryItemXxx<int>*>(mit->second);
00348 if (rixi) {
00349 val = *(rixi->Get());
00350 return true;
00351 }
00352 MSG("Registry", Msg::kError) << "Key " << key
00353 << " does not have type double or int"
00354 << " as required" << endl;
00355 return false;
00356 }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
Access a value. Returns value if key lookup succeeds, else prints warning message. Use above Get() methods for a safer access method. |
|
|
|
|
|
Definition at line 382 of file Registry.cxx. References Nav::GetName(), and MSG. Referenced by Calibrator::ConfigScheme(), RegistryGui::GetRegistry(), and RegistryValidate::RunAllTests(). 00383 {
00384 Registry retval;
00385 if (Get(key,retval)) return retval;
00386 if (fErrorHandler) { fErrorHandler(); return retval; }
00387 else {
00388 MSG("Registry",Msg::kWarning)
00389 << "\nRegistry::GetTYPE: failed to get value for key \""
00390 << key << "\" from Registry \"" << this->GetName()
00391 << "\". Aborting\n\n";
00392 bool must_get_a_value = false;
00393 assert(must_get_a_value);
00394 return retval;
00395 }
00396 }
|
|
|
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 398 of file Registry.cxx. References fMap. Referenced by TrackFilterBFCalibFD::Config(), StopMuFinderFar::Configure(), InterGen_Neugen::Configure(), dump_keys(), DbuDaqFileSummary::FillMapFromString(), and CfgPromptConfigurable::SafeMerge(). 00399 {
00400 tRegMap::const_iterator mit = fMap.find(key);
00401 if (mit == fMap.end()) return typeid(void);
00402 return mit->second->GetType();
00403 }
|
|
|
Return "int", "double", "char", "string", "Registry" or "void".
Definition at line 404 of file Registry.cxx. References fMap. Referenced by CfgPromptConfigurable::SafeMerge(), Anp::SetKey(), and RegistryGui::SetRegistry(). 00405 {
00406 tRegMap::const_iterator mit = fMap.find(key);
00407 if (mit == fMap.end()) return "void";
00408 return mit->second->GetTypeAsString();
00409 }
|
|
|
see format.txt
Definition at line 411 of file Registry.cxx. References fMap, and PrintStream(). Referenced by CfgPromptConfigurable::SafeMerge(), RegistryGui::SetPossiblesMenu(), and RegistryGui::SetRegistry(). 00412 {
00413 ostringstream os;
00414 tRegMap::const_iterator mit = fMap.find(key);
00415 if (mit == fMap.end()) return "";
00416 mit->second->PrintStream(os);
00417 return os.str();
00418 }
|
|
|
Definition at line 91 of file Registry.h. Referenced by CfgConfigurable::Update(). 00091 { return fDirty; }
|
|
|
Definition at line 223 of file Registry.cxx. References RegistryKey. Referenced by InterGen_Neugen::Configure(), dump_keys(), DbuDaqFileSummary::FillMapFromString(), Merge(), operator=(), JobCDialog::Querry(), CfgDialog::Query(), Registry(), Cfg::RegistryToString(), CfgPromptConfigurable::SafeMerge(), Anp::SetKey(), RegistryGui::SetPossiblesMenu(), and RegistryGui::SetRegistry(). 00224 {
00225 return RegistryKey(this);
00226 }
|
|
|
|
Control if new key/value pairs can be added.
Definition at line 82 of file Registry.h. Referenced by BeamMonCuts::FillRegistry(), DbiConfigStream::operator>>(), CfgPromptConfigurable::SafeMerge(), Anp::SetKey(), and JobCModule::SetUniqueName(). 00082 { return fKeysLocked; }
|
|
|
|
|
Copy rhs into this, respects this's locks.
Definition at line 76 of file Registry.cxx. References fKeysLocked, fMap, Nav::GetName(), Key(), MSG, s(), and SetDirty(). Referenced by TestDataModule::Config(), Anp::StdHepTab::Config(), Anp::SnarlTimeTab::Config(), SetKNNModule::Config(), Anp::SelectTrue::Config(), Anp::SelectNuMu::Config(), Anp::SelectKinem::Config(), Anp::SelectCount::Config(), Anp::RunkNN::Config(), Anp::Interface::Config(), FitTrackMSListModule::Config(), FillDataModule::Config(), Anp::EventHitTab::Config(), Anp::EventAdcTab::Config(), DetSim::Config(), AlignmentModule::Config(), NC::FitMaster::DefaultConfig(), NCExtrapolationModule::DefaultConfig(), DetSim::DefaultConfig(), Cluster3DModule::DefaultConfig(), UgliLoanPool::Instance(), PlexLoanPool::Instance(), BfldLoanPool::Instance(), run(), 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, Nav::GetName(), PrintStream(), and Size(). Referenced by Anp::Interface::Config(), PulserTimeCalScheme::ConfigModified(), NuBeam::IsGoodSpillAndFillPot(), NtpTools::PassBeamCuts(), 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 }
|
|
|
Reimplemented in NuEvtKin, and RecJobRecord. Definition at line 184 of file Registry.cxx. References PrettyPrint(). Referenced by InterGen_Neugen::Configure(), MadTVAnalysis::CreatePAN(), MadMKAnalysis::CreatePAN(), RegistryValidate::DumpRegistry(), NCDataQualityModule::EndJob(), MicroDSTMaker::EndJob(), RerootToTruthModule::Get(), HepevtModule::Get(), PerValidate::OutputStreamMgr(), UgliLoanPool::Print(), PlexLoanPool::Print(), BfldLoanPool::Print(), NCExtrapolationModule::Run(), AltAlgStpPatternRecList::RunAlg(), AltAlgSliceList::RunAlg(), and RecValidate::TestRecordTempTags(). 00185 {
00186 this->PrettyPrint(cout);
00187 }
|
|
|
Print to cout (without extraneous bits of Dump()).
Reimplemented in RecJobRecord. Definition at line 475 of file Registry.cxx. References done(), fMap, Nav::GetName(), RegistryItem::GetTypeAsString(), and RegistryItem::PrintStream(). Referenced by NuEvtKin::FormatToOStream(), DbuDaqFileSummary::GetStringFromMap(), GetValueAsString(), operator<<(), DbiConfigStream::operator<<(), PrettyPrint(), RegistryValidate::ReadWriteTest(), BeamMonCuts::SetCutValues(), and OltNewModule::WriteConfig(). 00476 {
00477 os << "['" << this->GetName() << "'";
00478
00479 tRegMap::const_iterator mit, done = fMap.end();
00480 for (mit = fMap.begin(); mit != done; ++mit) {
00481 os << " '" << mit->first << "'=(";
00482 os << mit->second->GetTypeAsString();
00483 os << ")";
00484 mit->second->PrintStream(os);
00485 }
00486
00487 os << "]";
00488 return os;
00489 }
|
|
|
Definition at line 499 of file Registry.cxx. References bail(), fMap, Util::read_quoted_string(), RegistryItem::ReadStream(), and reg. Referenced by DbuDaqFileSummary::FillMapFromString(), BeamMonCuts::FillRegistry(), RegistryGui::GetRegistry(), DbiConfigStream::operator>>(), and RegistryValidate::ReadWriteTest(). 00500 {
00501 Registry reg;
00502
00503 char c;
00504 if (!is.get(c)) return bail(is);
00505 if (c != '[') {
00506 is.putback(c);
00507 return bail(is);
00508 }
00509 string name = Util::read_quoted_string(is);
00510 reg.SetName(name.c_str());
00511
00512 while (is.get(c)) {
00513 if (isspace(c)) continue;
00514 if (c == ']') {
00515 *this = reg;
00516 return is;
00517 }
00518 is.putback(c);
00519
00520 // get the key
00521 string key = read_quoted_string(is);
00522 if (key == "") return bail(is);
00523
00524 // skip the "="
00525 if (!is.get(c)) return bail(is);
00526
00527 // get the "("
00528 if (!is.get(c) || c != '(') {
00529 is.putback(c);
00530 return bail(is);
00531 }
00532
00533 // get the type
00534 string type;
00535 while (is.get(c)) {
00536 if (c == ')') break;
00537 type += c;
00538 }
00539
00540 // factory:
00541 RegistryItem* ri = 0;
00542 if (type == "char")
00543 ri = new RegistryItemXxx<char>();
00544 else if (type == "int")
00545 ri = new RegistryItemXxx<int>();
00546 else if (type == "double")
00547 ri = new RegistryItemXxx<double>();
00548 else if (type == "string")
00549 ri = new RegistryItemXxx<const char*>();
00550 else if (type == "Registry")
00551 ri = new RegistryItemXxx<Registry>();
00552 else return bail(is);
00553
00554 ri->ReadStream(is);
00555 reg.fMap[key] = ri;
00556 }
00557 return is;
00558
00559 }
|
|
|
Definition at line 111 of file Registry.cxx. References fMap, and SetDirty(). Referenced by Anp::Interface::Config(), DbiTableProxyRegistry::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. References Nav::GetName(), and MSG. 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 90 of file Registry.h. References fDirty. Referenced by Clear(), CfgPromptConfigurable::InitializeConfig(), Merge(), operator=(), Registry(), RemoveKey(), CfgPromptConfigurable::Set(), and CfgConfigurable::Update(). 00090 { fDirty = is_dirty; }
|
|
|
Definition at line 94 of file Registry.h. References fErrorHandler. Referenced by RegistryValidate::RunAllTests(). 00094 { fErrorHandler = eh; }
|
|
|
Return number of entries.
Definition at line 52 of file Registry.h. References fMap. Referenced by BMSpillAna::ChangeCutValues(), Calibrator::ConfigScheme(), SliceSRListModule::DefaultConfig(), SleepModule::DefaultConfig(), HistManModule::DefaultConfig(), CDFMonitoringModule::DefaultConfig(), BMSpillAna::DefaultConfig(), BDSpliceModule::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 77 of file Registry.h. Referenced by XTalkFilter::Config(), SystematicGains::Config(), PETrimmer::Config(), JobCModule::Config(), BeamMonCuts::FillRegistry(), DbiConfigStream::operator>>(), CfgPromptConfigurable::SafeMerge(), and Anp::SetKey(). 00077 { return fValuesLocked; }
|
|
|
not written out
Definition at line 157 of file Registry.h. Referenced by Key(). |
|
|
Definition at line 161 of file Registry.h. Referenced by SetDirty(). |
|
|
Definition at line 155 of file Registry.h. Referenced by SetErrorHandler(). |
|
|
Definition at line 154 of file Registry.h. Referenced by Dump(), LockKeys(), Merge(), operator=(), PrettyPrint(), Registry(), and UnLockKeys(). |
|
|
Definition at line 159 of file Registry.h. Referenced by Clear(), Dump(), GetType(), GetTypeAsString(), GetValueAsString(), KeyExists(), Merge(), Registry::RegistryKey::operator()(), operator=(), PrettyPrint(), PrintStream(), ReadStream(), Registry(), Registry::RegistryKey::RegistryKey(), RemoveKey(), Size(), and ~Registry(). |
|
|
Definition at line 153 of file Registry.h. Referenced by Clear(), Dump(), LockValues(), operator=(), PrettyPrint(), Registry(), and UnLockValues(). |
1.3.9.1