EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairDbCache.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairDbCache.h
1 #ifndef FAIRDBCACHE_H
2 #define FAIRDBCACHE_H
3 
4 #include <list>
5 #include <map>
6 #include <string>
7 using std::string;
8 
9 #include "FairDb.h"
10 
11 class ValContext;
12 class FairDbResult;
14 class FairDbTableProxy;
15 class FairDbValidityRec;
16 //class MsgStream;
17 
19 {
20 
21  public:
22 
23 // Typedefs
24 
25  typedef std::list<FairDbResult*> ResultList_t;
26 
27 // Constructors and destructors.
28 
30  const string& tableName);
31  virtual ~FairDbCache();
32 
33 
34 // State testing member functions
35  UInt_t GetMaxSize() const { return fMaxSize; }
36  UInt_t GetCurSize() const { return fCurSize; }
37  UInt_t GetNumAdopted() const { return fNumAdopted; }
38  UInt_t GetNumReused() const { return fNumReused; }
40  const FairDbResult* Search(const ValContext& vc,
41  const FairDb::Task& task) const;
42  const FairDbResult* Search(const string& sqlQualifiers) const;
43 
45  const FairDbResult* Search(const FairDbValidityRec& vr,
46  const string& sqlQualifiers = "") const;
47 // MsgStream& ShowStatistics(MsgStream& msg) const;
48 
49 // State changing member functions
50  void Adopt(FairDbResult* res,bool registerKey = true);
51  void Purge();
52  void SetStale();
53 
54  protected:
55 
56 
57  private:
58 
59  FairDbCache(const FairDbCache&);
61 
62  const ResultList_t* GetSubCache(Int_t aggNo) const;
63  void Purge(ResultList_t& subCache, const FairDbResult* res=0);
64 
65 
66 
68 
69  const string& fTableName;
70  std::map<Int_t,ResultList_t> fCache;
71  mutable UInt_t fCurSize;
72  mutable UInt_t fMaxSize;
73  mutable UInt_t fNumAdopted;
74  mutable UInt_t fNumReused;
75 
76 
77  ClassDef(FairDbCache,0) //Query result cache for specific database table.
78 
79 };
80 
81 
82 #endif // FAIRDBCACHE_H