CMS 3D CMS Logo

ODFEDAQConfig Class Reference

#include <OnlineDB/EcalCondDB/interface/ODFEDAQConfig.h>

Inheritance diagram for ODFEDAQConfig:

IODConfig IDBObject

List of all members.

Public Member Functions

int fetchNextId () throw (std::runtime_error)
std::string getComment () const
int getDelayId () const
int getId () const
int getPedestalId () const
std::string getTable ()
int getVersion () const
int getWeightId () const
 ODFEDAQConfig ()
void setComment (std::string x)
void setDelayId (int x)
void setId (int id)
void setParameters (std::map< string, string > my_keys_map)
void setPedestalId (int x)
void setVersion (int id)
void setWeightId (int x)
 ~ODFEDAQConfig ()

Private Member Functions

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

Private Attributes

std::string m_com
int m_del
int m_ID
int m_ped
int m_version
int m_wei

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 9 of file ODFEDAQConfig.h.


Constructor & Destructor Documentation

ODFEDAQConfig::ODFEDAQConfig (  ) 

Definition at line 11 of file ODFEDAQConfig.cc.

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

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

ODFEDAQConfig::~ODFEDAQConfig (  ) 

Definition at line 33 of file ODFEDAQConfig.cc.

00034 {
00035 }


Member Function Documentation

void ODFEDAQConfig::clear ( void   )  [private]

Definition at line 23 of file ODFEDAQConfig.cc.

References m_com, m_del, m_ped, m_version, and m_wei.

Referenced by ODFEDAQConfig().

00023                          {
00024    m_del=0;
00025    m_wei=0;
00026    m_ped=0;
00027    m_version=0;
00028    m_com="";
00029 }

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

Definition at line 131 of file ODFEDAQConfig.cc.

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

00133 {
00134   this->checkConnection();
00135   result->clear();
00136   if(result->getId()==0 && (result->getConfigTag()=="") ){
00137     throw(runtime_error("ODFEDAQConfig::fetchData(): no Id defined for this ODFEDAQConfig "));
00138   }
00139 
00140   try {
00141 
00142     m_readStmt->setSQL("SELECT * FROM " + getTable() +   
00143                        " where ( config_id = :1 or (tag=:2 AND version=:3 ) )" );
00144     m_readStmt->setInt(1, result->getId());
00145     m_readStmt->setString(2, result->getConfigTag());
00146     m_readStmt->setInt(3, result->getVersion());
00147     ResultSet* rset = m_readStmt->executeQuery();
00148 
00149     rset->next();
00150 
00151     // 1 is the id and 2 is the config tag and 3 is the version
00152 
00153     result->setId(rset->getInt(1));
00154     result->setConfigTag(rset->getString(2));
00155     result->setVersion(rset->getInt(3));
00156 
00157     result->setPedestalId(       rset->getInt(4) );
00158     result->setDelayId(        rset->getInt(5) );
00159     result->setWeightId(         rset->getInt(6) );
00160     result->setComment(      rset->getString(7) );
00161 
00162   } catch (SQLException &e) {
00163     throw(runtime_error("ODFEDAQConfig::fetchData():  "+e.getMessage()));
00164   }
00165 }

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

Definition at line 167 of file ODFEDAQConfig.cc.

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

00168 {
00169   // Return from memory if available
00170   if (m_ID!=0) {
00171     return m_ID;
00172   }
00173 
00174   this->checkConnection();
00175 
00176   try {
00177     Statement* stmt = m_conn->createStatement();
00178     stmt->setSQL("SELECT config_id FROM "+ getTable()+
00179                  "WHERE  tag=:1 and version=:2 " );
00180 
00181     stmt->setString(1, getConfigTag() );
00182     stmt->setInt(2, getVersion() );
00183 
00184     ResultSet* rset = stmt->executeQuery();
00185 
00186     if (rset->next()) {
00187       m_ID = rset->getInt(1);
00188     } else {
00189       m_ID = 0;
00190     }
00191     m_conn->terminateStatement(stmt);
00192   } catch (SQLException &e) {
00193     throw(runtime_error("ODFEDAQConfig::fetchID:  "+e.getMessage()));
00194   }
00195 
00196   return m_ID;
00197 }

int ODFEDAQConfig::fetchNextId (  )  throw (std::runtime_error)

Definition at line 39 of file ODFEDAQConfig.cc.

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

Referenced by prepareWrite().

00039                                                         {
00040 
00041   int result=0;
00042   try {
00043     this->checkConnection();
00044 
00045     m_readStmt = m_conn->createStatement(); 
00046     m_readStmt->setSQL("select fe_daq_conDfig_sq.nextVal from dual");
00047     ResultSet* rset = m_readStmt->executeQuery();
00048     while (rset->next ()){
00049       result= rset->getInt(1);
00050     }
00051     m_conn->terminateStatement(m_readStmt);
00052     return result; 
00053 
00054   } catch (SQLException &e) {
00055     throw(runtime_error("ODFEDAQConfig::fetchNextId():  "+e.getMessage()));
00056   }
00057 
00058 }

std::string ODFEDAQConfig::getComment (  )  const [inline]

Definition at line 34 of file ODFEDAQConfig.h.

References m_com.

00034 { return m_com; }

int ODFEDAQConfig::getDelayId (  )  const [inline]

Definition at line 29 of file ODFEDAQConfig.h.

References m_del.

00029 { return m_del; }

int ODFEDAQConfig::getId (  )  const [inline]

Definition at line 19 of file ODFEDAQConfig.h.

References m_ID.

00019 { return m_ID; }

int ODFEDAQConfig::getPedestalId (  )  const [inline]

Definition at line 27 of file ODFEDAQConfig.h.

References m_ped.

00027 { return m_ped; }

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

Implements IODConfig.

Definition at line 16 of file ODFEDAQConfig.h.

Referenced by fetchData(), and fetchID().

00016 { return "FE_DAQ_CONFIG"; }

int ODFEDAQConfig::getVersion (  )  const [inline]

Definition at line 24 of file ODFEDAQConfig.h.

References m_version.

Referenced by fetchID().

00024 { return m_version; }

int ODFEDAQConfig::getWeightId (  )  const [inline]

Definition at line 31 of file ODFEDAQConfig.h.

References m_wei.

00031 { return m_wei; }

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

Implements IODConfig.

Definition at line 60 of file ODFEDAQConfig.cc.

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

00062 {
00063   this->checkConnection();
00064   int next_id=fetchNextId();
00065 
00066   try {
00067     m_writeStmt = m_conn->createStatement();
00068     m_writeStmt->setSQL("INSERT INTO FE_DAQ_CONFIG ( config_id, tag, version, ped_id, " 
00069                         " del_id, wei_id, user_comment ) "
00070                         "VALUES (  "
00071                         " :1, :2, :3, :4, :5, :6, :7 )" );
00072 
00073     m_writeStmt->setInt(1, next_id);
00074     m_ID=next_id;
00075 
00076   } catch (SQLException &e) {
00077     throw(runtime_error("ODFEDAQConfig::prepareWrite():  "+e.getMessage()));
00078   }
00079 
00080 }

void ODFEDAQConfig::setComment ( std::string  x  )  [inline]

Definition at line 33 of file ODFEDAQConfig.h.

References m_com.

Referenced by setParameters().

00033 { m_com = x; }

void ODFEDAQConfig::setDelayId ( int  x  )  [inline]

Definition at line 28 of file ODFEDAQConfig.h.

References m_del.

Referenced by setParameters().

00028 { m_del = x; }

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

Definition at line 18 of file ODFEDAQConfig.h.

References m_ID.

00018 { m_ID = id; }

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

Definition at line 82 of file ODFEDAQConfig.cc.

References setComment(), setDelayId(), setPedestalId(), setVersion(), and setWeightId().

00082                                                                   {
00083   
00084   // parses the result of the XML parser that is a map of 
00085   // string string with variable name variable value 
00086   
00087   for( std::map<std::string, std::string >::iterator ci=
00088          my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
00089     
00090     if(ci->first==  "VERSION") setVersion(atoi(ci->second.c_str()) );
00091     if(ci->first==  "PED_ID") setPedestalId(atoi(ci->second.c_str()) );
00092     if(ci->first==  "DEL_ID") setDelayId(atoi(ci->second.c_str()));
00093     if(ci->first==  "WEI_ID") setWeightId(atoi(ci->second.c_str()));
00094     if(ci->first==  "COMMENT" || ci->first==  "USER_COMMENT") setComment(ci->second);
00095     
00096   }
00097   
00098 }

void ODFEDAQConfig::setPedestalId ( int  x  )  [inline]

Definition at line 26 of file ODFEDAQConfig.h.

References m_ped.

Referenced by setParameters().

00026 { m_ped = x; }

void ODFEDAQConfig::setVersion ( int  id  )  [inline]

Definition at line 23 of file ODFEDAQConfig.h.

References m_version.

Referenced by setParameters().

00023 { m_version = id; }

void ODFEDAQConfig::setWeightId ( int  x  )  [inline]

Definition at line 30 of file ODFEDAQConfig.h.

References m_wei.

Referenced by setParameters().

00030 { m_wei = x; }

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

Definition at line 100 of file ODFEDAQConfig.cc.

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

00102 {
00103   this->checkConnection();
00104   this->checkPrepare();
00105 
00106   try {
00107 
00108     // number 1 is the id 
00109     m_writeStmt->setString(2, this->getConfigTag());
00110     m_writeStmt->setInt(3, this->getVersion());
00111     m_writeStmt->setInt(4, this->getPedestalId());
00112     m_writeStmt->setInt(5, this->getDelayId());
00113     m_writeStmt->setInt(6, this->getWeightId());
00114     m_writeStmt->setString(7, this->getComment());
00115 
00116     m_writeStmt->executeUpdate();
00117 
00118 
00119   } catch (SQLException &e) {
00120     throw(runtime_error("ODFEDAQConfig::writeDB():  "+e.getMessage()));
00121   }
00122   // Now get the ID
00123   if (!this->fetchID()) {
00124     throw(runtime_error("ODFEDAQConfig::writeDB:  Failed to write"));
00125   }
00126 
00127 
00128 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 11 of file ODFEDAQConfig.h.


Member Data Documentation

std::string ODFEDAQConfig::m_com [private]

Definition at line 57 of file ODFEDAQConfig.h.

Referenced by clear(), getComment(), and setComment().

int ODFEDAQConfig::m_del [private]

Definition at line 54 of file ODFEDAQConfig.h.

Referenced by clear(), getDelayId(), and setDelayId().

int ODFEDAQConfig::m_ID [private]

Definition at line 52 of file ODFEDAQConfig.h.

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

int ODFEDAQConfig::m_ped [private]

Definition at line 53 of file ODFEDAQConfig.h.

Referenced by clear(), getPedestalId(), and setPedestalId().

int ODFEDAQConfig::m_version [private]

Definition at line 56 of file ODFEDAQConfig.h.

Referenced by clear(), getVersion(), and setVersion().

int ODFEDAQConfig::m_wei [private]

Definition at line 55 of file ODFEDAQConfig.h.

Referenced by clear(), getWeightId(), and setWeightId().


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