![]() |
![]() |
#include <OnlineDB/EcalCondDB/interface/LocationDef.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
std::string | getLocation () const |
LocationDef () | |
bool | operator!= (const LocationDef &l) const |
bool | operator== (const LocationDef &l) const |
void | setByID (int id) throw (std::runtime_error) |
void | setLocation (std::string loc) |
virtual | ~LocationDef () |
Protected Member Functions | |
void | fetchAllDefs (std::vector< LocationDef > *fillVec) throw (std::runtime_error) |
Protected Attributes | |
std::string | m_loc |
Friends | |
class | EcalCondDBInterface |
Definition at line 12 of file LocationDef.h.
LocationDef::LocationDef | ( | ) |
Definition at line 10 of file LocationDef.cc.
References IDBObject::m_conn, IDBObject::m_env, IUniqueDBObject::m_ID, m_loc, and NULL.
LocationDef::~LocationDef | ( | ) | [virtual] |
void LocationDef::fetchAllDefs | ( | std::vector< LocationDef > * | fillVec | ) | throw (std::runtime_error) [protected] |
Definition at line 103 of file LocationDef.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, setByID(), and IDBObject::setConnection().
00105 { 00106 this->checkConnection(); 00107 try { 00108 Statement* stmt = m_conn->createStatement(); 00109 stmt->setSQL("SELECT def_id FROM location_def ORDER BY def_id"); 00110 ResultSet* rset = stmt->executeQuery(); 00111 00112 LocationDef locationDef; 00113 locationDef.setConnection(m_env, m_conn); 00114 00115 while(rset->next()) { 00116 locationDef.setByID( rset->getInt(1) ); 00117 fillVec->push_back( locationDef ); 00118 } 00119 } catch (SQLException &e) { 00120 throw(runtime_error("LocationDef::fetchAllDefs: "+e.getMessage())); 00121 } 00122 }
int LocationDef::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 43 of file LocationDef.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IUniqueDBObject::m_ID, and m_loc.
Referenced by RunTag::fetchParentIDs(), DCUTag::fetchParentIDs(), and CaliTag::fetchParentIDs().
00045 { 00046 // Return def from memory if available 00047 if (m_ID) { 00048 return m_ID; 00049 } 00050 00051 this->checkConnection(); 00052 00053 try { 00054 Statement* stmt = m_conn->createStatement(); 00055 stmt->setSQL("SELECT def_id FROM location_def WHERE " 00056 "location = :location"); 00057 stmt->setString(1, m_loc); 00058 00059 ResultSet* rset = stmt->executeQuery(); 00060 00061 if (rset->next()) { 00062 m_ID = rset->getInt(1); 00063 } else { 00064 m_ID = 0; 00065 } 00066 m_conn->terminateStatement(stmt); 00067 } catch (SQLException &e) { 00068 throw(runtime_error("LocationDef::fetchID: "+e.getMessage())); 00069 } 00070 00071 return m_ID; 00072 }
string LocationDef::getLocation | ( | ) | const |
Definition at line 26 of file LocationDef.cc.
References m_loc.
Referenced by EcalEndcapMonitorClient::beginRunDb(), EcalBarrelMonitorClient::beginRunDb(), EcalEndcapMonitorClient::defaultWebPage(), EcalBarrelMonitorClient::defaultWebPage(), EcalTPGDBApp::printTag(), and EcalErrorMask::readDB().
00027 { 00028 return m_loc; 00029 }
bool LocationDef::operator!= | ( | const LocationDef & | l | ) | const [inline] |
bool LocationDef::operator== | ( | const LocationDef & | l | ) | const [inline] |
Implements IUniqueDBObject.
Definition at line 76 of file LocationDef.cc.
References IDBObject::checkConnection(), e, id, IDBObject::m_conn, IUniqueDBObject::m_ID, and m_loc.
Referenced by fetchAllDefs(), DCUTag::setByID(), RunTag::setByID(), and CaliTag::setByID().
00078 { 00079 this->checkConnection(); 00080 00081 try { 00082 Statement* stmt = m_conn->createStatement(); 00083 00084 stmt->setSQL("SELECT location FROM location_def WHERE def_id = :1"); 00085 stmt->setInt(1, id); 00086 00087 ResultSet* rset = stmt->executeQuery(); 00088 if (rset->next()) { 00089 m_loc = rset->getString(1); 00090 m_ID = id; 00091 } else { 00092 throw(runtime_error("LocationDef::setByID: Given def_id is not in the database")); 00093 } 00094 00095 m_conn->terminateStatement(stmt); 00096 } catch (SQLException &e) { 00097 throw(runtime_error("LocationDef::setByID: "+e.getMessage())); 00098 } 00099 }
void LocationDef::setLocation | ( | std::string | loc | ) |
Referenced by EcalEndcapMonitorClient::beginRunDb(), EcalBarrelMonitorClient::beginRunDb(), popcon::EcalLaserHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), and EcalPedOffset::writeDb().
friend class EcalCondDBInterface [friend] |
std::string LocationDef::m_loc [protected] |
Definition at line 32 of file LocationDef.h.
Referenced by fetchID(), getLocation(), LocationDef(), operator!=(), operator==(), and setByID().