![]() |
![]() |
00001 #ifndef INCLUDE_ORA_TRANSACTIONCACHE_H 00002 #define INCLUDE_ORA_TRANSACTIONCACHE_H 00003 00004 #include "CondCore/ORA/interface/Handle.h" 00005 // 00006 #include <string> 00007 #include <map> 00008 #include <boost/shared_ptr.hpp> 00009 #include <boost/weak_ptr.hpp> 00010 00011 namespace ora { 00012 00013 class DatabaseContainer; 00014 class DatabaseUtilitySession; 00015 00016 class TransactionCache { 00017 public: 00018 TransactionCache(); 00019 00020 virtual ~TransactionCache(); 00021 00022 void clear(); 00023 00024 void setDbExists( bool exists ); 00025 00026 bool dbExistsLoaded(); 00027 00028 bool dbExists(); 00029 00030 void addContainer( int id, const std::string& name, Handle<DatabaseContainer>& contPtr ); 00031 00032 void eraseContainer( int id, const std::string& name ); 00033 00034 Handle<DatabaseContainer> getContainer( int id ); 00035 00036 Handle<DatabaseContainer> getContainer( const std::string& name ); 00037 00038 const std::map<int, Handle<DatabaseContainer> >& containers(); 00039 00040 void setUtility( Handle<DatabaseUtilitySession>& utility ); 00041 00042 Handle<DatabaseUtilitySession> utility(); 00043 00044 bool isLoaded(); 00045 00046 void setLoaded(); 00047 00048 void setNamedReference( const std::string& name, boost::shared_ptr<void>& data ); 00049 00050 boost::shared_ptr<void> getNamedReference( const std::string& name ); 00051 00052 00053 private: 00054 void cleanUpNamedRefCache(); 00055 00056 private: 00057 std::pair<bool,bool> m_dbExists; 00058 std::map<std::string, int> m_containersByName; 00059 std::map<int, Handle<DatabaseContainer> > m_containersById; 00060 Handle<DatabaseUtilitySession> m_utility; 00061 bool m_loaded; 00062 std::map<std::string,boost::weak_ptr<void> > m_namedRefCache; 00063 }; 00064 } 00065 00066 #endif