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