CMS 3D CMS Logo

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

#include <MonVersionDef.h>

Inheritance diagram for MonVersionDef:
IDef IUniqueDBObject IDBObject

Public Member Functions

int fetchID () noexcept(false) override
 
std::string getDescription () const
 
std::string getMonitoringVersion () const
 
 MonVersionDef ()
 
bool operator!= (const MonVersionDef &d) const
 
bool operator== (const MonVersionDef &d) const
 
void setByID (int id) noexcept(false) override
 
void setMonitoringVersion (std::string ver)
 
 ~MonVersionDef () 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< MonVersionDef > *fillVec) noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 

Protected Attributes

std::string m_desc
 
std::string m_monVer
 
- 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 MonVersionDef.h.

Constructor & Destructor Documentation

◆ MonVersionDef()

MonVersionDef::MonVersionDef ( )

Definition at line 9 of file MonVersionDef.cc.

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

◆ ~MonVersionDef()

MonVersionDef::~MonVersionDef ( )
override

Definition at line 17 of file MonVersionDef.cc.

17 {}

Member Function Documentation

◆ fetchAllDefs()

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

Definition at line 83 of file MonVersionDef.cc.

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

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

◆ fetchID()

int MonVersionDef::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 30 of file MonVersionDef.cc.

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

References MillePedeFileConverter_cfg::e.

◆ getDescription()

string MonVersionDef::getDescription ( ) const

Definition at line 28 of file MonVersionDef.cc.

28 { return m_desc; }

◆ getMonitoringVersion()

string MonVersionDef::getMonitoringVersion ( ) const

Definition at line 19 of file MonVersionDef.cc.

19 { return m_monVer; }

◆ operator!=()

bool MonVersionDef::operator!= ( const MonVersionDef d) const
inline

Definition at line 31 of file MonVersionDef.h.

31 { return m_monVer != d.m_monVer; }

References ztail::d, and m_monVer.

◆ operator==()

bool MonVersionDef::operator== ( const MonVersionDef d) const
inline

Definition at line 30 of file MonVersionDef.h.

30 { return m_monVer == d.m_monVer; }

References ztail::d, and m_monVer.

◆ setByID()

void MonVersionDef::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 60 of file MonVersionDef.cc.

60  {
61  this->checkConnection();
62 
63  try {
64  Statement* stmt = m_conn->createStatement();
65 
66  stmt->setSQL("SELECT mon_ver, description FROM mon_version_def WHERE def_id = :1");
67  stmt->setInt(1, id);
68 
69  ResultSet* rset = stmt->executeQuery();
70  if (rset->next()) {
71  m_monVer = rset->getString(1);
72  m_desc = rset->getString(2);
73  } else {
74  throw(std::runtime_error("MonVersionDef::setByID: Given def_id is not in the database"));
75  }
76 
77  m_conn->terminateStatement(stmt);
78  } catch (SQLException& e) {
79  throw(std::runtime_error("MonVersionDef::setByID: " + e.getMessage()));
80  }
81 }

References MillePedeFileConverter_cfg::e.

Referenced by fetchAllDefs().

◆ setMonitoringVersion()

void MonVersionDef::setMonitoringVersion ( std::string  ver)

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonVersionDef.h.

Member Data Documentation

◆ m_desc

std::string MonVersionDef::m_desc
protected

Definition at line 36 of file MonVersionDef.h.

◆ m_monVer

std::string MonVersionDef::m_monVer
protected

Definition at line 35 of file MonVersionDef.h.

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

IUniqueDBObject::m_ID
int m_ID
Definition: IUniqueDBObject.h:18
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
MonVersionDef::m_desc
std::string m_desc
Definition: MonVersionDef.h:36
MonVersionDef
Definition: MonVersionDef.h:12
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
MonVersionDef::m_monVer
std::string m_monVer
Definition: MonVersionDef.h:35
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
ztail.d
d
Definition: ztail.py:151
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
MonVersionDef::setByID
void setByID(int id) noexcept(false) override
Definition: MonVersionDef.cc:60
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37