CMS 3D CMS Logo

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

#include <RunModeDef.h>

Inheritance diagram for RunModeDef:
IDef IUniqueDBObject IDBObject

Public Member Functions

int fetchID () noexcept(false) override
 
std::string getRunMode () const
 
bool operator!= (const RunModeDef &t) const
 
bool operator== (const RunModeDef &t) const
 
 RunModeDef ()
 
void setByID (int id) noexcept(false) override
 
void setRunMode (std::string runmode)
 
 ~RunModeDef () 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< RunModeDef > *fillVec) noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 

Protected Attributes

std::string m_runMode
 
- 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 RunModeDef.h.

Constructor & Destructor Documentation

◆ RunModeDef()

RunModeDef::RunModeDef ( )

Definition at line 9 of file RunModeDef.cc.

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

◆ ~RunModeDef()

RunModeDef::~RunModeDef ( )
override

Definition at line 16 of file RunModeDef.cc.

16 {}

Member Function Documentation

◆ fetchAllDefs()

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

Definition at line 79 of file RunModeDef.cc.

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

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

◆ fetchID()

int RunModeDef::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 27 of file RunModeDef.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 ecal_run_mode_def WHERE "
39  "run_mode_string = :1");
40  stmt->setString(1, m_runMode);
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("RunModeDef::fetchID: " + e.getMessage()));
52  }
53 
54  return m_ID;
55 }

References MillePedeFileConverter_cfg::e.

◆ getRunMode()

string RunModeDef::getRunMode ( ) const

Definition at line 18 of file RunModeDef.cc.

18 { return m_runMode; }

◆ operator!=()

bool RunModeDef::operator!= ( const RunModeDef t) const
inline

Definition at line 29 of file RunModeDef.h.

29 { return m_runMode != t.m_runMode; }

References m_runMode, and OrderedSet::t.

◆ operator==()

bool RunModeDef::operator== ( const RunModeDef t) const
inline

Definition at line 28 of file RunModeDef.h.

28 { return m_runMode == t.m_runMode; }

References m_runMode, and OrderedSet::t.

◆ setByID()

void RunModeDef::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 57 of file RunModeDef.cc.

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

References MillePedeFileConverter_cfg::e.

Referenced by fetchAllDefs().

◆ setRunMode()

void RunModeDef::setRunMode ( std::string  runmode)

Definition at line 20 of file RunModeDef.cc.

20  {
21  if (runmode != m_runMode) {
22  m_ID = 0;
24  }
25 }

References SiStripCommissioningClient_cfg::runmode.

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file RunModeDef.h.

Member Data Documentation

◆ m_runMode

std::string RunModeDef::m_runMode
protected

Definition at line 33 of file RunModeDef.h.

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

IUniqueDBObject::m_ID
int m_ID
Definition: IUniqueDBObject.h:18
RunModeDef
Definition: RunModeDef.h:12
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
RunModeDef::setByID
void setByID(int id) noexcept(false) override
Definition: RunModeDef.cc:57
OrderedSet.t
t
Definition: OrderedSet.py:90
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
SiStripCommissioningClient_cfg.runmode
runmode
Definition: SiStripCommissioningClient_cfg.py:8
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
RunModeDef::m_runMode
std::string m_runMode
Definition: RunModeDef.h:33
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37