CMS 3D CMS Logo

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

MonRunOutcomeDef Class Reference

#include <MonRunOutcomeDef.h>

Inheritance diagram for MonRunOutcomeDef:
IDef IUniqueDBObject IDBObject

List of all members.

Public Member Functions

int fetchID () throw (std::runtime_error)
std::string getLongDesc () const
std::string getShortDesc () const
 MonRunOutcomeDef ()
bool operator!= (const MonRunOutcomeDef &d) const
bool operator== (const MonRunOutcomeDef &d) const
void setByID (int id) throw (std::runtime_error)
void setShortDesc (std::string desc)
virtual ~MonRunOutcomeDef ()

Protected Member Functions

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

Protected Attributes

std::string m_longDesc
std::string m_shortDesc

Friends

class EcalCondDBInterface

Detailed Description

Def for monitoring run outcomes

Definition at line 12 of file MonRunOutcomeDef.h.


Constructor & Destructor Documentation

MonRunOutcomeDef::MonRunOutcomeDef ( )

Definition at line 10 of file MonRunOutcomeDef.cc.

References NULL.

{
  m_env = NULL;
  m_conn = NULL;
  m_ID = 0;
  m_shortDesc = "";
  m_longDesc = "";

}
MonRunOutcomeDef::~MonRunOutcomeDef ( ) [virtual]

Definition at line 22 of file MonRunOutcomeDef.cc.

{
}

Member Function Documentation

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

Definition at line 113 of file MonRunOutcomeDef.cc.

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

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

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

Implements IUniqueDBObject.

Definition at line 52 of file MonRunOutcomeDef.cc.

References alignCSCRings::e.

Referenced by MonRunDat::writeDB().

{
  // 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 mon_run_outcome_def WHERE "
                 "short_desc = :1");
    stmt->setString(1, m_shortDesc);

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

  return m_ID;
}
string MonRunOutcomeDef::getLongDesc ( ) const

Definition at line 45 of file MonRunOutcomeDef.cc.

{
  return m_longDesc;
}
string MonRunOutcomeDef::getShortDesc ( ) const

Definition at line 28 of file MonRunOutcomeDef.cc.

{
  return m_shortDesc;
}
bool MonRunOutcomeDef::operator!= ( const MonRunOutcomeDef d) const [inline]

Definition at line 31 of file MonRunOutcomeDef.h.

References m_shortDesc.

{ return m_shortDesc != d.m_shortDesc; }
bool MonRunOutcomeDef::operator== ( const MonRunOutcomeDef d) const [inline]

Definition at line 30 of file MonRunOutcomeDef.h.

References m_shortDesc.

{ return m_shortDesc == d.m_shortDesc; }
void MonRunOutcomeDef::setByID ( int  id) throw (std::runtime_error) [virtual]

Implements IUniqueDBObject.

Definition at line 85 of file MonRunOutcomeDef.cc.

References alignCSCRings::e, and errorMatrix2Lands_multiChannel::id.

Referenced by fetchAllDefs().

{
  this->checkConnection();

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

    stmt->setSQL("SELECT short_desc, long_desc FROM mon_run_outcome_def WHERE def_id = :1");
    stmt->setInt(1, id);

    ResultSet* rset = stmt->executeQuery();
    if (rset->next()) {
      m_shortDesc = rset->getString(1);
      m_longDesc = rset->getString(2);
      m_ID = id;
    } else {
      throw(std::runtime_error("MonRunOutcomeDef::setByID:  Given def_id is not in the database"));
    }
    
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
   throw(std::runtime_error("MonRunOutcomeDef::setByID:  "+e.getMessage()));
  }
}
void MonRunOutcomeDef::setShortDesc ( std::string  desc)

Definition at line 35 of file MonRunOutcomeDef.cc.

Referenced by EcalEndcapMonitorClient::writeDb(), and EcalBarrelMonitorClient::writeDb().

{
  if (desc != m_shortDesc) {
    m_ID = 0;
    m_shortDesc = desc;
  }
}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file MonRunOutcomeDef.h.


Member Data Documentation

std::string MonRunOutcomeDef::m_longDesc [protected]

Definition at line 36 of file MonRunOutcomeDef.h.

std::string MonRunOutcomeDef::m_shortDesc [protected]

Definition at line 35 of file MonRunOutcomeDef.h.

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