test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 () throw (std::runtime_error)
 
std::string getRunMode () const
 
bool operator!= (const RunModeDef &t) const
 
bool operator== (const RunModeDef &t) const
 
 RunModeDef ()
 
void setByID (int id) throw (std::runtime_error)
 
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) throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 

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)
throw (std::runtime_error
)
protected

Definition at line 106 of file RunModeDef.cc.

References alignCSCRings::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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setByID(int id)
Definition: RunModeDef.cc:80
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
int RunModeDef::fetchID ( )
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 46 of file RunModeDef.cc.

References alignCSCRings::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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string m_runMode
Definition: RunModeDef.h:35
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void checkConnection() const
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)
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 80 of file RunModeDef.cc.

References alignCSCRings::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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string m_runMode
Definition: RunModeDef.h:35
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void checkConnection() const
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==().