Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:49

0001 #ifndef IDATAITEM_H
0002 #define IDATAITEM_H
0003 
0004 #include "OnlineDB/EcalCondDB/interface/IDBObject.h"
0005 #include "OnlineDB/EcalCondDB/interface/ITag.h"
0006 #include "OnlineDB/EcalCondDB/interface/IIOV.h"
0007 #include "OnlineDB/EcalCondDB/interface/EcalLogicID.h"
0008 
0009 #include <stdexcept>
0010 #include <map>
0011 #include "OnlineDB/Oracle/interface/Oracle.h"
0012 
0013 /**
0014  *   Abstract interface for data in the conditions DB
0015  */
0016 class IDataItem : public IDBObject {
0017 public:
0018   IDataItem() : m_writeStmt(nullptr), m_readStmt(nullptr) {}
0019 
0020   virtual std::string getTable() = 0;
0021 
0022 protected:
0023   oracle::occi::Statement* m_writeStmt;
0024   oracle::occi::Statement* m_readStmt;
0025 
0026   inline void checkPrepare() noexcept(false) {
0027     if (m_writeStmt == nullptr) {
0028       throw(std::runtime_error("Write statement not prepared"));
0029     }
0030   }
0031 
0032   inline void terminateWriteStatement() noexcept(false) {
0033     if (m_writeStmt != nullptr) {
0034       m_conn->terminateStatement(m_writeStmt);
0035     } else {
0036       std::cout << "Warning from IDataItem: statement was aleady closed" << std::endl;
0037     }
0038   }
0039 
0040   inline void createReadStatement() noexcept(false) { m_readStmt = m_conn->createStatement(); }
0041 
0042   inline void setPrefetchRowCount(int ncount) noexcept(false) { m_readStmt->setPrefetchRowCount(ncount); }
0043 
0044   inline void terminateReadStatement() noexcept(false) {
0045     if (m_readStmt != nullptr) {
0046       m_conn->terminateStatement(m_readStmt);
0047     } else {
0048       std::cout << "Warning from IDataItem: statement was aleady closed" << std::endl;
0049     }
0050   }
0051 
0052   // Prepare a statement for writing operations
0053   virtual void prepareWrite() noexcept(false) = 0;
0054 };
0055 
0056 #endif