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) override
 
std::string getLocation () const
 
 LocationDef ()
 
bool operator!= (const LocationDef &l) const
 
bool operator== (const LocationDef &l) const
 
void setByID (int id) noexcept(false) override
 
void setLocation (std::string loc)
 
 ~LocationDef () override
 
- 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 const int ECALDB_NROWS = 1024
 

Detailed Description

Def for Location information

Definition at line 12 of file LocationDef.h.

Constructor & Destructor Documentation

◆ LocationDef()

LocationDef::LocationDef ( )

Definition at line 9 of file LocationDef.cc.

9  {
10  m_env = nullptr;
11  m_conn = nullptr;
12  m_ID = 0;
13  m_loc = "";
14 }

◆ ~LocationDef()

LocationDef::~LocationDef ( )
override

Definition at line 16 of file LocationDef.cc.

16 {}

Member Function Documentation

◆ fetchAllDefs()

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

Definition at line 80 of file LocationDef.cc.

80  {
81  this->checkConnection();
82  try {
83  Statement* stmt = m_conn->createStatement();
84  stmt->setSQL("SELECT def_id FROM location_def ORDER BY def_id");
85  ResultSet* rset = stmt->executeQuery();
86 
87  LocationDef locationDef;
88  locationDef.setConnection(m_env, m_conn);
89 
90  while (rset->next()) {
91  locationDef.setByID(rset->getInt(1));
92  fillVec->push_back(locationDef);
93  }
94  } catch (SQLException& e) {
95  throw(std::runtime_error("LocationDef::fetchAllDefs: " + e.getMessage()));
96  }
97 }

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

◆ fetchID()

int LocationDef::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 27 of file LocationDef.cc.

27  {
28  // Return def from memory if available
29  if (m_ID) {
30  return m_ID;
31  }
32 
33  this->checkConnection();
34 
35  try {
36  Statement* stmt = m_conn->createStatement();
37  stmt->setSQL(
38  "SELECT def_id FROM location_def WHERE "
39  "location = :location");
40  stmt->setString(1, m_loc);
41 
42  ResultSet* rset = stmt->executeQuery();
43 
44  if (rset->next()) {
45  m_ID = rset->getInt(1);
46  } else {
47  m_ID = 0;
48  }
49  m_conn->terminateStatement(stmt);
50  } catch (SQLException& e) {
51  throw(std::runtime_error("LocationDef::fetchID: " + e.getMessage()));
52  }
53 
54  return m_ID;
55 }

References MillePedeFileConverter_cfg::e.

◆ getLocation()

string LocationDef::getLocation ( ) const

Definition at line 18 of file LocationDef.cc.

18 { return m_loc; }

Referenced by EcalErrorMask::readDB().

◆ operator!=()

bool LocationDef::operator!= ( const LocationDef l) const
inline

Definition at line 28 of file LocationDef.h.

28 { return m_loc != l.m_loc; }

References cmsLHEtoEOSManager::l, and m_loc.

◆ operator==()

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

Definition at line 27 of file LocationDef.h.

27 { return m_loc == l.m_loc; }

References cmsLHEtoEOSManager::l, and m_loc.

◆ setByID()

void LocationDef::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 57 of file LocationDef.cc.

57  {
58  this->checkConnection();
59 
60  try {
61  Statement* stmt = m_conn->createStatement();
62 
63  stmt->setSQL("SELECT location FROM location_def WHERE def_id = :1");
64  stmt->setInt(1, id);
65 
66  ResultSet* rset = stmt->executeQuery();
67  if (rset->next()) {
68  m_loc = rset->getString(1);
69  m_ID = id;
70  } else {
71  throw(std::runtime_error("LocationDef::setByID: Given def_id is not in the database"));
72  }
73 
74  m_conn->terminateStatement(stmt);
75  } catch (SQLException& e) {
76  throw(std::runtime_error("LocationDef::setByID: " + e.getMessage()));
77  }
78 }

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

Referenced by fetchAllDefs().

◆ setLocation()

void LocationDef::setLocation ( std::string  loc)

Definition at line 20 of file LocationDef.cc.

20  {
21  if (loc != m_loc) {
22  m_ID = 0;
23  m_loc = loc;
24  }
25 }

Referenced by EcalCondDBWriter::dqmEndJob(), and EcalPedOffset::writeDb().

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file LocationDef.h.

Member Data Documentation

◆ m_loc

std::string LocationDef::m_loc
protected

Definition at line 32 of file LocationDef.h.

Referenced by operator!=(), and operator==().

IUniqueDBObject::m_ID
int m_ID
Definition: IUniqueDBObject.h:18
LocationDef
Definition: LocationDef.h:12
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
LocationDef::setByID
void setByID(int id) noexcept(false) override
Definition: LocationDef.cc:57
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
LocationDef::m_loc
std::string m_loc
Definition: LocationDef.h:32
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37