Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:45

0001 #ifndef RecoLuminosity_LumiProducer_DBService_h
0002 #define RecoLuminosity_LumiProducer_DBService_h
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 
0005 #include "RelationalAccess/ISessionProxy.h"
0006 #include "RelationalAccess/ConnectionService.h"
0007 
0008 #include <string>
0009 #include <mutex>
0010 #include <memory>
0011 
0012 namespace lumi {
0013   class DBConfig;
0014   namespace service {
0015 
0016     class ISessionProxyPtr {
0017     public:
0018       ISessionProxyPtr(std::unique_ptr<coral::ISessionProxy> iProxy, std::unique_lock<std::mutex> iLock)
0019           : m_lock(std::move(iLock)), m_proxy(std::move(iProxy)) {}
0020 
0021       coral::ISessionProxy* operator->() { return m_proxy.get(); }
0022 
0023     private:
0024       std::unique_lock<std::mutex> m_lock;
0025       std::unique_ptr<coral::ISessionProxy> m_proxy;
0026     };
0027 
0028     class DBService {
0029     public:
0030       DBService(const edm::ParameterSet& iConfig);
0031       ~DBService();
0032 
0033       ISessionProxyPtr connectReadOnly(const std::string& connectstring);
0034 
0035     private:
0036       std::unique_ptr<coral::ConnectionService> m_svc;
0037       std::unique_ptr<lumi::DBConfig> m_dbconfig;
0038       std::mutex m_mutex;
0039     };  //cl DBService
0040   }  // namespace service
0041 }  // namespace lumi
0042 #endif