CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
LocationDef Class Reference

#include <LocationDef.h>

Inheritance diagram for LocationDef:
IDef IUniqueDBObject IDBObject

Public Member Functions

int fetchID () noexcept(false)
 
std::string getLocation () const
 
 LocationDef ()
 
bool operator!= (const LocationDef &l) const
 
bool operator== (const LocationDef &l) const
 
void setByID (int id) noexcept(false)
 
void setLocation (std::string loc)
 
virtual ~LocationDef ()
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Protected Member Functions

void fetchAllDefs (std::vector< LocationDef > *fillVec) noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 

Protected Attributes

std::string m_loc
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 

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 NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_ID = 0;
15  m_loc = "";
16 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
std::string m_loc
Definition: LocationDef.h:32
LocationDef::~LocationDef ( )
virtual

Definition at line 20 of file LocationDef.cc.

21 {
22 }

Member Function Documentation

void LocationDef::fetchAllDefs ( std::vector< LocationDef > *  fillVec)
protectednoexcept

Definition at line 103 of file LocationDef.cc.

References MillePedeFileConverter_cfg::e, setByID(), and IDBObject::setConnection().

105 {
106  this->checkConnection();
107  try {
108  Statement* stmt = m_conn->createStatement();
109  stmt->setSQL("SELECT def_id FROM location_def ORDER BY def_id");
110  ResultSet* rset = stmt->executeQuery();
111 
112  LocationDef locationDef;
113  locationDef.setConnection(m_env, m_conn);
114 
115  while(rset->next()) {
116  locationDef.setByID( rset->getInt(1) );
117  fillVec->push_back( locationDef );
118  }
119  } catch (SQLException &e) {
120  throw(std::runtime_error("LocationDef::fetchAllDefs: "+e.getMessage()));
121  }
122 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setByID(int id) noexcept(false)
Definition: LocationDef.cc:76
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int LocationDef::fetchID ( )
virtualnoexcept

Implements IUniqueDBObject.

Definition at line 43 of file LocationDef.cc.

References MillePedeFileConverter_cfg::e.

45 {
46  // Return def from memory if available
47  if (m_ID) {
48  return m_ID;
49  }
50 
51  this->checkConnection();
52 
53  try {
54  Statement* stmt = m_conn->createStatement();
55  stmt->setSQL("SELECT def_id FROM location_def WHERE "
56  "location = :location");
57  stmt->setString(1, m_loc);
58 
59  ResultSet* rset = stmt->executeQuery();
60 
61  if (rset->next()) {
62  m_ID = rset->getInt(1);
63  } else {
64  m_ID = 0;
65  }
66  m_conn->terminateStatement(stmt);
67  } catch (SQLException &e) {
68  throw(std::runtime_error("LocationDef::fetchID: "+e.getMessage()));
69  }
70 
71  return m_ID;
72 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
std::string m_loc
Definition: LocationDef.h:32
string LocationDef::getLocation ( ) const

Definition at line 26 of file LocationDef.cc.

Referenced by EcalTPGDBApp::printTag(), and EcalErrorMask::readDB().

27 {
28  return m_loc;
29 }
std::string m_loc
Definition: LocationDef.h:32
bool LocationDef::operator!= ( const LocationDef l) const
inline

Definition at line 28 of file LocationDef.h.

References m_loc.

28 { return m_loc != l.m_loc; }
std::string m_loc
Definition: LocationDef.h:32
bool LocationDef::operator== ( const LocationDef l) const
inline

Definition at line 27 of file LocationDef.h.

References m_loc.

27 { return m_loc == l.m_loc; }
std::string m_loc
Definition: LocationDef.h:32
void LocationDef::setByID ( int  id)
virtualnoexcept

Implements IUniqueDBObject.

Definition at line 76 of file LocationDef.cc.

References MillePedeFileConverter_cfg::e, and triggerObjects_cff::id.

Referenced by fetchAllDefs().

78 {
79  this->checkConnection();
80 
81  try {
82  Statement* stmt = m_conn->createStatement();
83 
84  stmt->setSQL("SELECT location FROM location_def WHERE def_id = :1");
85  stmt->setInt(1, id);
86 
87  ResultSet* rset = stmt->executeQuery();
88  if (rset->next()) {
89  m_loc = rset->getString(1);
90  m_ID = id;
91  } else {
92  throw(std::runtime_error("LocationDef::setByID: Given def_id is not in the database"));
93  }
94 
95  m_conn->terminateStatement(stmt);
96  } catch (SQLException &e) {
97  throw(std::runtime_error("LocationDef::setByID: "+e.getMessage()));
98  }
99 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
std::string m_loc
Definition: LocationDef.h:32
void LocationDef::setLocation ( std::string  loc)

Definition at line 33 of file LocationDef.cc.

References create_public_lumi_plots::loc.

Referenced by EcalPedestalHistory::beginRun(), EcalCondDBWriter::dqmEndJob(), popcon::EcalSRPHandler::getNewObjects(), popcon::EcalDAQHandler::getNewObjects(), popcon::EcalTPGLinConstHandler::getNewObjects(), popcon::EcalTPGBadStripHandler::getNewObjects(), popcon::EcalTPGLutIdMapHandler::getNewObjects(), popcon::EcalTPGBadTTHandler::getNewObjects(), popcon::EcalTPGPhysicsConstHandler::getNewObjects(), popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects(), popcon::EcalTPGWeightIdMapHandler::getNewObjects(), popcon::EcalTPGBadXTHandler::getNewObjects(), popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects(), popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects(), popcon::EcalTPGWeightGroupHandler::getNewObjects(), popcon::EcalTPGFineGrainStripEEHandler::getNewObjects(), popcon::EcalTPGSlidingWindowHandler::getNewObjects(), popcon::EcalTPGPedestalsHandler::getNewObjects(), popcon::EcalTPGSpikeThresholdHandler::getNewObjects(), popcon::EcalTPGLutGroupHandler::getNewObjects(), popcon::EcalChannelStatusHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), and EcalPedOffset::writeDb().

34 {
35  if (loc != m_loc) {
36  m_ID = 0;
37  m_loc = loc;
38  }
39 }
std::string m_loc
Definition: LocationDef.h:32

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

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 operator!=(), and operator==().