CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 int const ECALDB_NROWS = 1024
 

Detailed Description

Def for Location information

Definition at line 12 of file MonVersionDef.h.

Constructor & Destructor Documentation

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 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string m_desc
Definition: MonVersionDef.h:36
std::string m_monVer
Definition: MonVersionDef.h:35
MonVersionDef::~MonVersionDef ( )
override

Definition at line 17 of file MonVersionDef.cc.

17 {}

Member Function Documentation

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

Definition at line 83 of file MonVersionDef.cc.

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

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

Implements IUniqueDBObject.

Definition at line 30 of file MonVersionDef.cc.

References alignCSCRings::e.

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

Definition at line 28 of file MonVersionDef.cc.

28 { return m_desc; }
std::string m_desc
Definition: MonVersionDef.h:36
string MonVersionDef::getMonitoringVersion ( ) const

Definition at line 19 of file MonVersionDef.cc.

19 { return m_monVer; }
std::string m_monVer
Definition: MonVersionDef.h:35
bool MonVersionDef::operator!= ( const MonVersionDef d) const
inline

Definition at line 31 of file MonVersionDef.h.

References m_monVer.

31 { return m_monVer != d.m_monVer; }
std::string m_monVer
Definition: MonVersionDef.h:35
bool MonVersionDef::operator== ( const MonVersionDef d) const
inline

Definition at line 30 of file MonVersionDef.h.

References m_monVer.

30 { return m_monVer == d.m_monVer; }
std::string m_monVer
Definition: MonVersionDef.h:35
void MonVersionDef::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 60 of file MonVersionDef.cc.

References alignCSCRings::e.

Referenced by fetchAllDefs().

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 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string m_desc
Definition: MonVersionDef.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string m_monVer
Definition: MonVersionDef.h:35
void MonVersionDef::setMonitoringVersion ( std::string  ver)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file MonVersionDef.h.

Member Data Documentation

std::string MonVersionDef::m_desc
protected

Definition at line 36 of file MonVersionDef.h.

std::string MonVersionDef::m_monVer
protected

Definition at line 35 of file MonVersionDef.h.

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