00001 #ifndef DBITABLEPROXYREGISTRY_H 00002 #define DBITABLEPROXYREGISTRY_H 00003 00025 #if !defined(__CINT__) || defined(__MAKECINT__) 00026 #include "Rtypes.h" 00027 #endif 00028 #include <map> 00029 #include <string> 00030 #include "DatabaseInterface/DbiRollbackDates.h" 00031 00032 class DbiCascader; 00033 class DbiTableProxy; 00034 class DbiTableRow; 00035 class DbiValidate; 00036 class DbiSvc; 00037 00038 class DbiTableProxyRegistry 00039 { 00040 00041 friend class DbiSvc; 00042 friend class DbiValidate; //Allow DbiValidate access to dtor and 00043 // fCascader 00044 public: 00045 00046 // State testing member functions 00047 void ShowStatistics() const; 00048 00049 // State changing member functions 00050 static DbiTableProxyRegistry& Instance(); 00051 static Bool_t IsActive() { return fgInstance ? kTRUE: kFALSE; } 00052 00053 00054 // Configuration calls: 00055 void ConfigRollback(const std::vector<std::string>& rollbacks); 00056 void ConfigLevel2Cache(const std::string& cachedir=""); 00057 void ConfigConnectionsPermanent(Bool_t permanent); 00058 void ConfigOrderContextQuery(Bool_t on); 00059 00060 00061 void ClearRollbackDates(); 00062 DbiCascader& GetCascader() { return *fCascader; } 00063 DbiTableProxy& GetTableProxy(const std::string& tableName, 00064 const DbiTableRow* tableRow) ; 00065 Bool_t HasRowCounter(const std::string& tableName); 00066 void PurgeCaches(); 00067 void RefreshMetaData(const std::string& tableName); 00068 void SetSqlCondition(const std::string& sql=""); 00069 00070 protected: 00071 00072 // Constructors (protected because singleton). 00073 DbiTableProxyRegistry(); 00074 virtual ~DbiTableProxyRegistry(); 00075 00076 private: 00077 00078 // State changing member functions 00079 00080 // Disabled (not implemented) copy constructor and asignment. 00081 00082 DbiTableProxyRegistry(const DbiTableProxyRegistry&) {}; 00083 DbiTableProxyRegistry& operator=(const DbiTableProxyRegistry&) { return *this; }; 00084 00085 // State testing member functions 00086 void ApplySqlCondition() const; 00087 void ApplySqlCondition(DbiTableProxy* proxy) const; 00088 00089 // Data members 00090 // Helper class to handle deletion of singleton 00091 public: // work around dicitonary problem see #470 comment 11 00092 struct Cleaner { 00093 static int fgCount; // counts #includes 00094 Cleaner() { this->Increment(); } 00095 ~Cleaner() { 00096 if (--fgCount==0 && DbiTableProxyRegistry::fgInstance!=0) { 00097 delete DbiTableProxyRegistry::fgInstance; 00098 DbiTableProxyRegistry::fgInstance = 0; 00099 } 00100 } 00101 void Increment() { ++fgCount; }; 00102 }; 00103 private: 00104 friend class Cleaner; 00105 00107 DbiCascader* fCascader; 00108 00110 std::string fSqlCondition; 00111 00112 #ifndef __CINT__ // Hide map from CINT; complains: missing Streamer() etc. 00114 std::map<std::string,DbiTableProxy*> fTPmap; 00115 #endif // __CINT__ 00116 00118 DbiRollbackDates fRollbackDates; 00119 00121 static DbiTableProxyRegistry* fgInstance; 00122 00123 00124 // Removed: ClassDef(DbiTableProxyRegistry,0) // Singleton register DbiTableProxys. 00125 00126 }; 00127 00128 00129 #endif // DBITABLEPROXYREGISTRY_H