EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairDbValRecSet.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairDbValRecSet.cxx
1 
2 #include "FairDbProxy.h"
3 #include "FairDbResult.h"
4 #include "FairDbTableProxy.h"
6 #include "FairDbValidityRec.h"
7 #include "FairDbValRecSet.h"
8 
10 
11 
12 
13 FairDbValRecSet::FairDbValRecSet(const string& tableName,UInt_t dbNo,UInt_t seqNo) :
14  fDbNo(dbNo),
15  fResult(NULL),
16  fSeqNoToRec()
17 {
18 // Get Db proxy for the table.
21  .GetTableProxy(tableName,&pet)
22  .GetDBProxy();
23 
24 // Collect up all validity records.
25  FairDbResultSet* rset = proxy.QueryAllValidities(dbNo,seqNo);
26  fResult = new FairDbResultNonAgg(rset,&pet,0,kFALSE);
27  delete rset;
28 
29 
30 }
31 
32 
33 
35 {
36 
37  delete fResult;
38 
39 }
40 
41 
43 {
44 
45  return fResult ? fResult->GetNumRows() : 0;
46 }
47 
48 
49 const string FairDbValRecSet::GetTableName() const
50 {
51 
52  return fResult ? fResult->TableName() : "Unknown";
53 }
54 
55 
57 {
58 
59  return fResult ?
60  dynamic_cast<const FairDbValidityRec*>(fResult->GetTableRow(rowNum))
61  : 0;
62 }
63 
64 
66  ) const
67 {
68 
69  UInt_t numRows = GetNumRows();
70  if ( numRows == 0 ) { return 0; }
71 
72 // Create look-up table if not yet built.
73 
74  if ( fSeqNoToRec.size() == 0 ) {
75  for ( UInt_t irow = 0; irow < numRows; ++irow) {
76  const FairDbValidityRec* vrec = GetTableRow(irow);
77  fSeqNoToRec[vrec->GetSeqNo()] = vrec;
78  }
79  }
80 
81  map<UInt_t,const FairDbValidityRec*>::const_iterator itr = fSeqNoToRec.find(seqNo);
82  return ( itr == fSeqNoToRec.end() ) ? 0 : itr->second;
83 
84 }
85