CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODTTCFCycle Class Reference

#include <ODTTCFCycle.h>

Inheritance diagram for ODTTCFCycle:
IODConfig IDBObject

Public Member Functions

int getId () const
 
std::string getTable () override
 
int getTTCFConfigurationID () const
 
 ODTTCFCycle ()
 
bool operator!= (const ODTTCFCycle &m) const
 
bool operator== (const ODTTCFCycle &m) const
 
void setId (int id)
 
void setTTCFConfigurationID (int x)
 
 ~ODTTCFCycle () override
 
- Public Member Functions inherited from IODConfig
std::string getConfigTag ()
 
void setConfigTag (std::string x)
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Private Member Functions

void clear ()
 
void fetchData (ODTTCFCycle *result) noexcept(false)
 
int fetchID () noexcept(false)
 
void insertConfig () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void setByID (int id) noexcept(false)
 
void writeDB () noexcept(false)
 

Private Attributes

int m_ID
 
int m_ttcf_config_id
 

Friends

class EcalCondDBInterface
 
class ODEcalCycle
 

Additional Inherited Members

- Public Types inherited from IODConfig
typedef oracle::occi::Clob Clob
 
typedef oracle::occi::SQLException SQLException
 
typedef oracle::occi::Statement Statement
 
typedef oracle::occi::Stream Stream
 
- Public Attributes inherited from IODConfig
std::string m_config_tag
 
- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IODConfig
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
unsigned char * readClob (Clob &clob, int size) noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IODConfig
Statementm_readStmt
 
Statementm_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 9 of file ODTTCFCycle.h.

Constructor & Destructor Documentation

ODTTCFCycle::ODTTCFCycle ( )

Definition at line 9 of file ODTTCFCycle.cc.

9  {
10  m_env = nullptr;
11  m_conn = nullptr;
12  m_writeStmt = nullptr;
13  m_readStmt = nullptr;
14  //
15  m_ID = 0;
16  m_ttcf_config_id = 0;
17 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
Statement * m_readStmt
Definition: IODConfig.h:34
int m_ttcf_config_id
Definition: ODTTCFCycle.h:33
ODTTCFCycle::~ODTTCFCycle ( )
override

Definition at line 19 of file ODTTCFCycle.cc.

19 {}

Member Function Documentation

void ODTTCFCycle::clear ( void  )
private

Definition at line 54 of file ODTTCFCycle.cc.

54 { m_ttcf_config_id = 0; }
int m_ttcf_config_id
Definition: ODTTCFCycle.h:33
void ODTTCFCycle::fetchData ( ODTTCFCycle result)
privatenoexcept

Definition at line 109 of file ODTTCFCycle.cc.

References alignCSCRings::e, and mps_fire::result.

109  {
110  this->checkConnection();
111  result->clear();
112 
113  if (result->getId() == 0) {
114  throw(std::runtime_error("ODTTCFConfig::fetchData(): no Id defined for this ODTTCFConfig "));
115  }
116 
117  try {
118  m_readStmt->setSQL(
119  "SELECT ttcf_configuration_id FROM ecal_ttcf_cycle "
120  "WHERE cycle_id = :1 ");
121 
122  m_readStmt->setInt(1, result->getId());
123  ResultSet *rset = m_readStmt->executeQuery();
124 
125  rset->next();
126 
127  result->setTTCFConfigurationID(rset->getInt(1));
128 
129  } catch (SQLException &e) {
130  throw(std::runtime_error("ODTTCFCycle::fetchData(): " + e.getMessage()));
131  }
132 }
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void clear()
Definition: ODTTCFCycle.cc:54
void setTTCFConfigurationID(int x)
Definition: ODTTCFCycle.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
int getId() const
Definition: ODTTCFCycle.h:20
int ODTTCFCycle::fetchID ( )
privatenoexcept

Definition at line 56 of file ODTTCFCycle.cc.

References alignCSCRings::e.

56  {
57  // Return from memory if available
58  if (m_ID) {
59  return m_ID;
60  }
61 
62  this->checkConnection();
63 
64  try {
65  Statement *stmt = m_conn->createStatement();
66  stmt->setSQL(
67  "SELECT cycle_id, ttcf_configuration_id FROM ecal_ttcf_cycle "
68  "WHERE cycle_id = :1 ");
69  stmt->setInt(1, m_ID);
70  ResultSet *rset = stmt->executeQuery();
71 
72  if (rset->next()) {
73  m_ID = rset->getInt(1);
74  m_ttcf_config_id = rset->getInt(2);
75  } else {
76  m_ID = 0;
77  }
78  m_conn->terminateStatement(stmt);
79  } catch (SQLException &e) {
80  throw(std::runtime_error("ODTTCFCycle::fetchID: " + e.getMessage()));
81  }
82 
83  return m_ID;
84 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
int m_ttcf_config_id
Definition: ODTTCFCycle.h:33
int ODTTCFCycle::getId ( void  ) const
inline

Definition at line 20 of file ODTTCFCycle.h.

References m_ID.

20 { return m_ID; };
std::string ODTTCFCycle::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 17 of file ODTTCFCycle.h.

17 { return "ECAL_TTCF_CYCLE"; }
int ODTTCFCycle::getTTCFConfigurationID ( ) const
inline

Definition at line 24 of file ODTTCFCycle.h.

References m_ttcf_config_id.

24 { return m_ttcf_config_id; }
int m_ttcf_config_id
Definition: ODTTCFCycle.h:33
void ODTTCFCycle::insertConfig ( )
privatenoexcept

Definition at line 134 of file ODTTCFCycle.cc.

References alignCSCRings::e.

Referenced by ODEcalCycle::writeDB().

134  {
135  try {
136  prepareWrite();
137  writeDB();
138  m_conn->commit();
140  } catch (std::runtime_error &e) {
141  m_conn->rollback();
142  throw(e);
143  } catch (...) {
144  m_conn->rollback();
145  throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught"));
146  }
147 }
void prepareWrite() noexcept(false) override
Definition: ODTTCFCycle.cc:21
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void writeDB() noexcept(false)
Definition: ODTTCFCycle.cc:34
void terminateWriteStatement() noexcept(false)
Definition: IODConfig.h:42
bool ODTTCFCycle::operator!= ( const ODTTCFCycle m) const
inline

Definition at line 28 of file ODTTCFCycle.h.

References visualization-live-secondInstance_cfg::m.

bool ODTTCFCycle::operator== ( const ODTTCFCycle m) const
inline

Definition at line 27 of file ODTTCFCycle.h.

References m_ID.

27 { return (m_ID == m.m_ID); }
void ODTTCFCycle::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 21 of file ODTTCFCycle.cc.

References alignCSCRings::e.

21  {
22  this->checkConnection();
23 
24  try {
25  m_writeStmt = m_conn->createStatement();
26  m_writeStmt->setSQL(
27  "INSERT INTO ECAL_TTCF_Cycle (cycle_id, ttcf_configuration_id ) "
28  "VALUES (:1, :2 )");
29  } catch (SQLException &e) {
30  throw(std::runtime_error("ODTTCFCycle::prepareWrite(): " + e.getMessage()));
31  }
32 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
void ODTTCFCycle::setByID ( int  id)
privatenoexcept

Definition at line 86 of file ODTTCFCycle.cc.

References alignCSCRings::e.

86  {
87  this->checkConnection();
88 
89  try {
90  Statement *stmt = m_conn->createStatement();
91  stmt->setSQL(
92  "SELECT cycle_id, ttcf_configuration_id FROM ecal_ttcf_cycle "
93  "WHERE cycle_id = :1 ");
94  stmt->setInt(1, id);
95  ResultSet *rset = stmt->executeQuery();
96 
97  if (rset->next()) {
98  m_ID = rset->getInt(1);
99  m_ttcf_config_id = rset->getInt(2);
100  } else {
101  m_ID = 0;
102  }
103  m_conn->terminateStatement(stmt);
104  } catch (SQLException &e) {
105  throw(std::runtime_error("ODTTCFCycle::fetchID: " + e.getMessage()));
106  }
107 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
int m_ttcf_config_id
Definition: ODTTCFCycle.h:33
void ODTTCFCycle::setId ( int  id)
inline

Definition at line 19 of file ODTTCFCycle.h.

References gpuClustering::id, and m_ID.

Referenced by ODEcalCycle::writeDB().

19 { m_ID = id; }
uint16_t *__restrict__ id
void ODTTCFCycle::setTTCFConfigurationID ( int  x)
inline

Definition at line 23 of file ODTTCFCycle.h.

References m_ttcf_config_id, and x.

Referenced by ODEcalCycle::writeDB().

23 { m_ttcf_config_id = x; }
int m_ttcf_config_id
Definition: ODTTCFCycle.h:33
void ODTTCFCycle::writeDB ( )
privatenoexcept

Definition at line 34 of file ODTTCFCycle.cc.

References alignCSCRings::e, and getId().

34  {
35  this->checkConnection();
36  this->checkPrepare();
37 
38  try {
39  m_writeStmt->setInt(1, this->getId());
40  m_writeStmt->setInt(2, this->getTTCFConfigurationID());
41 
42  m_writeStmt->executeUpdate();
43 
44  } catch (SQLException &e) {
45  throw(std::runtime_error("ODTTCFCycle::writeDB: " + e.getMessage()));
46  }
47 
48  // Now get the ID
49  if (!this->fetchID()) {
50  throw(std::runtime_error("ODTTCFCycle::writeDB: Failed to write"));
51  }
52 }
int getTTCFConfigurationID() const
Definition: ODTTCFCycle.h:24
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchID() noexcept(false)
Definition: ODTTCFCycle.cc:56
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
int getId() const
Definition: ODTTCFCycle.h:20
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODTTCFCycle.h.

friend class ODEcalCycle
friend

Definition at line 12 of file ODTTCFCycle.h.

Member Data Documentation

int ODTTCFCycle::m_ID
private

Definition at line 32 of file ODTTCFCycle.h.

Referenced by getId(), operator==(), and setId().

int ODTTCFCycle::m_ttcf_config_id
private

Definition at line 33 of file ODTTCFCycle.h.

Referenced by getTTCFConfigurationID(), and setTTCFConfigurationID().