CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

ODLTSConfig Class Reference

#include <ODLTSConfig.h>

Inheritance diagram for ODLTSConfig:
IODConfig IDBObject

List of all members.

Public Member Functions

int getId () const
int getNumberOfEvents () const
int getRate () const
std::string getTable ()
std::string getTriggerType () const
int getTrigLocL1Delay () const
 ODLTSConfig ()
void setId (int id)
void setNumberOfEvents (int x)
void setParameters (std::map< std::string, std::string > my_keys_map)
void setRate (int x)
void setTriggerType (std::string x)
void setTrigLocL1Delay (int x)
 ~ODLTSConfig ()

Private Member Functions

void clear ()
void fetchData (ODLTSConfig *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchNextId () throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

int m_delay
int m_ID
int m_num
int m_rate
std::string m_trg_type

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 9 of file ODLTSConfig.h.


Constructor & Destructor Documentation

ODLTSConfig::ODLTSConfig ( )

Definition at line 11 of file ODLTSConfig.cc.

References NULL.

ODLTSConfig::~ODLTSConfig ( )

Definition at line 32 of file ODLTSConfig.cc.

{
}

Member Function Documentation

void ODLTSConfig::clear ( void  ) [private]

Definition at line 23 of file ODLTSConfig.cc.

                       {
  m_trg_type="";
  m_num=0;
  m_rate=0;
  m_delay=0;
}
void ODLTSConfig::fetchData ( ODLTSConfig result) throw (std::runtime_error) [private]

Definition at line 127 of file ODLTSConfig.cc.

References query::result.

{
  this->checkConnection();
  result->clear();
  if(result->getId()==0 && (result->getConfigTag()=="") ){
    throw(std::runtime_error("ODLTSConfig::fetchData(): no Id defined for this ODLTSConfig "));
  }

  try {

    m_readStmt->setSQL("SELECT * "
                       "FROM ECAL_LTS_CONFIGURATION  "
                       " where ( lts_configuration_id = :1 or lts_tag=:2 ) " );
    m_readStmt->setInt(1, result->getId());
    m_readStmt->setString(2, result->getConfigTag());
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();
    // 1 is the id and 2 is the config tag
    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));

    result->setTriggerType(        rset->getString(3) );
    result->setNumberOfEvents(     rset->getInt(4) );
    result->setRate(               rset->getInt(5) );
    result->setTrigLocL1Delay(     rset->getInt(6) );
  

  } catch (SQLException &e) {
    throw(std::runtime_error("ODLTSConfig::fetchData():  "+e.getMessage()));
  }
}
int ODLTSConfig::fetchID ( ) throw (std::runtime_error) [private]

Definition at line 161 of file ODLTSConfig.cc.

{
  // Return from memory if available
  if (m_ID!=0) {
    return m_ID;
  }

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT lts_configuration_id FROM ecal_lts_configuration "
                 "WHERE  lts_tag=:lts_tag  " );

    stmt->setString(1, getConfigTag());

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

  return m_ID;
}
int ODLTSConfig::fetchNextId ( ) throw (std::runtime_error) [private]

Definition at line 53 of file ODLTSConfig.cc.

References query::result.

                                                      {

  int result=0;
  try {
    this->checkConnection();

    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select ecal_lts_config_sq.NextVal from dual");
    ResultSet* rset = m_readStmt->executeQuery();
    while (rset->next ()){
      result= rset->getInt(1);
    }
    m_conn->terminateStatement(m_readStmt);
    return result; 

  } catch (SQLException &e) {
    throw(std::runtime_error("ODLTSConfig::fetchNextId():  "+e.getMessage()));
  }

}
int ODLTSConfig::getId ( ) const [inline]

Definition at line 19 of file ODLTSConfig.h.

References m_ID.

{ return m_ID; }
int ODLTSConfig::getNumberOfEvents ( ) const [inline]

Definition at line 25 of file ODLTSConfig.h.

References m_num.

{ return m_num; }
int ODLTSConfig::getRate ( ) const [inline]

Definition at line 28 of file ODLTSConfig.h.

References m_rate.

{ return m_rate; }
std::string ODLTSConfig::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 16 of file ODLTSConfig.h.

{ return "ECAL_LTS_CONFIGURATION"; }
std::string ODLTSConfig::getTriggerType ( void  ) const [inline]

Definition at line 22 of file ODLTSConfig.h.

References m_trg_type.

{ return m_trg_type; }
int ODLTSConfig::getTrigLocL1Delay ( ) const [inline]

Definition at line 31 of file ODLTSConfig.h.

References m_delay.

{ return m_delay; }
void ODLTSConfig::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 75 of file ODLTSConfig.cc.

{
  this->checkConnection();
  int next_id=fetchNextId();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_LTS_CONFIGURATION ( lts_configuration_id, lts_tag, "
                        "trigger_type, num_of_events, rate, trig_loc_l1_delay ) "
                        "VALUES (  "
                        ":1, :2, :3, :4 , :5, :6 )");
    m_writeStmt->setInt(1, next_id);
    m_ID=next_id;

  } catch (SQLException &e) {
    throw(std::runtime_error("ODLTSConfig::prepareWrite():  "+e.getMessage()));
  }
}
void ODLTSConfig::setId ( int  id) [inline]

Definition at line 18 of file ODLTSConfig.h.

References m_ID.

{ m_ID = id; }
void ODLTSConfig::setNumberOfEvents ( int  x) [inline]

Definition at line 24 of file ODLTSConfig.h.

References m_num, and x.

{ m_num = x; }
void ODLTSConfig::setParameters ( std::map< std::string, std::string >  my_keys_map)
void ODLTSConfig::setRate ( int  x) [inline]

Definition at line 27 of file ODLTSConfig.h.

References m_rate, and x.

{ m_rate = x; }
void ODLTSConfig::setTriggerType ( std::string  x) [inline]

Definition at line 21 of file ODLTSConfig.h.

References m_trg_type, and x.

{ m_trg_type = x; }
void ODLTSConfig::setTrigLocL1Delay ( int  x) [inline]

Definition at line 30 of file ODLTSConfig.h.

References m_delay, and x.

{ m_delay = x; }
void ODLTSConfig::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 97 of file ODLTSConfig.cc.

{
  this->checkConnection();
  this->checkPrepare();

  try {

    m_writeStmt->setString(2, this->getConfigTag());
    m_writeStmt->setString(3, this->getTriggerType());
    m_writeStmt->setInt(4, this->getNumberOfEvents());
    m_writeStmt->setInt(5, this->getRate());
    m_writeStmt->setInt(6, this->getTrigLocL1Delay());

    m_writeStmt->executeUpdate();


  } catch (SQLException &e) {
    throw(std::runtime_error("ODLTSConfig::writeDB():  "+e.getMessage()));
  }
  // Now get the ID
  if (!this->fetchID()) {
    throw(std::runtime_error("ODLTSConfig::writeDB:  Failed to write"));
  }


}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 11 of file ODLTSConfig.h.


Member Data Documentation

int ODLTSConfig::m_delay [private]

Definition at line 47 of file ODLTSConfig.h.

Referenced by getTrigLocL1Delay(), and setTrigLocL1Delay().

int ODLTSConfig::m_ID [private]

Definition at line 43 of file ODLTSConfig.h.

Referenced by getId(), and setId().

int ODLTSConfig::m_num [private]

Definition at line 45 of file ODLTSConfig.h.

Referenced by getNumberOfEvents(), and setNumberOfEvents().

int ODLTSConfig::m_rate [private]

Definition at line 46 of file ODLTSConfig.h.

Referenced by getRate(), and setRate().

std::string ODLTSConfig::m_trg_type [private]

Definition at line 44 of file ODLTSConfig.h.

Referenced by getTriggerType(), and setTriggerType().