Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DbiCache.h

Go to the documentation of this file.
00001 #ifndef DBICACHE_H
00002 #define DBICACHE_H
00003 
00025 #include <list>
00026 #include <map>
00027 #include <string>
00028 using std::string;
00029 
00030 #include "DatabaseInterface/Dbi.h"
00031 
00032 class VldContext;
00033 class DbiResult;
00034 class DbiTableProxyRegistry;
00035 class DbiTableProxy;
00036 class DbiValidityRec;
00037 class MsgStream;
00038 
00039 class DbiCache
00040 {
00041 
00042   friend   class DbiValidate;  // To allow access to purge.
00043 public:
00044 
00045 // Typedefs
00046 
00047 typedef std::list<DbiResult*> ResultList_t;
00048  
00049 // Constructors and destructors.
00050 
00051            DbiCache(DbiTableProxy& qp,
00052                     const string& tableName);
00053   virtual ~DbiCache();
00054 
00055 
00056 // State testing member functions
00057           UInt_t GetMaxSize() const { return fMaxSize; } 
00058           UInt_t GetCurSize() const { return fCurSize; } 
00059           UInt_t GetNumAdopted() const { return fNumAdopted; } 
00060           UInt_t GetNumReused() const { return fNumReused; } 
00062 const DbiResult* Search(const VldContext& vc,
00063                         const Dbi::Task& task) const;
00064 const DbiResult* Search(const string& sqlQualifiers) const;
00065 
00067 const DbiResult* Search(const DbiValidityRec& vr,
00068                         const string& sqlQualifiers = "") const;
00069       MsgStream& ShowStatistics(MsgStream& msg) const;
00070 
00071 // State changing member functions
00072     void Adopt(DbiResult* res,bool registerKey = true);
00073     void Purge();
00074     void SetStale();
00075 
00076 protected:
00077 
00078 // State testing member functions
00079 
00080 // State changing member functions
00081 
00082 private:
00083 
00084 // Disabled (not implemented) copy constructor and asignment.
00085  DbiCache(const DbiCache&);
00086  DbiCache& operator=(const DbiCache&);
00087 
00088   const ResultList_t* GetSubCache(Int_t aggNo) const;  
00089                 void Purge(ResultList_t& subCache, const DbiResult* res=0);
00090 
00091 // Data members
00092  
00093 
00095   DbiTableProxy&  fTableProxy;
00096 
00098   const string& fTableName;
00099 
00103   std::map<Int_t,ResultList_t> fCache;
00104 
00106   mutable UInt_t fCurSize;
00107 
00109   mutable UInt_t fMaxSize;
00110 
00112   mutable UInt_t fNumAdopted;
00113 
00115   mutable UInt_t fNumReused;
00116 
00117 
00118 ClassDef(DbiCache,0)  //Query result cache for specific database table.
00119 
00120 };
00121 
00122 
00123 #endif  // DBICACHE_H

Generated on Mon Feb 15 11:06:34 2010 for loon by  doxygen 1.3.9.1