#include <DbiSimFlagAssociation.h>
Public Types | |
| typedef list< SimFlag::SimFlag_t > | SimList_t |
| typedef map< SimFlag::SimFlag_t, SimList_t > | SimMap_t |
Public Member Functions | |
| DbiSimFlagAssociation () | |
| virtual | ~DbiSimFlagAssociation () |
| SimList_t | Get (const SimFlag::SimFlag_t value) const |
| void | Print (ostream &s) const |
| void | Show () |
| void | Clear () |
| void | Set (const SimFlag::SimFlag_t value, SimList_t list) |
| void | Set (Registry ®) |
Static Public Member Functions | |
| static const DbiSimFlagAssociation & | Instance () |
| Get access to the one and only instance. | |
Private Attributes | |
| SimMap_t | fAssociations |
Static Private Attributes | |
| static const DbiSimFlagAssociation * | fgInstance = 0 |
| The one and only instance (owned by DbiTableProxyRegistry). | |
Definition at line 41 of file DbiSimFlagAssociation.h.
| typedef list<SimFlag::SimFlag_t> DbiSimFlagAssociation::SimList_t |
Definition at line 48 of file DbiSimFlagAssociation.h.
| typedef map<SimFlag::SimFlag_t,SimList_t > DbiSimFlagAssociation::SimMap_t |
Definition at line 49 of file DbiSimFlagAssociation.h.
| DbiSimFlagAssociation::DbiSimFlagAssociation | ( | ) |
Definition at line 56 of file DbiSimFlagAssociation.cxx.
References fgInstance, Msg::kVerbose, LEA_CTOR, and MSG.
00056 { 00057 // 00058 // 00059 // Purpose: Default constructor 00060 // 00061 // Contact: N. West 00062 // 00063 00064 LEA_CTOR //Leak Checker 00065 00066 MSG("Dbi", Msg::kVerbose) << "Creating DbiSimFlagAssociation" << endl; 00067 00068 // Connect to global pointer; 00069 fgInstance = this; 00070 00071 }
| DbiSimFlagAssociation::~DbiSimFlagAssociation | ( | ) | [virtual] |
Definition at line 76 of file DbiSimFlagAssociation.cxx.
References fgInstance, Msg::kVerbose, LEA_DTOR, and MSG.
00076 { 00077 // 00078 // 00079 // Purpose: Destructor 00080 // 00081 // Contact: N. West 00082 // 00083 00084 LEA_DTOR //Leak Checker 00085 00086 MSG("Dbi", Msg::kVerbose) << "Destroying DbiSimFlagAssociation" << endl; 00087 00088 // Disconnect from global pointer; 00089 if ( fgInstance == this ) fgInstance = 0; 00090 00091 }
| void DbiSimFlagAssociation::Clear | ( | ) | [inline] |
Definition at line 66 of file DbiSimFlagAssociation.h.
References fAssociations.
Referenced by DbiTableProxyRegistry::ClearSimFlagAssociation().
00066 { fAssociations.clear(); }
| DbiSimFlagAssociation::SimList_t DbiSimFlagAssociation::Get | ( | const SimFlag::SimFlag_t | value | ) | const |
Definition at line 95 of file DbiSimFlagAssociation.cxx.
References fAssociations.
Referenced by DbiValidityRecBuilder::DbiValidityRecBuilder(), and DbiCache::Search().
00095 { 00096 // 00097 // 00098 // Purpose: Return associated list 00099 // or just list containing value if none. 00100 // 00101 00102 SimMap_t::const_iterator itr = fAssociations.find(value); 00103 if ( itr != fAssociations.end() ) return itr->second; 00104 SimList_t l; 00105 l.push_back(value); 00106 return l; 00107 00108 }
| const DbiSimFlagAssociation & DbiSimFlagAssociation::Instance | ( | ) | [static] |
Get access to the one and only instance.
Definition at line 112 of file DbiSimFlagAssociation.cxx.
References fgInstance.
Referenced by DbiValidityRecBuilder::DbiValidityRecBuilder(), and DbiCache::Search().
00112 { 00113 // 00114 // 00115 // Purpose: Get access to the one and only instance. 00116 // 00117 00118 // Program Notes:- 00119 // ============= 00120 00121 // If necessary, creates a DbiSimFlagAssociation, but once 00122 // DbiTableProxyRegistry has been created, it's owned version 00123 // will supersede it and orginal will be lost (leak). 00124 // In practice this should never happen; DbiTableProxyRegistry is 00125 // the first significant object to be created. 00126 00127 if ( ! fgInstance ) new DbiSimFlagAssociation; 00128 // The act of creation will set fgInstance. 00129 return *fgInstance; 00130 00131 }
| void DbiSimFlagAssociation::Print | ( | ostream & | s | ) | const |
Definition at line 134 of file DbiSimFlagAssociation.cxx.
References SimFlag::AsString(), and fAssociations.
00134 { 00135 // 00136 // 00137 // Purpose: Print self. 00138 00139 s << "\n\nSimFlag Association Status: "; 00140 if ( fAssociations.size() == 0 ) s <<"Not enabled" << endl; 00141 else { 00142 s << endl; 00143 00144 SimMap_t::const_iterator mapItr = fAssociations.begin(); 00145 SimMap_t::const_iterator mapItrEnd = fAssociations.end(); 00146 while ( mapItr != mapItrEnd ) { 00147 00148 SimFlag::SimFlag_t value = mapItr->first; 00149 string name = SimFlag::AsString(value); 00150 ostringstream buff; 00151 buff << name << "(" << value << ")"; 00152 name = buff.str(); 00153 if ( name.size() < 20 ) name.append(20-name.size(),' '); 00154 s << name << "maps to: "; 00155 00156 SimList_t l = mapItr->second; 00157 SimList_t::const_iterator listItr = l.begin(); 00158 SimList_t::const_iterator listItrEnd = l.end(); 00159 while ( listItr != listItrEnd ) { 00160 SimFlag::SimFlag_t v = *listItr; 00161 string n = SimFlag::AsString(v); 00162 s << n << "(" << v << ")"; 00163 ++listItr; 00164 if ( listItr != listItrEnd ) s << ", "; 00165 } 00166 s << endl; 00167 ++mapItr; 00168 } 00169 00170 } 00171 }
| void DbiSimFlagAssociation::Set | ( | Registry & | reg | ) |
Definition at line 175 of file DbiSimFlagAssociation.cxx.
References Registry::Get(), SimFlag::kUnknown, Msg::kWarning, MSG, Particle::Name(), reg, Registry::RemoveKey(), Set(), Show(), SimFlag::StringToEnum(), and UtilString::StringTok().
00175 { 00176 // 00177 // 00178 // Purpose: Extract SimFlag association lists from Registry. 00179 // 00180 // Arguments: 00181 // reg in Registry containing "SimFlagAssociation:..." keys. 00182 // out Updated Registry with these keys removed. 00183 // 00184 // Contact: N. West 00185 // 00186 // Specification:- 00187 // ============= 00188 // 00189 // o Extract SimFlag association lists from Registry. 00190 00191 Registry::RegistryKey keyItr(®); 00192 00193 Bool_t hasChanged = kFALSE; 00194 00195 const char* key = keyItr(); 00196 while ( key ) { 00197 00198 const char* nextKey = keyItr(); 00199 if ( ! strncmp("SimFlagAssociation:",key,19) ) { 00200 00201 // Found a SimFlagAssociation key, extract its value. 00202 string Name = key+19; 00203 SimFlag::SimFlag_t value = SimFlag::StringToEnum(Name.c_str()); 00204 const char* listChars = 0; 00205 bool ok = reg.Get(key,listChars) && (value != SimFlag::kUnknown); 00206 // Collect the associated list 00207 SimList_t lv; 00208 if ( ok ) { 00209 vector<string> ls; 00210 UtilString::StringTok(ls,listChars,","); 00211 vector<string>::iterator itr = ls.begin(); 00212 vector<string>::iterator itrEnd = ls.end(); 00213 for (; itr != itrEnd; ++itr ) { 00214 SimFlag::SimFlag_t v = SimFlag::StringToEnum(itr->c_str()); 00215 if ( v == SimFlag::kUnknown) ok = false; 00216 lv.push_back(v); 00217 } 00218 } 00219 00220 if ( ok ) { 00221 this->Set(value,lv); 00222 hasChanged = true; 00223 } 00224 else MSG("Dbi",Msg::kWarning) 00225 << "Illegal SimFlagAssociation registry item: " << key 00226 << " = " << listChars << endl; 00227 00228 reg.RemoveKey(key); 00229 } 00230 key = nextKey; 00231 } 00232 00233 if ( hasChanged ) this->Show(); 00234 }
| void DbiSimFlagAssociation::Set | ( | const SimFlag::SimFlag_t | value, | |
| SimList_t | list | |||
| ) | [inline] |
Definition at line 67 of file DbiSimFlagAssociation.h.
References fAssociations.
Referenced by DbiTableProxyRegistry::Config(), and Set().
00067 { 00068 fAssociations[value] = list; }
| void DbiSimFlagAssociation::Show | ( | ) |
Definition at line 238 of file DbiSimFlagAssociation.cxx.
References Msg::kInfo, and MSG.
Referenced by Set().
00238 { 00239 // 00240 // 00241 // Purpose: 00242 00243 MSG("Dbi",Msg::kInfo) << *this << endl; 00244 00245 00246 }
SimMap_t DbiSimFlagAssociation::fAssociations [private] |
const DbiSimFlagAssociation * DbiSimFlagAssociation::fgInstance = 0 [static, private] |
The one and only instance (owned by DbiTableProxyRegistry).
Definition at line 74 of file DbiSimFlagAssociation.h.
Referenced by DbiSimFlagAssociation(), Instance(), and ~DbiSimFlagAssociation().
1.4.7