CMS 3D CMS Logo

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 
18  public:
22  {}
23 
24  virtual std::string getTable() =0;
25 
26 
27  protected:
28  oracle::occi::Statement* m_writeStmt;
29  oracle::occi::Statement* m_readStmt;
30 
31  inline void checkPrepare() noexcept(false)
32  {
33  if (m_writeStmt == nullptr) {
34  throw(std::runtime_error("Write statement not prepared"));
35  }
36  }
37 
39  {
40  if (m_writeStmt != nullptr) {
41  m_conn->terminateStatement(m_writeStmt);
42  } else {
43  std::cout << "Warning from IDataItem: statement was aleady closed"<< std::endl;
44  }
45  }
46 
47 
49  {
50  m_readStmt=m_conn->createStatement();
51  }
52 
53  inline void setPrefetchRowCount(int ncount) noexcept(false)
54  {
55  m_readStmt->setPrefetchRowCount(ncount);
56  }
57 
59  {
60  if (m_readStmt != nullptr) {
61  m_conn->terminateStatement(m_readStmt);
62  } else {
63  std::cout << "Warning from IDataItem: statement was aleady closed"<< std::endl;
64  }
65  }
66 
67 
68 
69  // Prepare a statement for writing operations
70  virtual void prepareWrite() noexcept(false) = 0;
71 
72 
73 };
74 
75 #endif
void setPrefetchRowCount(int ncount) noexcept(false)
Definition: IDataItem.h:53
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define noexcept
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
#define nullptr
void createReadStatement() noexcept(false)
Definition: IDataItem.h:48
void terminateWriteStatement() noexcept(false)
Definition: IDataItem.h:38
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void terminateReadStatement() noexcept(false)
Definition: IDataItem.h:58
virtual std::string getTable()=0
IDataItem()
Definition: IDataItem.h:19
virtual void prepareWrite() noexcept(false)=0