Concept Association of a particular SimFlag type with a list of SimFlag types. More...
#include <TDbiSimFlagAssociation.hxx>
Public Types | |
typedef list < DbiSimFlag::SimFlag_t > | SimList_t |
typedef map < DbiSimFlag::SimFlag_t, SimList_t > | SimMap_t |
Public Member Functions | |
TDbiSimFlagAssociation () | |
virtual | ~TDbiSimFlagAssociation () |
SimList_t | Get (const DbiSimFlag::SimFlag_t value) const |
void | Print (ostream &s) const |
void | Show () |
void | Clear () |
void | Set (const DbiSimFlag::SimFlag_t value, SimList_t list) |
void | Set (TDbiRegistry ®) |
Static Public Member Functions | |
static const TDbiSimFlagAssociation & | Instance () |
Get access to the one and only instance. | |
Private Attributes | |
SimMap_t | fAssociations |
Static Private Attributes | |
static const TDbiSimFlagAssociation * | fgInstance |
The one and only instance (owned by TDbiDatabaseManager). |
Concept Association of a particular SimFlag type with a list of SimFlag types.
Purpose To allow the DBI to choose an alternative SimFlag type when attempting to satisfy queries. For example, allow MC data to use Data constants. Contact: A.Finch@lancaster.ac.uk
Definition at line 44 of file TDbiSimFlagAssociation.hxx.
typedef list<DbiSimFlag::SimFlag_t> TDbiSimFlagAssociation::SimList_t |
Definition at line 51 of file TDbiSimFlagAssociation.hxx.
typedef map<DbiSimFlag::SimFlag_t,SimList_t > TDbiSimFlagAssociation::SimMap_t |
Definition at line 52 of file TDbiSimFlagAssociation.hxx.
TDbiSimFlagAssociation::TDbiSimFlagAssociation | ( | ) |
Definition at line 56 of file TDbiSimFlagAssociation.cxx.
References fgInstance, and SK_DBI_Trace.
00056 { 00057 // 00058 // 00059 // Purpose: Default constructor 00060 // 00061 // Contact: N. West 00062 // 00063 00064 00065 SK_DBI_Trace( "Creating TDbiSimFlagAssociation" << " "); 00066 00067 // Connect to global pointer; 00068 fgInstance = this; 00069 00070 }
TDbiSimFlagAssociation::~TDbiSimFlagAssociation | ( | ) | [virtual] |
Definition at line 75 of file TDbiSimFlagAssociation.cxx.
References fgInstance, and SK_DBI_Trace.
00075 { 00076 // 00077 // 00078 // Purpose: Destructor 00079 // 00080 // Contact: N. West 00081 // 00082 00083 00084 SK_DBI_Trace( "Destroying TDbiSimFlagAssociation" << " "); 00085 00086 // Disconnect from global pointer; 00087 if ( fgInstance == this ) fgInstance = 0; 00088 00089 }
void TDbiSimFlagAssociation::Clear | ( | ) | [inline] |
Definition at line 69 of file TDbiSimFlagAssociation.hxx.
References fAssociations.
Referenced by TDbiDatabaseManager::ClearSimFlagAssociation().
00069 { fAssociations.clear(); }
TDbiSimFlagAssociation::SimList_t TDbiSimFlagAssociation::Get | ( | const DbiSimFlag::SimFlag_t | value | ) | const |
Definition at line 93 of file TDbiSimFlagAssociation.cxx.
References fAssociations.
Referenced by ClassImp(), and TDbiCache::Search().
00093 { 00094 // 00095 // 00096 // Purpose: Return associated list 00097 // or just list containing value if none. 00098 // 00099 00100 SimMap_t::const_iterator itr = fAssociations.find(value); 00101 if ( itr != fAssociations.end() ) return itr->second; 00102 SimList_t l; 00103 l.push_back(value); 00104 return l; 00105 00106 }
const TDbiSimFlagAssociation & TDbiSimFlagAssociation::Instance | ( | ) | [static] |
Get access to the one and only instance.
Definition at line 110 of file TDbiSimFlagAssociation.cxx.
References fgInstance.
Referenced by ClassImp(), and TDbiCache::Search().
00110 { 00111 // 00112 // 00113 // Purpose: Get access to the one and only instance. 00114 // 00115 00116 // Program Notes:- 00117 // ============= 00118 00119 // If necessary, creates a TDbiSimFlagAssociation, but once 00120 // TDbiDatabaseManager.hxxas been created, it's owned version 00121 // will supersede it and orginal will be lost (leak). 00122 // In practice this should never happen; TDbiDatabaseManager is 00123 // the first significant object to be created. 00124 00125 if ( ! fgInstance ) new TDbiSimFlagAssociation; 00126 // The act of creation will set fgInstance. 00127 return *fgInstance; 00128 00129 }
void TDbiSimFlagAssociation::Print | ( | ostream & | s | ) | const |
Definition at line 132 of file TDbiSimFlagAssociation.cxx.
References DbiDetector::AsString(), and fAssociations.
00132 { 00133 // 00134 // 00135 // Purpose: Print self. 00136 00137 s << "\n\nSimFlag Association Status: "; 00138 if ( fAssociations.size() == 0 ) s <<"Not enabled" << endl; 00139 else { 00140 s << endl; 00141 00142 SimMap_t::const_iterator mapItr = fAssociations.begin(); 00143 SimMap_t::const_iterator mapItrEnd = fAssociations.end(); 00144 while ( mapItr != mapItrEnd ) { 00145 00146 DbiSimFlag::SimFlag_t value = mapItr->first; 00147 string name = DbiSimFlag::AsString(value); 00148 ostringstream buff; 00149 buff << name << "(" << value << ")"; 00150 name = buff.str(); 00151 if ( name.size() < 20 ) name.append(20-name.size(),' '); 00152 s << name << "maps to: "; 00153 00154 SimList_t l = mapItr->second; 00155 SimList_t::const_iterator listItr = l.begin(); 00156 SimList_t::const_iterator listItrEnd = l.end(); 00157 while ( listItr != listItrEnd ) { 00158 DbiSimFlag::SimFlag_t v = *listItr; 00159 string n = DbiSimFlag::AsString(v); 00160 s << n << "(" << v << ")"; 00161 ++listItr; 00162 if ( listItr != listItrEnd ) s << ", "; 00163 } 00164 s << endl; 00165 ++mapItr; 00166 } 00167 00168 } 00169 }
void TDbiSimFlagAssociation::Set | ( | TDbiRegistry & | reg | ) |
Definition at line 173 of file TDbiSimFlagAssociation.cxx.
References TDbiRegistry::Get(), DbiSimFlag::kUnknown, TDbiRegistry::RemoveKey(), Set(), Show(), SK_DBI_Warn, DbiDetector::StringToEnum(), and UtilString::StringTok().
00173 { 00174 // 00175 // 00176 // Purpose: Extract SimFlag association lists from TDbiRegistry. 00177 // 00178 // Arguments: 00179 // reg in TDbiRegistry containing "SimFlagAssociation:..." keys. 00180 // out Updated TDbiRegistry with these keys removed. 00181 // 00182 // Contact: N. West 00183 // 00184 // Specification:- 00185 // ============= 00186 // 00187 // o Extract SimFlag association lists from TDbiRegistry. 00188 00189 TDbiRegistry::TDbiRegistryKey keyItr(®); 00190 00191 Bool_t hasChanged = kFALSE; 00192 00193 const char* key = keyItr(); 00194 while ( key ) { 00195 00196 const char* nextKey = keyItr(); 00197 if ( ! strncmp("SimFlagAssociation:",key,19) ) { 00198 00199 // Found a SimFlagAssociation key, extract its value. 00200 string Name = key+19; 00201 DbiSimFlag::SimFlag_t value = DbiSimFlag::StringToEnum(Name.c_str()); 00202 const char* listChars = 0; 00203 bool ok = reg.Get(key,listChars) && (value != DbiSimFlag::kUnknown); 00204 // Collect the associated list 00205 SimList_t lv; 00206 if ( ok ) { 00207 vector<string> ls; 00208 UtilString::StringTok(ls,listChars,","); 00209 vector<string>::iterator itr = ls.begin(); 00210 vector<string>::iterator itrEnd = ls.end(); 00211 for (; itr != itrEnd; ++itr ) { 00212 DbiSimFlag::SimFlag_t v = DbiSimFlag::StringToEnum(itr->c_str()); 00213 if ( v == DbiSimFlag::kUnknown) ok = false; 00214 lv.push_back(v); 00215 } 00216 } 00217 00218 if ( ok ) { 00219 this->Set(value,lv); 00220 hasChanged = true; 00221 } 00222 else SK_DBI_Warn( "Illegal SimFlagAssociation registry item: " << key 00223 << " = " << listChars << " "); 00224 00225 reg.RemoveKey(key); 00226 } 00227 key = nextKey; 00228 } 00229 00230 if ( hasChanged ) this->Show(); 00231 }
void TDbiSimFlagAssociation::Set | ( | const DbiSimFlag::SimFlag_t | value, | |
SimList_t | list | |||
) | [inline] |
Definition at line 70 of file TDbiSimFlagAssociation.hxx.
References fAssociations.
Referenced by TDbiDatabaseManager::Config(), and Set().
00070 { 00071 fAssociations[value] = list; }
void TDbiSimFlagAssociation::Show | ( | ) |
Definition at line 235 of file TDbiSimFlagAssociation.cxx.
References SK_DBI_Info.
Referenced by Set().
00235 { 00236 // 00237 // 00238 // Purpose: 00239 00240 SK_DBI_Info( *this << " "); 00241 00242 00243 }
const TDbiSimFlagAssociation* TDbiSimFlagAssociation::fgInstance [static, private] |
The one and only instance (owned by TDbiDatabaseManager).
Definition at line 77 of file TDbiSimFlagAssociation.hxx.
Referenced by Instance(), TDbiSimFlagAssociation(), and ~TDbiSimFlagAssociation().