File indexing completed on 2024-04-06 12:01:24
0001 #ifndef CondCore_CondDB_PayloadReader_h
0002 #define CondCore_CondDB_PayloadReader_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "CondCore/CondDB/interface/ConnectionPool.h"
0016
0017 #include <memory>
0018
0019 namespace cond {
0020
0021 namespace persistency {
0022
0023 class PayloadReader {
0024 public:
0025 static constexpr const char* const PRODUCTION_DB = "oracle://cms_orcon_adg/CMS_CONDITIONS";
0026
0027 public:
0028
0029 PayloadReader();
0030
0031
0032 PayloadReader(const PayloadReader& rhs);
0033
0034
0035 virtual ~PayloadReader();
0036
0037
0038 PayloadReader& operator=(const PayloadReader& rhs);
0039
0040
0041 ConnectionPool& connection();
0042
0043
0044 void open(const std::string& connectionString);
0045
0046
0047 void open();
0048
0049
0050 void close();
0051
0052
0053 template <typename T>
0054 std::shared_ptr<T> fetch(const cond::Hash& payloadHash);
0055
0056 private:
0057 std::shared_ptr<ConnectionPool> m_connection;
0058 Session m_session;
0059 };
0060
0061 template <typename T>
0062 inline std::shared_ptr<T> PayloadReader::fetch(const cond::Hash& payloadHash) {
0063 std::shared_ptr<T> ret;
0064 if (m_session.connectionString().empty())
0065 open(PRODUCTION_DB);
0066 m_session.transaction().start(true);
0067 ret = m_session.fetchPayload<T>(payloadHash);
0068 m_session.transaction().commit();
0069 return ret;
0070 }
0071
0072 }
0073 }
0074 #endif