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)
 
std::string getRunMode () const
 
bool operator!= (const RunModeDef &t) const
 
bool operator== (const RunModeDef &t) const
 
 RunModeDef ()
 
void setByID (int id) noexcept(false)
 
void setRunMode (std::string runmode)
 
virtual ~RunModeDef ()
 
- 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 int const ECALDB_NROWS =1024
 

Detailed Description

Def for Location information

Definition at line 12 of file RunModeDef.h.

Constructor & Destructor Documentation

RunModeDef::RunModeDef ( )

Definition at line 9 of file RunModeDef.cc.

References NULL.

10 {
11  m_env = NULL;
12  m_conn = NULL;
13  m_ID = 0;
14  m_runMode = "";
15 
16 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
std::string m_runMode
Definition: RunModeDef.h:35
RunModeDef::~RunModeDef ( )
virtual

Definition at line 20 of file RunModeDef.cc.

21 {
22 }

Member Function Documentation

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

Definition at line 106 of file RunModeDef.cc.

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

108 {
109  this->checkConnection();
110  try {
111  Statement* stmt = m_conn->createStatement();
112  stmt->setSQL("SELECT def_id FROM ecal_run_mode_def ORDER BY def_id");
113  ResultSet* rset = stmt->executeQuery();
114 
115  RunModeDef runModeDef;
116  runModeDef.setConnection(m_env, m_conn);
117 
118  while(rset->next()) {
119  runModeDef.setByID( rset->getInt(1) );
120  fillVec->push_back( runModeDef );
121  }
122  } catch (SQLException &e) {
123  throw(std::runtime_error("RunModeDef::fetchAllDefs: "+e.getMessage()));
124  }
125 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setByID(int id) noexcept(false)
Definition: RunModeDef.cc:80
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int RunModeDef::fetchID ( )
virtualnoexcept

Implements IUniqueDBObject.

Definition at line 46 of file RunModeDef.cc.

References MillePedeFileConverter_cfg::e.

48 {
49  // Return def from memory if available
50  if (m_ID) {
51  return m_ID;
52  }
53 
54  this->checkConnection();
55 
56  try {
57  Statement* stmt = m_conn->createStatement();
58  stmt->setSQL("SELECT def_id FROM ecal_run_mode_def WHERE "
59  "run_mode_string = :1"
60  );
61  stmt->setString(1, m_runMode);
62 
63  ResultSet* rset = stmt->executeQuery();
64 
65  if (rset->next()) {
66  m_ID = rset->getInt(1);
67  } else {
68  m_ID = 0;
69  }
70  m_conn->terminateStatement(stmt);
71  } catch (SQLException &e) {
72  throw(std::runtime_error("RunModeDef::fetchID: "+e.getMessage()));
73  }
74 
75  return m_ID;
76 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string m_runMode
Definition: RunModeDef.h:35
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
string RunModeDef::getRunMode ( ) const

Definition at line 26 of file RunModeDef.cc.

27 {
28  return m_runMode;
29 }
std::string m_runMode
Definition: RunModeDef.h:35
bool RunModeDef::operator!= ( const RunModeDef t) const
inline

Definition at line 31 of file RunModeDef.h.

References m_runMode.

31 { return m_runMode != t.m_runMode; }
std::string m_runMode
Definition: RunModeDef.h:35
bool RunModeDef::operator== ( const RunModeDef t) const
inline

Definition at line 30 of file RunModeDef.h.

References m_runMode.

30 { return m_runMode == t.m_runMode; }
std::string m_runMode
Definition: RunModeDef.h:35
void RunModeDef::setByID ( int  id)
virtualnoexcept

Implements IUniqueDBObject.

Definition at line 80 of file RunModeDef.cc.

References MillePedeFileConverter_cfg::e.

Referenced by fetchAllDefs().

82 {
83  this->checkConnection();
84 
85  try {
86  Statement* stmt = m_conn->createStatement();
87 
88  stmt->setSQL("SELECT run_mode_string FROM ecal_run_mode_def WHERE def_id = :1");
89  stmt->setInt(1, id);
90 
91  ResultSet* rset = stmt->executeQuery();
92  if (rset->next()) {
93  m_runMode = rset->getString(1);
94  } else {
95  throw(std::runtime_error("RunModeDef::setByID: Given def_id is not in the database"));
96  }
97 
98  m_conn->terminateStatement(stmt);
99  } catch (SQLException &e) {
100  throw(std::runtime_error("RunModeDef::setByID: "+e.getMessage()));
101  }
102 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string m_runMode
Definition: RunModeDef.h:35
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void RunModeDef::setRunMode ( std::string  runmode)

Definition at line 33 of file RunModeDef.cc.

34 {
35  if (runmode != m_runMode) {
36  m_ID = 0;
37  m_runMode = runmode;
38  }
39 }
std::string m_runMode
Definition: RunModeDef.h:35

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file RunModeDef.h.

Member Data Documentation

std::string RunModeDef::m_runMode
protected

Definition at line 35 of file RunModeDef.h.

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