CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes | Friends

RunModeDef Class Reference

#include <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 NULL.

{
  m_env = NULL;
  m_conn = NULL;
  m_ID = 0;
  m_runMode = "";

}
RunModeDef::~RunModeDef ( ) [virtual]

Definition at line 20 of file RunModeDef.cc.

{
}

Member Function Documentation

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

Definition at line 106 of file RunModeDef.cc.

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

{
  this->checkConnection();
  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT def_id FROM ecal_run_mode_def ORDER BY def_id");
    ResultSet* rset = stmt->executeQuery();
    
    RunModeDef runModeDef;
    runModeDef.setConnection(m_env, m_conn);

    while(rset->next()) {
      runModeDef.setByID( rset->getInt(1) );
      fillVec->push_back( runModeDef );
    }
  } catch (SQLException &e) {
    throw(std::runtime_error("RunModeDef::fetchAllDefs:  "+e.getMessage()));
  }
}
int RunModeDef::fetchID ( ) throw (std::runtime_error) [virtual]

Implements IUniqueDBObject.

Definition at line 46 of file RunModeDef.cc.

{
  // Return def from memory if available
  if (m_ID) {
    return m_ID;
  }

  this->checkConnection();
  
  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT def_id FROM ecal_run_mode_def WHERE "
                 "run_mode_string   = :1"
                 );
    stmt->setString(1, m_runMode);

    ResultSet* rset = stmt->executeQuery();
    
    if (rset->next()) {
      m_ID = rset->getInt(1);
    } else {
      m_ID = 0;
    }
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("RunModeDef::fetchID:  "+e.getMessage()));
  }

  return m_ID;
}
string RunModeDef::getRunMode ( ) const

Definition at line 26 of file RunModeDef.cc.

{
  return m_runMode;
}
bool RunModeDef::operator!= ( const RunModeDef t) const [inline]

Definition at line 31 of file RunModeDef.h.

References m_runMode.

{ 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.

{ 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.

Referenced by fetchAllDefs().

{
  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();

    stmt->setSQL("SELECT run_mode_string FROM ecal_run_mode_def WHERE def_id = :1");
    stmt->setInt(1, id);

    ResultSet* rset = stmt->executeQuery();
    if (rset->next()) {
      m_runMode = rset->getString(1);
    } else {
      throw(std::runtime_error("RunModeDef::setByID:  Given def_id is not in the database"));
    }
    
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
   throw(std::runtime_error("RunModeDef::setByID:  "+e.getMessage()));
  }
}
void RunModeDef::setRunMode ( std::string  runmode)

Definition at line 33 of file RunModeDef.cc.

{
  if (runmode != m_runMode) {
    m_ID = 0;
    m_runMode = 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 operator!=(), and operator==().