#include <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 |
Def for Location information
Definition at line 12 of file LocationDef.h.
LocationDef::LocationDef | ( | ) |
LocationDef::~LocationDef | ( | ) | [virtual] |
Definition at line 20 of file LocationDef.cc.
{ }
void LocationDef::fetchAllDefs | ( | std::vector< LocationDef > * | fillVec | ) | throw (std::runtime_error) [protected] |
Definition at line 103 of file LocationDef.cc.
References setByID(), and IDBObject::setConnection().
{ this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT def_id FROM location_def ORDER BY def_id"); ResultSet* rset = stmt->executeQuery(); LocationDef locationDef; locationDef.setConnection(m_env, m_conn); while(rset->next()) { locationDef.setByID( rset->getInt(1) ); fillVec->push_back( locationDef ); } } catch (SQLException &e) { throw(std::runtime_error("LocationDef::fetchAllDefs: "+e.getMessage())); } }
int LocationDef::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 43 of file LocationDef.cc.
{ // Return def from memory if available if (m_ID) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT def_id FROM location_def WHERE " "location = :location"); stmt->setString(1, m_loc); 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("LocationDef::fetchID: "+e.getMessage())); } return m_ID; }
string LocationDef::getLocation | ( | ) | const |
Definition at line 26 of file LocationDef.cc.
Referenced by EcalTPGDBApp::printTag(), and EcalErrorMask::readDB().
{ return m_loc; }
bool LocationDef::operator!= | ( | const LocationDef & | l | ) | const [inline] |
bool LocationDef::operator== | ( | const LocationDef & | l | ) | const [inline] |
void LocationDef::setByID | ( | int | id | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 76 of file LocationDef.cc.
Referenced by fetchAllDefs().
{ this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT location FROM location_def WHERE def_id = :1"); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_loc = rset->getString(1); m_ID = id; } else { throw(std::runtime_error("LocationDef::setByID: Given def_id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("LocationDef::setByID: "+e.getMessage())); } }
void LocationDef::setLocation | ( | std::string | loc | ) |
Referenced by EcalEndcapMonitorClient::beginRunDb(), EcalBarrelMonitorClient::beginRunDb(), popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects(), popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects(), popcon::EcalTPGWeightGroupHandler::getNewObjects(), popcon::EcalTPGBadXTHandler::getNewObjects(), popcon::EcalTPGWeightIdMapHandler::getNewObjects(), popcon::EcalDAQHandler::getNewObjects(), popcon::EcalTPGBadTTHandler::getNewObjects(), popcon::EcalTPGSlidingWindowHandler::getNewObjects(), popcon::EcalTPGPedestalsHandler::getNewObjects(), popcon::EcalTPGPhysicsConstHandler::getNewObjects(), popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects(), popcon::EcalTPGLutIdMapHandler::getNewObjects(), popcon::EcalTPGLinConstHandler::getNewObjects(), popcon::EcalTPGLutGroupHandler::getNewObjects(), popcon::EcalTPGFineGrainStripEEHandler::getNewObjects(), popcon::EcalChannelStatusHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), and EcalPedOffset::writeDb().
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 14 of file LocationDef.h.
std::string LocationDef::m_loc [protected] |
Definition at line 32 of file LocationDef.h.
Referenced by operator!=(), and operator==().