CMS 3D CMS Logo

ODLTSConfig Class Reference

#include <OnlineDB/EcalCondDB/interface/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< string, 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 10 of file ODLTSConfig.cc.

References clear(), IODConfig::m_config_tag, IDBObject::m_conn, IDBObject::m_env, m_ID, IODConfig::m_readStmt, IODConfig::m_writeStmt, and NULL.

00011 {
00012   m_env = NULL;
00013   m_conn = NULL;
00014   m_writeStmt = NULL;
00015   m_readStmt = NULL;
00016   m_config_tag="";
00017   m_ID=0;
00018   clear();
00019 
00020 }

ODLTSConfig::~ODLTSConfig (  ) 

Definition at line 31 of file ODLTSConfig.cc.

00032 {
00033 }


Member Function Documentation

void ODLTSConfig::clear ( void   )  [private]

Definition at line 22 of file ODLTSConfig.cc.

References m_delay, m_num, m_rate, and m_trg_type.

Referenced by ODLTSConfig().

00022                        {
00023   m_trg_type="";
00024   m_num=0;
00025   m_rate=0;
00026   m_delay=0;
00027 }

void ODLTSConfig::fetchData ( ODLTSConfig result  )  throw (std::runtime_error) [private]

Definition at line 126 of file ODLTSConfig.cc.

References IDBObject::checkConnection(), e, IODConfig::m_readStmt, and HLT_VtxMuL3::result.

00128 {
00129   this->checkConnection();
00130   result->clear();
00131   if(result->getId()==0 && (result->getConfigTag()=="") ){
00132     throw(runtime_error("ODLTSConfig::fetchData(): no Id defined for this ODLTSConfig "));
00133   }
00134 
00135   try {
00136 
00137     m_readStmt->setSQL("SELECT * "
00138                        "FROM ECAL_LTS_CONFIGURATION  "
00139                        " where ( lts_configuration_id = :1 or lts_tag=:2 ) " );
00140     m_readStmt->setInt(1, result->getId());
00141     m_readStmt->setString(2, result->getConfigTag());
00142     ResultSet* rset = m_readStmt->executeQuery();
00143 
00144     rset->next();
00145     // 1 is the id and 2 is the config tag
00146     result->setId(rset->getInt(1));
00147     result->setConfigTag(rset->getString(2));
00148 
00149     result->setTriggerType(        rset->getString(3) );
00150     result->setNumberOfEvents(     rset->getInt(4) );
00151     result->setRate(               rset->getInt(5) );
00152     result->setTrigLocL1Delay(     rset->getInt(6) );
00153   
00154 
00155   } catch (SQLException &e) {
00156     throw(runtime_error("ODLTSConfig::fetchData():  "+e.getMessage()));
00157   }
00158 }

int ODLTSConfig::fetchID (  )  throw (std::runtime_error) [private]

Definition at line 160 of file ODLTSConfig.cc.

References IDBObject::checkConnection(), e, IODConfig::getConfigTag(), IDBObject::m_conn, and m_ID.

00161 {
00162   // Return from memory if available
00163   if (m_ID!=0) {
00164     return m_ID;
00165   }
00166 
00167   this->checkConnection();
00168 
00169   try {
00170     Statement* stmt = m_conn->createStatement();
00171     stmt->setSQL("SELECT lts_configuration_id FROM ecal_lts_configuration "
00172                  "WHERE  lts_tag=:lts_tag  " );
00173 
00174     stmt->setString(1, getConfigTag());
00175 
00176     ResultSet* rset = stmt->executeQuery();
00177 
00178     if (rset->next()) {
00179       m_ID = rset->getInt(1);
00180     } else {
00181       m_ID = 0;
00182     }
00183     m_conn->terminateStatement(stmt);
00184   } catch (SQLException &e) {
00185     throw(runtime_error("ODLTSConfig::fetchID:  "+e.getMessage()));
00186   }
00187 
00188   return m_ID;
00189 }

int ODLTSConfig::fetchNextId (  )  throw (std::runtime_error) [private]

Definition at line 52 of file ODLTSConfig.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.

Referenced by prepareWrite().

00052                                                       {
00053 
00054   int result=0;
00055   try {
00056     this->checkConnection();
00057 
00058     m_readStmt = m_conn->createStatement(); 
00059     m_readStmt->setSQL("select ecal_lts_config_sq.NextVal from dual");
00060     ResultSet* rset = m_readStmt->executeQuery();
00061     while (rset->next ()){
00062       result= rset->getInt(1);
00063     }
00064     m_conn->terminateStatement(m_readStmt);
00065     return result; 
00066 
00067   } catch (SQLException &e) {
00068     throw(runtime_error("ODLTSConfig::fetchNextId():  "+e.getMessage()));
00069   }
00070 
00071 }

int ODLTSConfig::getId (  )  const [inline]

Definition at line 19 of file ODLTSConfig.h.

References m_ID.

00019 { return m_ID; }

int ODLTSConfig::getNumberOfEvents (  )  const [inline]

Definition at line 25 of file ODLTSConfig.h.

References m_num.

00025 { return m_num; }

int ODLTSConfig::getRate (  )  const [inline]

Definition at line 28 of file ODLTSConfig.h.

References m_rate.

00028 { return m_rate; }

std::string ODLTSConfig::getTable (  )  [inline, virtual]

Implements IODConfig.

Definition at line 16 of file ODLTSConfig.h.

00016 { return "ECAL_LTS_CONFIGURATION"; }

std::string ODLTSConfig::getTriggerType (  )  const [inline]

Definition at line 22 of file ODLTSConfig.h.

References m_trg_type.

00022 { return m_trg_type; }

int ODLTSConfig::getTrigLocL1Delay (  )  const [inline]

Definition at line 31 of file ODLTSConfig.h.

References m_delay.

00031 { return m_delay; }

void ODLTSConfig::prepareWrite (  )  throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 74 of file ODLTSConfig.cc.

References IDBObject::checkConnection(), e, fetchNextId(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.

00076 {
00077   this->checkConnection();
00078   int next_id=fetchNextId();
00079 
00080   try {
00081     m_writeStmt = m_conn->createStatement();
00082     m_writeStmt->setSQL("INSERT INTO ECAL_LTS_CONFIGURATION ( lts_configuration_id, lts_tag, "
00083                         "trigger_type, num_of_events, rate, trig_loc_l1_delay ) "
00084                         "VALUES (  "
00085                         ":1, :2, :3, :4 , :5, :6 )");
00086     m_writeStmt->setInt(1, next_id);
00087     m_ID=next_id;
00088 
00089   } catch (SQLException &e) {
00090     throw(runtime_error("ODLTSConfig::prepareWrite():  "+e.getMessage()));
00091   }
00092 }

void ODLTSConfig::setId ( int  id  )  [inline]

Definition at line 18 of file ODLTSConfig.h.

References m_ID.

00018 { m_ID = id; }

void ODLTSConfig::setNumberOfEvents ( int  x  )  [inline]

Definition at line 24 of file ODLTSConfig.h.

References m_num.

Referenced by setParameters().

00024 { m_num = x; }

void ODLTSConfig::setParameters ( std::map< string, string >  my_keys_map  ) 

Definition at line 35 of file ODLTSConfig.cc.

References IODConfig::setConfigTag(), setNumberOfEvents(), setRate(), setTriggerType(), and setTrigLocL1Delay().

00035                                                                 {
00036   
00037   // parses the result of the XML parser that is a map of 
00038   // string string with variable name variable value 
00039   
00040   for( std::map<std::string, std::string >::iterator ci=
00041          my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
00042 
00043     if(ci->first==  "LTS_CONFIGURATION_ID") setConfigTag(ci->second);
00044     if(ci->first==  "NUM_OF_EVENTS") setNumberOfEvents(atoi(ci->second.c_str()) );
00045     if(ci->first==  "RATE") setRate(atoi(ci->second.c_str() ));
00046     if(ci->first==  "TRIGGER_TYPE") setTriggerType(ci->second );
00047     if(ci->first==  "TRIG_LOC_L1_DELAY") setTrigLocL1Delay(atoi(ci->second.c_str() ));
00048   }
00049   
00050 }

void ODLTSConfig::setRate ( int  x  )  [inline]

Definition at line 27 of file ODLTSConfig.h.

References m_rate.

Referenced by setParameters().

00027 { m_rate = x; }

void ODLTSConfig::setTriggerType ( std::string  x  )  [inline]

Definition at line 21 of file ODLTSConfig.h.

References m_trg_type.

Referenced by setParameters().

00021 { m_trg_type = x; }

void ODLTSConfig::setTrigLocL1Delay ( int  x  )  [inline]

Definition at line 30 of file ODLTSConfig.h.

References m_delay.

Referenced by setParameters().

00030 { m_delay = x; }

void ODLTSConfig::writeDB (  )  throw (std::runtime_error) [private]

Definition at line 96 of file ODLTSConfig.cc.

References IDBObject::checkConnection(), IODConfig::checkPrepare(), e, and IODConfig::m_writeStmt.

00098 {
00099   this->checkConnection();
00100   this->checkPrepare();
00101 
00102   try {
00103 
00104     m_writeStmt->setString(2, this->getConfigTag());
00105     m_writeStmt->setString(3, this->getTriggerType());
00106     m_writeStmt->setInt(4, this->getNumberOfEvents());
00107     m_writeStmt->setInt(5, this->getRate());
00108     m_writeStmt->setInt(6, this->getTrigLocL1Delay());
00109 
00110     m_writeStmt->executeUpdate();
00111 
00112 
00113   } catch (SQLException &e) {
00114     throw(runtime_error("ODLTSConfig::writeDB():  "+e.getMessage()));
00115   }
00116   // Now get the ID
00117   if (!this->fetchID()) {
00118     throw(runtime_error("ODLTSConfig::writeDB:  Failed to write"));
00119   }
00120 
00121 
00122 }


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 clear(), getTrigLocL1Delay(), and setTrigLocL1Delay().

int ODLTSConfig::m_ID [private]

Definition at line 43 of file ODLTSConfig.h.

Referenced by fetchID(), getId(), ODLTSConfig(), prepareWrite(), and setId().

int ODLTSConfig::m_num [private]

Definition at line 45 of file ODLTSConfig.h.

Referenced by clear(), getNumberOfEvents(), and setNumberOfEvents().

int ODLTSConfig::m_rate [private]

Definition at line 46 of file ODLTSConfig.h.

Referenced by clear(), getRate(), and setRate().

std::string ODLTSConfig::m_trg_type [private]

Definition at line 44 of file ODLTSConfig.h.

Referenced by clear(), getTriggerType(), and setTriggerType().


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