CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IDataItem.h
Go to the documentation of this file.
1 #ifndef IDATAITEM_H
2 #define IDATAITEM_H
3 
8 
9 #include <stdexcept>
10 #include <map>
12 
16 class IDataItem : public IDBObject {
17 public:
18  IDataItem() : m_writeStmt(nullptr), m_readStmt(nullptr) {}
19 
20  virtual std::string getTable() = 0;
21 
22 protected:
23  oracle::occi::Statement* m_writeStmt;
24  oracle::occi::Statement* m_readStmt;
25 
26  inline void checkPrepare() noexcept(false) {
27  if (m_writeStmt == nullptr) {
28  throw(std::runtime_error("Write statement not prepared"));
29  }
30  }
31 
32  inline void terminateWriteStatement() noexcept(false) {
33  if (m_writeStmt != nullptr) {
34  m_conn->terminateStatement(m_writeStmt);
35  } else {
36  std::cout << "Warning from IDataItem: statement was aleady closed" << std::endl;
37  }
38  }
39 
40  inline void createReadStatement() noexcept(false) { m_readStmt = m_conn->createStatement(); }
41 
42  inline void setPrefetchRowCount(int ncount) noexcept(false) { m_readStmt->setPrefetchRowCount(ncount); }
43 
44  inline void terminateReadStatement() noexcept(false) {
45  if (m_readStmt != nullptr) {
46  m_conn->terminateStatement(m_readStmt);
47  } else {
48  std::cout << "Warning from IDataItem: statement was aleady closed" << std::endl;
49  }
50  }
51 
52  // Prepare a statement for writing operations
53  virtual void prepareWrite() noexcept(false) = 0;
54 };
55 
56 #endif
void setPrefetchRowCount(int ncount) noexcept(false)
Definition: IDataItem.h:42
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
void createReadStatement() noexcept(false)
Definition: IDataItem.h:40
void terminateWriteStatement() noexcept(false)
Definition: IDataItem.h:32
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:24
void terminateReadStatement() noexcept(false)
Definition: IDataItem.h:44
virtual std::string getTable()=0
IDataItem()
Definition: IDataItem.h:18
tuple cout
Definition: gather_cfg.py:144
virtual void prepareWrite() noexcept(false)=0