#include <DbiConfigStream.h>
Public Member Functions | |
| DbiConfigStream () | |
| DbiConfigStream (const std::string &SoftwName, const std::string &ConfigName="default", VldContext vc=DbiConfigStream::fgDefaultContext, Dbi::Task task=0, const std::string &tableName="SOFTWARE_CONFIGURATION") | |
| virtual | ~DbiConfigStream () |
| const DbiConfigStream & | operator>> (Registry *reg) |
| const DbiConfigSet * | GetConfigSet () const |
| DbiConfigStream & | operator<< (const Registry *reg) |
| Bool_t | IsEmpty () |
| DbiValidityRec & | GetValidityRec () |
| Bool_t | Write (UInt_t dbNo=0, const std::string &logComment="", Bool_t localTest=false) |
Static Public Attributes | |
| VldContext | fgDefaultContext |
Private Member Functions | |
| DbiConfigStream (const DbiConfigStream &) | |
Private Attributes | |
| const DbiConfigSet * | fCFSet |
| DbiResultPtr< DbiConfigSet > | fCFSetTable |
| Pointer to ConfigSet table. | |
| DbiConfigSet | fCFSetModified |
| Local DbiConfigSet (empty until/unless filled using operator <<). | |
| DbiValidityRec | fVRec |
| Associated validity rec (used when writing back to the database). | |
| std::string | fConfigName |
| Name of the configuration set. | |
| std::string | fSoftwName |
| Name of the software system to be configured. | |
DatabaseInterface
Contact: n.west1@physics.ox.ac.uk
Definition at line 38 of file DbiConfigStream.h.
|
|
Definition at line 34 of file DbiConfigStream.cxx. 00034 : 00035 fCFSet(0) 00036 { 00037 // 00038 // 00039 // Purpose: Default constructor 00040 // 00041 // Arguments: None. 00042 // 00043 // Return: n/a 00044 // 00045 // Contact: N. West 00046 // 00047 // Specification:- 00048 // ============= 00049 // 00050 // o Create dummy ConfigStream. 00051 00052 00053 // Program Notes:- 00054 // ============= 00055 00056 // None. 00057 00058 LEA_CTOR //Leak Checker 00059 00060 MSG("Dbi", Msg::kDebug) << "Creating DbiConfigStream" << endl; 00061 }
|
|
||||||||||||||||||||||||
|
Definition at line 65 of file DbiConfigStream.cxx. References fCFSet, fCFSetTable, fConfigName, fSoftwName, fVRec, DbiConfigSet::GetAggregateNo(), DbiResultPtr< T >::GetNumRows(), DbiConfigSet::GetParamValue(), DbiResultPtr< T >::GetRow(), DbiResultPtr< T >::GetValidityRec(), LEA_CTOR, MSG, DbiValidityRec::SetDbNo(), DbiValidityRec::SetTableProxy(), and DbiValidityRec::SetVldRange(). 00069 : 00070 fCFSet(0), 00071 fCFSetTable(tableName,vc,task), 00072 fConfigName(ConfigName), 00073 fSoftwName(SoftName) 00074 { 00075 // 00076 // 00077 // Purpose: Standard constructor 00078 // 00079 // Arguments: 00080 // SoftwName in Name of the software system to be configured 00081 // ConfigName in Name of the configuration set. 00082 // Default: "default" 00083 // vc in Context. 00084 // Default: Dbi::fgDefaultContext. 00085 // task in The task of the configuration. 00086 // Default: 0 00087 // tableName in Name of configuration data table. 00088 // Default: "SOFTWARE_CONFIGURATION" 00089 // 00090 // Return: n/a 00091 // 00092 // Contact: N. West 00093 // 00094 // Specification:- 00095 // ============= 00096 // 00097 // o Create ConfigStream from specified table. 00098 00099 00100 // Program Notes:- 00101 // ============= 00102 00103 // None. 00104 00105 LEA_CTOR //Leak Checker 00106 00107 MSG("Dbi", Msg::kDebug) << "Creating DbiConfigStream" << endl; 00108 00109 // Search for row matching software and configuration names. 00110 int rowNum = fCFSetTable.GetNumRows()-1; 00111 while ( rowNum >= 0 ) { 00112 fCFSet = fCFSetTable.GetRow(rowNum); 00113 if ( fCFSet->GetParamValue(0) == fSoftwName 00114 && fCFSet->GetParamValue(1) == fConfigName ) { 00115 fVRec = *fCFSetTable.GetValidityRec(fCFSet); 00116 MSG("Dbi", Msg::kSynopsis) << "DbiConfigStream for " << fSoftwName 00117 << "," << fConfigName 00118 << " has validity rec: " << fVRec 00119 << " and aggregate no.: " << fCFSet->GetAggregateNo() 00120 << endl; 00121 return; 00122 } 00123 --rowNum; 00124 } 00125 00126 // Cannot find matching row, leave configuration data as null 00127 // and set up a validity rec that can be used if creating a 00128 // new row. 00129 00130 fCFSet = 0; 00131 00132 fVRec.SetDbNo(0); 00133 fVRec.SetTableProxy(&DbiResultPtr<DbiConfigSet>::GetTableProxy(tableName)); 00134 VldTimeStamp start(1970,1,1,0,0,0); 00135 VldTimeStamp end(2038,1,1,0,0,0); 00136 VldRange vr(127,127,start,end,"DbiConfigStream"); 00137 fVRec.SetVldRange(vr); 00138 MSG("Dbi", Msg::kSynopsis) << "DbiConfigStream for " << fSoftwName 00139 << "," << fConfigName 00140 << " has no existing entry; creating validity rec: " << fVRec << endl; 00141 00142 }
|
|
|
Definition at line 146 of file DbiConfigStream.cxx. 00146 {
00147 //
00148 //
00149 // Purpose: Destructor
00150 //
00151 // Arguments:
00152 // None.
00153 //
00154 // Return: n/a
00155 //
00156 // Contact: N. West
00157 //
00158 // Specification:-
00159 // =============
00160 //
00161 // o Destroy ConfigStream.
00162
00163
00164 // Program Notes:-
00165 // =============
00166
00167 // None.
00168
00169 LEA_DTOR //Leak Checker
00170
00171 MSG("Dbi", Msg::kDebug) << "Destroying DbiConfigStream" << endl;
00172
00173 }
|
|
|
|
|
|
Definition at line 57 of file DbiConfigStream.h. Referenced by AlgFactory::GetAlgHandle(), and operator<<(). 00057 { return fCFSet; }
|
|
|
Definition at line 63 of file DbiConfigStream.h. 00063 { return fVRec; }
|
|
|
Definition at line 62 of file DbiConfigStream.h. 00062 { return fCFSet == 0; }
|
|
|
Definition at line 268 of file DbiConfigStream.cxx. References DbiConfigSet::Clear(), fCFSet, fCFSetModified, fConfigName, fSoftwName, fVRec, DbiValidityRec::GetAggregateNo(), MAXMSG, Registry::PrintStream(), DbiConfigSet::PushBack(), reg, and DbiConfigSet::SetAggregateNo(). 00268 {
00269 //
00270 //
00271 // Purpose: Stream configuration data from Registry object.
00272 //
00273 // Arguments:
00274 //
00275 // Contact: N. West
00276 //
00277 // Specification:-
00278 // =============
00279 //
00280 // o Refill internal fCFSetModified from reg..
00281
00282 // Program Notes:-
00283 // =============
00284
00285 // This does NOT write to the database. To do that first use this
00286 // method to refill the configuration and then call the Write method.
00287
00288 if ( fSoftwName == "" ) {
00289 MAXMSG("Dbi",Msg::kError,20) << "Cannot fill (<<): No software name defined." << endl;
00290 return *this;
00291 }
00292
00293 DbiFieldType stringType(Dbi::kString);
00294
00295 ostringstream os;
00296 reg->PrintStream(os);
00297 fCFSetModified.Clear();
00298 fCFSetModified.PushBack("SOFTW_NAME", fSoftwName, stringType);
00299 fCFSetModified.PushBack("CONFIG_NAME",fConfigName, stringType);
00300 fCFSetModified.PushBack("CONFIG_DATA",os.str(), stringType);
00301 if ( fVRec.GetAggregateNo() > 0 ) fCFSetModified.SetAggregateNo( fVRec.GetAggregateNo());
00302 fCFSet = &fCFSetModified;
00303 return *this;
00304
00305 }
|
|
|
Definition at line 211 of file DbiConfigStream.cxx. References Registry::Clear(), fCFSet, DbiConfigSet::GetNumParams(), DbiConfigSet::GetParamName(), DbiConfigSet::GetParamValue(), Registry::KeysLocked(), Registry::LockKeys(), Registry::LockValues(), MAXMSG, Registry::ReadStream(), reg, Registry::UnLockKeys(), Registry::UnLockValues(), and Registry::ValuesLocked(). 00211 {
00212 //
00213 //
00214 // Purpose: Stream configuration data into Registry object.
00215 //
00216 // Arguments:
00217 // reg in Empty Registry object (contents ignored)
00218 // out Filled Registry object.
00219 //
00220 // Return: Original DbiConfigStream object.
00221 //
00222 // Contact: N. West
00223 //
00224 // Specification:-
00225 // =============
00226 //
00227 // o Erase the contents of reg and refill from the DbiConfigSet
00228 // owned by this DbiConfigStream.
00229
00230 // Program Notes:-
00231 // =============
00232
00233 // None.
00234
00235 if ( ! reg ) return *this;
00236
00237 // Record the current state of reg and then clear it.
00238
00239 Bool_t keysLocked = reg->KeysLocked();
00240 Bool_t valuesLocked = reg->ValuesLocked();
00241 reg->UnLockKeys();
00242 reg->UnLockValues();
00243 reg->Clear();
00244
00245 // Use the owned DbiConfigSet to fill reg.
00246
00247 if ( fCFSet ) {
00248 UInt_t numParams = fCFSet->GetNumParams();
00249
00250 // Handle configuration tables.
00251
00252 if ( numParams == 3 && fCFSet->GetParamName(2) == "CONFIG_DATA" ) {
00253 istringstream is(fCFSet->GetParamValue(2));
00254 reg->ReadStream(is);
00255 }
00256 else {
00257 MAXMSG("Dbi",Msg::kError,20) << "Attempting to fill Registry from a table with "
00258 << numParams << " columns (should be 3) using column named "
00259 << fCFSet->GetParamName(2) << " (should be CONFIG_DATA)." << endl;
00260 }
00261 }
00262 if ( keysLocked ) reg->LockKeys();
00263 if ( valuesLocked ) reg->LockValues();
00264 return *this;
00265 }
|
|
||||||||||||||||
|
Definition at line 310 of file DbiConfigStream.cxx. References DbiCascader::AllocateSeqNo(), DbiWriter< T >::Close(), fCFSetModified, fConfigName, fSoftwName, fVRec, DbiValidityRec::GetAggregateNo(), DbiTableProxyRegistry::GetCascader(), DbiTableProxy::GetTableName(), DbiValidityRec::GetTableProxy(), DbiTableProxyRegistry::Instance(), MAXMSG, MSG, DbiConfigSet::SetAggregateNo(), DbiValidityRec::SetAggregateNo(), DbiWriter< T >::SetOverlayCreationDate(), and DbiWriter< T >::SetRequireGlobalSeqno(). 00312 {
00313 //
00314 //
00315 // Purpose: Write configuration data to the database.
00316 //
00317 // Arguments:
00318 // dbNo in Database number in cascade (starting at 0).
00319 // Default: 0.
00320 // logComment in Reason for update.
00321 // Default: "".
00322 // localTest in Set true to use local SEQNOs (doesn't require authorising DB).
00323 // Default: false.
00324 //
00325 // Return: True if I/O successful.
00326
00327 if ( ! fCFSet ) {
00328 MAXMSG("Dbi",Msg::kError,20) << "No configuration data to write out." << endl;
00329 return false;
00330 }
00331
00332 // If no aggregate number has been asigned so far, but fCFSet non-zero, then must
00333 // be creating a new software/config combination with the data in fCFSetModified.
00334 // Use a global seqno number (or local if localTest) to define a unique aggregate number.
00335 int requireGlobal = localTest ? -1 : 1;
00336 if ( fVRec.GetAggregateNo() < 0 ) {
00337 DbiCascader& cas = DbiTableProxyRegistry::Instance().GetCascader();
00338 Int_t aggNo = cas.AllocateSeqNo(fVRec.GetTableProxy()->GetTableName(),requireGlobal,dbNo);
00339 if ( aggNo <= Dbi::kMAXLOCALSEQNO && ! localTest ) {
00340 MAXMSG("Dbi",Msg::kError,20) << "Cannot write out configuration data: no authorising entry in cascade." << endl;
00341 return false;
00342 }
00343 fVRec.SetAggregateNo(aggNo);
00344 fCFSetModified.SetAggregateNo(aggNo);
00345 MSG("Dbi",Msg::kDebug) << "Aggregate number: " << aggNo
00346 << " allocated to entry " << fSoftwName
00347 << "," << fConfigName
00348 << " in table " << fVRec.GetTableProxy()->GetTableName() << endl;
00349 }
00350 DbiWriter<DbiConfigSet> writer(fVRec,dbNo,logComment);
00351 writer.SetRequireGlobalSeqno(requireGlobal);
00352 writer.SetOverlayCreationDate();
00353 writer << *fCFSet;
00354 return writer.Close();
00355
00356 }
|
|
|
Pointer to the associated configuration set. May point either to a row of fCFSetTable (or 0) or, after operator <<, to fCFSetModified Definition at line 77 of file DbiConfigStream.h. Referenced by DbiConfigStream(), operator<<(), and operator>>(). |
|
|
Local DbiConfigSet (empty until/unless filled using operator <<).
Definition at line 84 of file DbiConfigStream.h. Referenced by operator<<(), and Write(). |
|
|
Pointer to ConfigSet table.
Definition at line 81 of file DbiConfigStream.h. Referenced by DbiConfigStream(). |
|
|
Name of the configuration set.
Definition at line 90 of file DbiConfigStream.h. Referenced by DbiConfigStream(), operator<<(), and Write(). |
|
|
|
|
|
Name of the software system to be configured.
Definition at line 93 of file DbiConfigStream.h. Referenced by DbiConfigStream(), operator<<(), and Write(). |
|
|
Associated validity rec (used when writing back to the database).
Definition at line 87 of file DbiConfigStream.h. Referenced by DbiConfigStream(), operator<<(), and Write(). |
1.3.9.1