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
MonVersionDef Class Reference

#include <MonVersionDef.h>

Inheritance diagram for MonVersionDef:
IDef IUniqueDBObject IDBObject

Public Member Functions

int fetchID () throw (std::runtime_error)
 
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) throw (std::runtime_error)
 
void setMonitoringVersion (std::string ver)
 
virtual ~MonVersionDef ()
 
- 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) throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 

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.

References NULL.

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

Definition at line 20 of file MonVersionDef.cc.

21 {
22 }

Member Function Documentation

void MonVersionDef::fetchAllDefs ( std::vector< MonVersionDef > *  fillVec)
throw (std::runtime_error
)
protected

Definition at line 110 of file MonVersionDef.cc.

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

112 {
113  this->checkConnection();
114  try {
115  Statement* stmt = m_conn->createStatement();
116  stmt->setSQL("SELECT def_id FROM mon_version_def ORDER BY def_id");
117  ResultSet* rset = stmt->executeQuery();
118 
119  MonVersionDef monVersionDef;
120  monVersionDef.setConnection(m_env, m_conn);
121 
122  while(rset->next()) {
123  monVersionDef.setByID( rset->getInt(1) );
124  fillVec->push_back( monVersionDef );
125  }
126  } catch (SQLException &e) {
127  throw(std::runtime_error("MonVersionDef::fetchAllDefs: "+e.getMessage()));
128  }
129 }
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:22
void setByID(int id)
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
int MonVersionDef::fetchID ( )
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 49 of file MonVersionDef.cc.

References alignCSCRings::e.

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

Definition at line 42 of file MonVersionDef.cc.

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

Definition at line 26 of file MonVersionDef.cc.

27 {
28  return m_monVer;
29 }
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)
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 83 of file MonVersionDef.cc.

References alignCSCRings::e.

Referenced by fetchAllDefs().

85 {
86  this->checkConnection();
87 
88  try {
89  Statement* stmt = m_conn->createStatement();
90 
91  stmt->setSQL("SELECT mon_ver, description FROM mon_version_def WHERE def_id = :1");
92  stmt->setInt(1, id);
93 
94  ResultSet* rset = stmt->executeQuery();
95  if (rset->next()) {
96  m_monVer = rset->getString(1);
97  m_desc = rset->getString(2);
98  } else {
99  throw(std::runtime_error("MonVersionDef::setByID: Given def_id is not in the database"));
100  }
101 
102  m_conn->terminateStatement(stmt);
103  } catch (SQLException &e) {
104  throw(std::runtime_error("MonVersionDef::setByID: "+e.getMessage()));
105  }
106 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string m_desc
Definition: MonVersionDef.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
std::string m_monVer
Definition: MonVersionDef.h:35
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void checkConnection() const
Definition: IDBObject.h:41
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==().