CMS 3D CMS Logo

RunModeDef Class Reference

Def for Location information. More...

#include <OnlineDB/EcalCondDB/interface/RunModeDef.h>

Inheritance diagram for RunModeDef:

IDef IUniqueDBObject IDBObject

List of all members.

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 ()

Protected Member Functions

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

Protected Attributes

std::string m_runMode

Friends

class EcalCondDBInterface


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 IDBObject::m_conn, IDBObject::m_env, IUniqueDBObject::m_ID, m_runMode, and NULL.

00010 {
00011   m_env = NULL;
00012   m_conn = NULL;
00013   m_ID = 0;
00014   m_runMode = "";
00015 
00016 }

RunModeDef::~RunModeDef (  )  [virtual]

Definition at line 20 of file RunModeDef.cc.

00021 {
00022 }


Member Function Documentation

void RunModeDef::fetchAllDefs ( std::vector< RunModeDef > *  fillVec  )  throw (std::runtime_error) [protected]

Definition at line 106 of file RunModeDef.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, setByID(), and IDBObject::setConnection().

00108 {
00109   this->checkConnection();
00110   try {
00111     Statement* stmt = m_conn->createStatement();
00112     stmt->setSQL("SELECT def_id FROM ecal_run_mode_def ORDER BY def_id");
00113     ResultSet* rset = stmt->executeQuery();
00114     
00115     RunModeDef runModeDef;
00116     runModeDef.setConnection(m_env, m_conn);
00117 
00118     while(rset->next()) {
00119       runModeDef.setByID( rset->getInt(1) );
00120       fillVec->push_back( runModeDef );
00121     }
00122   } catch (SQLException &e) {
00123     throw(runtime_error("RunModeDef::fetchAllDefs:  "+e.getMessage()));
00124   }
00125 }

int RunModeDef::fetchID (  )  throw (std::runtime_error) [virtual]

Implements IUniqueDBObject.

Definition at line 46 of file RunModeDef.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IUniqueDBObject::m_ID, and m_runMode.

Referenced by ODRunConfigInfo::writeDB().

00048 {
00049   // Return def from memory if available
00050   if (m_ID) {
00051     return m_ID;
00052   }
00053 
00054   this->checkConnection();
00055   
00056   try {
00057     Statement* stmt = m_conn->createStatement();
00058     stmt->setSQL("SELECT def_id FROM ecal_run_mode_def WHERE "
00059                  "run_mode_string   = :1"
00060                  );
00061     stmt->setString(1, m_runMode);
00062 
00063     ResultSet* rset = stmt->executeQuery();
00064     
00065     if (rset->next()) {
00066       m_ID = rset->getInt(1);
00067     } else {
00068       m_ID = 0;
00069     }
00070     m_conn->terminateStatement(stmt);
00071   } catch (SQLException &e) {
00072     throw(runtime_error("RunModeDef::fetchID:  "+e.getMessage()));
00073   }
00074 
00075   return m_ID;
00076 }

string RunModeDef::getRunMode (  )  const

Definition at line 26 of file RunModeDef.cc.

References m_runMode.

00027 {
00028   return m_runMode;
00029 }

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

Definition at line 31 of file RunModeDef.h.

References m_runMode.

00031 { return m_runMode != t.m_runMode; }

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

Definition at line 30 of file RunModeDef.h.

References m_runMode.

00030 { return m_runMode == t.m_runMode; }

void RunModeDef::setByID ( int  id  )  throw (std::runtime_error) [virtual]

Implements IUniqueDBObject.

Definition at line 80 of file RunModeDef.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, and m_runMode.

Referenced by fetchAllDefs(), and ODRunConfigInfo::setByID().

00082 {
00083   this->checkConnection();
00084 
00085   try {
00086     Statement* stmt = m_conn->createStatement();
00087 
00088     stmt->setSQL("SELECT run_mode_string FROM ecal_run_mode_def WHERE def_id = :1");
00089     stmt->setInt(1, id);
00090 
00091     ResultSet* rset = stmt->executeQuery();
00092     if (rset->next()) {
00093       m_runMode = rset->getString(1);
00094     } else {
00095       throw(runtime_error("RunModeDef::setByID:  Given def_id is not in the database"));
00096     }
00097     
00098     m_conn->terminateStatement(stmt);
00099   } catch (SQLException &e) {
00100    throw(runtime_error("RunModeDef::setByID:  "+e.getMessage()));
00101   }
00102 }

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


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

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 fetchID(), getRunMode(), operator!=(), operator==(), RunModeDef(), and setByID().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:31:14 2009 for CMSSW by  doxygen 1.5.4