#include <ODTTCFCycle.h>
Public Member Functions | |
int | getId () const |
std::string | getTable () |
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 () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODTTCFCycle *result) throw (std::runtime_error) |
int | fetchID () throw (std::runtime_error) |
void | insertConfig () throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | setByID (int id) throw (std::runtime_error) |
void | writeDB () throw (std::runtime_error) |
Private Attributes | |
int | m_ID |
int | m_ttcf_config_id |
Friends | |
class | EcalCondDBInterface |
class | ODEcalCycle |
Definition at line 11 of file ODTTCFCycle.h.
ODTTCFCycle::ODTTCFCycle | ( | ) |
Definition at line 9 of file ODTTCFCycle.cc.
References NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; // m_ID = 0; m_ttcf_config_id = 0; }
ODTTCFCycle::~ODTTCFCycle | ( | ) |
Definition at line 21 of file ODTTCFCycle.cc.
{ }
void ODTTCFCycle::clear | ( | void | ) | [private] |
Definition at line 66 of file ODTTCFCycle.cc.
{ m_ttcf_config_id=0; }
void ODTTCFCycle::fetchData | ( | ODTTCFCycle * | result | ) | throw (std::runtime_error) [private] |
Definition at line 131 of file ODTTCFCycle.cc.
References ExpressReco_HICollisions_FallBack::e, and query::result.
{ this->checkConnection(); result->clear(); if(result->getId()==0){ throw(std::runtime_error("ODTTCFConfig::fetchData(): no Id defined for this ODTTCFConfig ")); } try { m_readStmt->setSQL("SELECT ttcf_configuration_id FROM ecal_ttcf_cycle " "WHERE cycle_id = :1 "); m_readStmt->setInt(1, result->getId()); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); result->setTTCFConfigurationID( rset->getInt(1) ); } catch (SQLException &e) { throw(std::runtime_error("ODTTCFCycle::fetchData(): "+e.getMessage())); } }
int ODTTCFCycle::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 71 of file ODTTCFCycle.cc.
References ExpressReco_HICollisions_FallBack::e.
{ // Return from memory if available if (m_ID) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT cycle_id, ttcf_configuration_id FROM ecal_ttcf_cycle " "WHERE cycle_id = :1 "); stmt->setInt(1, m_ID); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); m_ttcf_config_id = rset->getInt(2); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("ODTTCFCycle::fetchID: "+e.getMessage())); } return m_ID; }
int ODTTCFCycle::getId | ( | ) | const [inline] |
std::string ODTTCFCycle::getTable | ( | ) | [inline, virtual] |
int ODTTCFCycle::getTTCFConfigurationID | ( | ) | const [inline] |
Definition at line 26 of file ODTTCFCycle.h.
References m_ttcf_config_id.
{return m_ttcf_config_id;}
void ODTTCFCycle::insertConfig | ( | ) | throw (std::runtime_error) [private] |
Definition at line 158 of file ODTTCFCycle.cc.
References ExpressReco_HICollisions_FallBack::e.
Referenced by ODEcalCycle::writeDB().
{ try { prepareWrite(); writeDB(); m_conn->commit(); terminateWriteStatement(); } catch (std::runtime_error &e) { m_conn->rollback(); throw(e); } catch (...) { m_conn->rollback(); throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught")); } }
bool ODTTCFCycle::operator!= | ( | const ODTTCFCycle & | m | ) | const [inline] |
bool ODTTCFCycle::operator== | ( | const ODTTCFCycle & | m | ) | const [inline] |
void ODTTCFCycle::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 26 of file ODTTCFCycle.cc.
References ExpressReco_HICollisions_FallBack::e.
{ this->checkConnection(); try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO ECAL_TTCF_Cycle (cycle_id, ttcf_configuration_id ) " "VALUES (:1, :2 )"); } catch (SQLException &e) { throw(std::runtime_error("ODTTCFCycle::prepareWrite(): "+e.getMessage())); } }
void ODTTCFCycle::setByID | ( | int | id | ) | throw (std::runtime_error) [private] |
Definition at line 104 of file ODTTCFCycle.cc.
References ExpressReco_HICollisions_FallBack::e.
{ this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT cycle_id, ttcf_configuration_id FROM ecal_ttcf_cycle " "WHERE cycle_id = :1 "); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); m_ttcf_config_id = rset->getInt(2); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("ODTTCFCycle::fetchID: "+e.getMessage())); } }
void ODTTCFCycle::setId | ( | int | id | ) | [inline] |
Definition at line 21 of file ODTTCFCycle.h.
References ExpressReco_HICollisions_FallBack::id, and m_ID.
Referenced by ODEcalCycle::writeDB().
void ODTTCFCycle::setTTCFConfigurationID | ( | int | x | ) | [inline] |
Definition at line 25 of file ODTTCFCycle.h.
References m_ttcf_config_id, and ExpressReco_HICollisions_FallBack::x.
Referenced by ODEcalCycle::writeDB().
void ODTTCFCycle::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 41 of file ODTTCFCycle.cc.
References ExpressReco_HICollisions_FallBack::e, and CastorDbASCIIIO::getId().
{ this->checkConnection(); this->checkPrepare(); try { m_writeStmt->setInt(1, this->getId()); m_writeStmt->setInt(2, this->getTTCFConfigurationID()); m_writeStmt->executeUpdate(); } catch (SQLException &e) { throw(std::runtime_error("ODTTCFCycle::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("ODTTCFCycle::writeDB: Failed to write")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 13 of file ODTTCFCycle.h.
friend class ODEcalCycle [friend] |
Definition at line 14 of file ODTTCFCycle.h.
int ODTTCFCycle::m_ID [private] |
Definition at line 34 of file ODTTCFCycle.h.
Referenced by getId(), operator==(), and setId().
int ODTTCFCycle::m_ttcf_config_id [private] |
Definition at line 35 of file ODTTCFCycle.h.
Referenced by getTTCFConfigurationID(), and setTTCFConfigurationID().