#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 | |
| static 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. | |
Definition at line 38 of file DbiConfigStream.h.
| DbiConfigStream::DbiConfigStream | ( | ) |
Definition at line 34 of file DbiConfigStream.cxx.
References Msg::kDebug, LEA_CTOR, and MSG.
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 }
| 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" | |||
| ) |
| DbiConfigStream::~DbiConfigStream | ( | ) | [virtual] |
Definition at line 146 of file DbiConfigStream.cxx.
References Msg::kDebug, LEA_DTOR, and MSG.
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 }
| DbiConfigStream::DbiConfigStream | ( | const DbiConfigStream & | ) | [private] |
| const DbiConfigSet* DbiConfigStream::GetConfigSet | ( | ) | const [inline] |
Definition at line 57 of file DbiConfigStream.h.
References fCFSet.
Referenced by AlgFactory::GetAlgHandle(), and operator<<().
00057 { return fCFSet; }
| DbiValidityRec& DbiConfigStream::GetValidityRec | ( | ) | [inline] |
| Bool_t DbiConfigStream::IsEmpty | ( | ) | [inline] |
| DbiConfigStream & DbiConfigStream::operator<< | ( | const Registry * | reg | ) |
Definition at line 268 of file DbiConfigStream.cxx.
References DbiConfigSet::Clear(), fCFSet, fCFSetModified, fConfigName, fSoftwName, fVRec, DbiValidityRec::GetAggregateNo(), Msg::kError, Dbi::kString, 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 }
| const DbiConfigStream & DbiConfigStream::operator>> | ( | Registry * | reg | ) |
Definition at line 211 of file DbiConfigStream.cxx.
References Registry::Clear(), fCFSet, DbiConfigSet::GetNumParams(), DbiConfigSet::GetParamName(), DbiConfigSet::GetParamValue(), Msg::kError, 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 }
| Bool_t DbiConfigStream::Write | ( | UInt_t | dbNo = 0, |
|
| const std::string & | logComment = "", |
|||
| Bool_t | localTest = false | |||
| ) |
Definition at line 310 of file DbiConfigStream.cxx.
References DbiCascader::AllocateSeqNo(), DbiWriter< T >::Close(), fCFSet, fCFSetModified, fConfigName, fSoftwName, fVRec, DbiValidityRec::GetAggregateNo(), DbiTableProxyRegistry::GetCascader(), DbiTableProxy::GetTableName(), DbiValidityRec::GetTableProxy(), DbiTableProxyRegistry::Instance(), Msg::kDebug, Msg::kError, Dbi::kMAXLOCALSEQNO, 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 }
const DbiConfigSet* DbiConfigStream::fCFSet [private] |
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 GetConfigSet(), IsEmpty(), operator<<(), operator>>(), and Write().
DbiConfigSet DbiConfigStream::fCFSetModified [private] |
Local DbiConfigSet (empty until/unless filled using operator <<).
Definition at line 84 of file DbiConfigStream.h.
Referenced by operator<<(), and Write().
DbiResultPtr<DbiConfigSet> DbiConfigStream::fCFSetTable [private] |
std::string DbiConfigStream::fConfigName [private] |
Name of the configuration set.
Definition at line 90 of file DbiConfigStream.h.
Referenced by operator<<(), and Write().
Definition at line 44 of file DbiConfigStream.h.
std::string DbiConfigStream::fSoftwName [private] |
Name of the software system to be configured.
Definition at line 93 of file DbiConfigStream.h.
Referenced by operator<<(), and Write().
DbiValidityRec DbiConfigStream::fVRec [private] |
Associated validity rec (used when writing back to the database).
Definition at line 87 of file DbiConfigStream.h.
Referenced by GetValidityRec(), operator<<(), and Write().
1.4.7