#include <ODLTSConfig.h>
Public Member Functions | |
int | getId () const |
int | getNumberOfEvents () const |
int | getRate () const |
std::string | getTable () |
std::string | getTriggerType () const |
int | getTrigLocL1Delay () const |
ODLTSConfig () | |
void | setId (int id) |
void | setNumberOfEvents (int x) |
void | setParameters (std::map< std::string, std::string > my_keys_map) |
void | setRate (int x) |
void | setTriggerType (std::string x) |
void | setTrigLocL1Delay (int x) |
~ODLTSConfig () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODLTSConfig *result) throw (std::runtime_error) |
int | fetchID () throw (std::runtime_error) |
int | fetchNextId () throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeDB () throw (std::runtime_error) |
Private Attributes | |
int | m_delay |
int | m_ID |
int | m_num |
int | m_rate |
std::string | m_trg_type |
Friends | |
class | EcalCondDBInterface |
Definition at line 9 of file ODLTSConfig.h.
ODLTSConfig::ODLTSConfig | ( | ) |
Definition at line 11 of file ODLTSConfig.cc.
References hitfit::clear(), and NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; m_config_tag=""; m_ID=0; clear(); }
ODLTSConfig::~ODLTSConfig | ( | ) |
Definition at line 32 of file ODLTSConfig.cc.
{ }
void ODLTSConfig::clear | ( | void | ) | [private] |
Definition at line 23 of file ODLTSConfig.cc.
{ m_trg_type=""; m_num=0; m_rate=0; m_delay=0; }
void ODLTSConfig::fetchData | ( | ODLTSConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 127 of file ODLTSConfig.cc.
References alignCSCRings::e, and query::result.
{ this->checkConnection(); result->clear(); if(result->getId()==0 && (result->getConfigTag()=="") ){ throw(std::runtime_error("ODLTSConfig::fetchData(): no Id defined for this ODLTSConfig ")); } try { m_readStmt->setSQL("SELECT * " "FROM ECAL_LTS_CONFIGURATION " " where ( lts_configuration_id = :1 or lts_tag=:2 ) " ); m_readStmt->setInt(1, result->getId()); m_readStmt->setString(2, result->getConfigTag()); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); // 1 is the id and 2 is the config tag result->setId(rset->getInt(1)); result->setConfigTag(rset->getString(2)); result->setTriggerType( rset->getString(3) ); result->setNumberOfEvents( rset->getInt(4) ); result->setRate( rset->getInt(5) ); result->setTrigLocL1Delay( rset->getInt(6) ); } catch (SQLException &e) { throw(std::runtime_error("ODLTSConfig::fetchData(): "+e.getMessage())); } }
int ODLTSConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 161 of file ODLTSConfig.cc.
References alignCSCRings::e.
{ // Return from memory if available if (m_ID!=0) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT lts_configuration_id FROM ecal_lts_configuration " "WHERE lts_tag=:lts_tag " ); stmt->setString(1, getConfigTag()); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("ODLTSConfig::fetchID: "+e.getMessage())); } return m_ID; }
int ODLTSConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 53 of file ODLTSConfig.cc.
References alignCSCRings::e, and query::result.
{ int result=0; try { this->checkConnection(); m_readStmt = m_conn->createStatement(); m_readStmt->setSQL("select ecal_lts_config_sq.NextVal from dual"); ResultSet* rset = m_readStmt->executeQuery(); while (rset->next ()){ result= rset->getInt(1); } m_conn->terminateStatement(m_readStmt); return result; } catch (SQLException &e) { throw(std::runtime_error("ODLTSConfig::fetchNextId(): "+e.getMessage())); } }
int ODLTSConfig::getId | ( | ) | const [inline] |
int ODLTSConfig::getNumberOfEvents | ( | ) | const [inline] |
int ODLTSConfig::getRate | ( | ) | const [inline] |
std::string ODLTSConfig::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 16 of file ODLTSConfig.h.
{ return "ECAL_LTS_CONFIGURATION"; }
std::string ODLTSConfig::getTriggerType | ( | void | ) | const [inline] |
int ODLTSConfig::getTrigLocL1Delay | ( | ) | const [inline] |
void ODLTSConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 75 of file ODLTSConfig.cc.
References alignCSCRings::e.
{ this->checkConnection(); int next_id=fetchNextId(); try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO ECAL_LTS_CONFIGURATION ( lts_configuration_id, lts_tag, " "trigger_type, num_of_events, rate, trig_loc_l1_delay ) " "VALUES ( " ":1, :2, :3, :4 , :5, :6 )"); m_writeStmt->setInt(1, next_id); m_ID=next_id; } catch (SQLException &e) { throw(std::runtime_error("ODLTSConfig::prepareWrite(): "+e.getMessage())); } }
void ODLTSConfig::setId | ( | int | id | ) | [inline] |
void ODLTSConfig::setNumberOfEvents | ( | int | x | ) | [inline] |
void ODLTSConfig::setParameters | ( | std::map< std::string, std::string > | my_keys_map | ) |
void ODLTSConfig::setRate | ( | int | x | ) | [inline] |
void ODLTSConfig::setTriggerType | ( | std::string | x | ) | [inline] |
void ODLTSConfig::setTrigLocL1Delay | ( | int | x | ) | [inline] |
void ODLTSConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 97 of file ODLTSConfig.cc.
References alignCSCRings::e.
{ this->checkConnection(); this->checkPrepare(); try { m_writeStmt->setString(2, this->getConfigTag()); m_writeStmt->setString(3, this->getTriggerType()); m_writeStmt->setInt(4, this->getNumberOfEvents()); m_writeStmt->setInt(5, this->getRate()); m_writeStmt->setInt(6, this->getTrigLocL1Delay()); m_writeStmt->executeUpdate(); } catch (SQLException &e) { throw(std::runtime_error("ODLTSConfig::writeDB(): "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("ODLTSConfig::writeDB: Failed to write")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 11 of file ODLTSConfig.h.
int ODLTSConfig::m_delay [private] |
Definition at line 47 of file ODLTSConfig.h.
Referenced by getTrigLocL1Delay(), and setTrigLocL1Delay().
int ODLTSConfig::m_ID [private] |
Definition at line 43 of file ODLTSConfig.h.
int ODLTSConfig::m_num [private] |
Definition at line 45 of file ODLTSConfig.h.
Referenced by getNumberOfEvents(), and setNumberOfEvents().
int ODLTSConfig::m_rate [private] |
Definition at line 46 of file ODLTSConfig.h.
std::string ODLTSConfig::m_trg_type [private] |
Definition at line 44 of file ODLTSConfig.h.
Referenced by getTriggerType(), and setTriggerType().