CMS 3D CMS Logo

LocationDef Class Reference

Def for Location information. More...

#include <OnlineDB/EcalCondDB/interface/LocationDef.h>

Inheritance diagram for LocationDef:

IDef IUniqueDBObject IDBObject

List of all members.

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


Detailed Description

Def for Location information.

Definition at line 12 of file LocationDef.h.


Constructor & Destructor Documentation

LocationDef::LocationDef (  ) 

Definition at line 10 of file LocationDef.cc.

References IDBObject::m_conn, IDBObject::m_env, IUniqueDBObject::m_ID, m_loc, and NULL.

00011 {
00012   m_env = NULL;
00013   m_conn = NULL;
00014   m_ID = 0;
00015   m_loc = "";
00016 }

LocationDef::~LocationDef (  )  [virtual]

Definition at line 20 of file LocationDef.cc.

00021 {
00022 }


Member Function Documentation

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]

Definition at line 28 of file LocationDef.h.

References m_loc.

00028 { return m_loc != l.m_loc; }

bool LocationDef::operator== ( const LocationDef l  )  const [inline]

Definition at line 27 of file LocationDef.h.

References m_loc.

00027 { return m_loc == l.m_loc; }

void LocationDef::setByID ( int  id  )  throw (std::runtime_error) [virtual]

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().


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file LocationDef.h.


Member Data Documentation

std::string LocationDef::m_loc [protected]

Definition at line 32 of file LocationDef.h.

Referenced by fetchID(), getLocation(), LocationDef(), operator!=(), operator==(), and setByID().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:27:55 2009 for CMSSW by  doxygen 1.5.4