CMS 3D CMS Logo

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

RunTypeDef Class Reference

#include <RunTypeDef.h>

Inheritance diagram for RunTypeDef:
IDef IUniqueDBObject IDBObject

List of all members.

Public Member Functions

int fetchID () throw (std::runtime_error)
std::string getDescription () const
std::string getRunType () const
bool operator!= (const RunTypeDef &t) const
bool operator== (const RunTypeDef &t) const
 RunTypeDef ()
void setByID (int id) throw (std::runtime_error)
void setRunType (std::string runtype)
virtual ~RunTypeDef ()

Protected Member Functions

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

Protected Attributes

std::string m_desc
std::string m_runType

Friends

class EcalCondDBInterface

Detailed Description

Def for Location information

Definition at line 12 of file RunTypeDef.h.


Constructor & Destructor Documentation

RunTypeDef::RunTypeDef ( )

Definition at line 9 of file RunTypeDef.cc.

References NULL.

{
  m_env = NULL;
  m_conn = NULL;
  m_ID = 0;
  m_runType = "";
  m_desc = "";
}
RunTypeDef::~RunTypeDef ( ) [virtual]

Definition at line 20 of file RunTypeDef.cc.

{
}

Member Function Documentation

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

Definition at line 111 of file RunTypeDef.cc.

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

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

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

Implements IUniqueDBObject.

Definition at line 50 of file RunTypeDef.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 run_type_def WHERE "
                 "run_type   = :1"
                 );
    stmt->setString(1, m_runType);

    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("RunTypeDef::fetchID:  "+e.getMessage()));
  }

  return m_ID;
}
string RunTypeDef::getDescription ( ) const

Definition at line 43 of file RunTypeDef.cc.

{
  return m_desc;
}
string RunTypeDef::getRunType ( void  ) const

Definition at line 26 of file RunTypeDef.cc.

Referenced by EcalTPGDBApp::printTag().

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

Definition at line 31 of file RunTypeDef.h.

References m_runType.

{ return m_runType != t.m_runType; }
bool RunTypeDef::operator== ( const RunTypeDef t) const [inline]

Definition at line 30 of file RunTypeDef.h.

References m_runType.

{ return m_runType == t.m_runType; }
void RunTypeDef::setByID ( int  id) throw (std::runtime_error) [virtual]

Implements IUniqueDBObject.

Definition at line 84 of file RunTypeDef.cc.

Referenced by fetchAllDefs().

{
  this->checkConnection();

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

    stmt->setSQL("SELECT run_type, description FROM run_type_def WHERE def_id = :1");
    stmt->setInt(1, id);

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

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file RunTypeDef.h.


Member Data Documentation

std::string RunTypeDef::m_desc [protected]

Definition at line 36 of file RunTypeDef.h.

std::string RunTypeDef::m_runType [protected]

Definition at line 35 of file RunTypeDef.h.

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