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 int const 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 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string m_loc
Definition: LocationDef.h:32

◆ ~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.

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

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 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setByID(int id) noexcept(false) override
Definition: LocationDef.cc:57
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ fetchID()

int LocationDef::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 27 of file LocationDef.cc.

References MillePedeFileConverter_cfg::e.

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 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string m_loc
Definition: LocationDef.h:32

◆ getLocation()

string LocationDef::getLocation ( ) const

Definition at line 18 of file LocationDef.cc.

Referenced by EcalErrorMask::readDB().

18 { return m_loc; }
std::string m_loc
Definition: LocationDef.h:32

◆ operator!=()

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

Definition at line 28 of file LocationDef.h.

References cmsLHEtoEOSManager::l, and m_loc.

28 { return m_loc != l.m_loc; }
std::string m_loc
Definition: LocationDef.h:32

◆ operator==()

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

Definition at line 27 of file LocationDef.h.

References cmsLHEtoEOSManager::l, and m_loc.

27 { return m_loc == l.m_loc; }
std::string m_loc
Definition: LocationDef.h:32

◆ setByID()

void LocationDef::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 57 of file LocationDef.cc.

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

Referenced by fetchAllDefs().

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 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string m_loc
Definition: LocationDef.h:32

◆ setLocation()

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

Definition at line 20 of file LocationDef.cc.

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

20  {
21  if (loc != m_loc) {
22  m_ID = 0;
23  m_loc = loc;
24  }
25 }
std::string m_loc
Definition: LocationDef.h:32

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