#include <OnlineDB/EcalCondDB/interface/RunModeDef.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
std::string | getRunMode () const |
bool | operator!= (const RunModeDef &t) const |
bool | operator== (const RunModeDef &t) const |
RunModeDef () | |
void | setByID (int id) throw (std::runtime_error) |
void | setRunMode (std::string runmode) |
virtual | ~RunModeDef () |
Protected Member Functions | |
void | fetchAllDefs (std::vector< RunModeDef > *fillVec) throw (std::runtime_error) |
Protected Attributes | |
std::string | m_runMode |
Friends | |
class | EcalCondDBInterface |
Definition at line 12 of file RunModeDef.h.
RunModeDef::RunModeDef | ( | ) |
Definition at line 9 of file RunModeDef.cc.
References IDBObject::m_conn, IDBObject::m_env, IUniqueDBObject::m_ID, m_runMode, and NULL.
00010 { 00011 m_env = NULL; 00012 m_conn = NULL; 00013 m_ID = 0; 00014 m_runMode = ""; 00015 00016 }
RunModeDef::~RunModeDef | ( | ) | [virtual] |
void RunModeDef::fetchAllDefs | ( | std::vector< RunModeDef > * | fillVec | ) | throw (std::runtime_error) [protected] |
Definition at line 106 of file RunModeDef.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, setByID(), and IDBObject::setConnection().
00108 { 00109 this->checkConnection(); 00110 try { 00111 Statement* stmt = m_conn->createStatement(); 00112 stmt->setSQL("SELECT def_id FROM ecal_run_mode_def ORDER BY def_id"); 00113 ResultSet* rset = stmt->executeQuery(); 00114 00115 RunModeDef runModeDef; 00116 runModeDef.setConnection(m_env, m_conn); 00117 00118 while(rset->next()) { 00119 runModeDef.setByID( rset->getInt(1) ); 00120 fillVec->push_back( runModeDef ); 00121 } 00122 } catch (SQLException &e) { 00123 throw(runtime_error("RunModeDef::fetchAllDefs: "+e.getMessage())); 00124 } 00125 }
int RunModeDef::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 46 of file RunModeDef.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IUniqueDBObject::m_ID, and m_runMode.
Referenced by ODRunConfigInfo::writeDB().
00048 { 00049 // Return def from memory if available 00050 if (m_ID) { 00051 return m_ID; 00052 } 00053 00054 this->checkConnection(); 00055 00056 try { 00057 Statement* stmt = m_conn->createStatement(); 00058 stmt->setSQL("SELECT def_id FROM ecal_run_mode_def WHERE " 00059 "run_mode_string = :1" 00060 ); 00061 stmt->setString(1, m_runMode); 00062 00063 ResultSet* rset = stmt->executeQuery(); 00064 00065 if (rset->next()) { 00066 m_ID = rset->getInt(1); 00067 } else { 00068 m_ID = 0; 00069 } 00070 m_conn->terminateStatement(stmt); 00071 } catch (SQLException &e) { 00072 throw(runtime_error("RunModeDef::fetchID: "+e.getMessage())); 00073 } 00074 00075 return m_ID; 00076 }
string RunModeDef::getRunMode | ( | ) | const |
Definition at line 26 of file RunModeDef.cc.
References m_runMode.
00027 { 00028 return m_runMode; 00029 }
bool RunModeDef::operator!= | ( | const RunModeDef & | t | ) | const [inline] |
bool RunModeDef::operator== | ( | const RunModeDef & | t | ) | const [inline] |
Implements IUniqueDBObject.
Definition at line 80 of file RunModeDef.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, and m_runMode.
Referenced by fetchAllDefs(), and ODRunConfigInfo::setByID().
00082 { 00083 this->checkConnection(); 00084 00085 try { 00086 Statement* stmt = m_conn->createStatement(); 00087 00088 stmt->setSQL("SELECT run_mode_string FROM ecal_run_mode_def WHERE def_id = :1"); 00089 stmt->setInt(1, id); 00090 00091 ResultSet* rset = stmt->executeQuery(); 00092 if (rset->next()) { 00093 m_runMode = rset->getString(1); 00094 } else { 00095 throw(runtime_error("RunModeDef::setByID: Given def_id is not in the database")); 00096 } 00097 00098 m_conn->terminateStatement(stmt); 00099 } catch (SQLException &e) { 00100 throw(runtime_error("RunModeDef::setByID: "+e.getMessage())); 00101 } 00102 }
void RunModeDef::setRunMode | ( | std::string | runmode | ) |
friend class EcalCondDBInterface [friend] |
std::string RunModeDef::m_runMode [protected] |
Definition at line 35 of file RunModeDef.h.
Referenced by fetchID(), getRunMode(), operator!=(), operator==(), RunModeDef(), and setByID().