CMS 3D CMS Logo

ODJBH4Config Class Reference

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

Inheritance diagram for ODJBH4Config:

IODConfig IDBObject

List of all members.

Public Member Functions

int getCaenBoardNumber () const
std::string getCaenBridgeType () const
int getCaenLinkNumber () const
std::string getCbd8210SerialNumber () const
std::string getHalAddressTableFile () const
std::string getHalModuleFile () const
std::string getHalStaticTableFile () const
int getId () const
std::string getTable ()
int getUseBuffer () const
 ODJBH4Config ()
void setCaenBoardNumber (int x)
void setCaenBridgeType (std::string x)
void setCaenLinkNumber (int x)
void setCbd8210SerialNumber (std::string x)
void setHalAddressTableFile (std::string x)
void setHalModuleFile (std::string x)
void setHalStaticTableFile (std::string x)
void setId (int id)
void setUseBuffer (int x)
 ~ODJBH4Config ()

Private Member Functions

void clear ()
void fetchData (ODJBH4Config *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

std::string m_caen1
int m_caen2
int m_caen3
std::string m_hal_add_file
std::string m_hal_mod_file
std::string m_hal_tab_file
int m_ID
std::string m_serial
int m_use_buffer

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 9 of file ODJBH4Config.h.


Constructor & Destructor Documentation

ODJBH4Config::ODJBH4Config (  ) 

Definition at line 10 of file ODJBH4Config.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 }

ODJBH4Config::~ODJBH4Config (  ) 

Definition at line 23 of file ODJBH4Config.cc.

00024 {
00025 }


Member Function Documentation

void ODJBH4Config::clear ( void   )  [private]

Definition at line 27 of file ODJBH4Config.cc.

References m_caen1, m_caen2, m_caen3, m_hal_add_file, m_hal_mod_file, m_hal_tab_file, m_serial, and m_use_buffer.

Referenced by ODJBH4Config().

00027                         {
00028 
00029   m_use_buffer=0;
00030   m_hal_mod_file="";
00031   m_hal_add_file="";
00032   m_hal_tab_file="";
00033   m_serial="";
00034   m_caen1="";
00035   m_caen2=0;
00036   m_caen3=0;
00037 
00038 }

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

Definition at line 118 of file ODJBH4Config.cc.

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

00120 {
00121   this->checkConnection();
00122   result->clear();
00123   if(result->getId()==0){
00124     throw(runtime_error("ODJBH4Config::fetchData(): no Id defined for this ODJBH4Config "));
00125   }
00126 
00127   try {
00128 
00129     m_readStmt->setSQL("SELECT * FROM ECAL_Jbh4_CONFIGURATION  "
00130                        " where ( jbh4_configuration_id = :1 or jbh4_tag=:2 )");
00131     m_readStmt->setInt(1, result->getId());
00132     m_readStmt->setString(2, result->getConfigTag());
00133     ResultSet* rset = m_readStmt->executeQuery();
00134 
00135     rset->next();
00136 
00137     result->setId(rset->getInt(1));
00138     result->setConfigTag(rset->getString(2));
00139 
00140     result->setUseBuffer(           rset->getInt(3) );
00141     result->setHalModuleFile(        rset->getString(4) );
00142     result->setHalAddressTableFile(         rset->getString(5) );
00143     result->setHalStaticTableFile(    rset->getString(6) );
00144     result->setCbd8210SerialNumber(        rset->getString(7) );
00145     result->setCaenBridgeType(           rset->getString(8) );
00146     result->setCaenLinkNumber(            rset->getInt(9) );
00147     result->setCaenBoardNumber(              rset->getInt(10) );
00148 
00149   } catch (SQLException &e) {
00150     throw(runtime_error("ODJBH4Config::fetchData():  "+e.getMessage()));
00151   }
00152 }

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

Definition at line 154 of file ODJBH4Config.cc.

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

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

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

Definition at line 41 of file ODJBH4Config.cc.

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

Referenced by prepareWrite().

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

int ODJBH4Config::getCaenBoardNumber (  )  const [inline]

Definition at line 45 of file ODJBH4Config.h.

References m_caen3.

00045 { return m_caen3 ; }

std::string ODJBH4Config::getCaenBridgeType (  )  const [inline]

Definition at line 39 of file ODJBH4Config.h.

References m_caen1.

00039 { return m_caen1; }

int ODJBH4Config::getCaenLinkNumber (  )  const [inline]

Definition at line 42 of file ODJBH4Config.h.

References m_caen2.

00042 { return m_caen2; }

std::string ODJBH4Config::getCbd8210SerialNumber (  )  const [inline]

Definition at line 36 of file ODJBH4Config.h.

References m_serial.

00036 { return m_serial; }

std::string ODJBH4Config::getHalAddressTableFile (  )  const [inline]

Definition at line 29 of file ODJBH4Config.h.

References m_hal_add_file.

00029 { return m_hal_add_file; }

std::string ODJBH4Config::getHalModuleFile (  )  const [inline]

Definition at line 26 of file ODJBH4Config.h.

References m_hal_mod_file.

00026 { return m_hal_mod_file; }

std::string ODJBH4Config::getHalStaticTableFile (  )  const [inline]

Definition at line 32 of file ODJBH4Config.h.

References m_hal_tab_file.

00032 { return m_hal_tab_file; }

int ODJBH4Config::getId (  )  const [inline]

Definition at line 19 of file ODJBH4Config.h.

References m_ID.

00019 { return m_ID; }

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

Implements IODConfig.

Definition at line 16 of file ODJBH4Config.h.

00016 { return "ECAL_JBH4_CONFIGURATION"; }

int ODJBH4Config::getUseBuffer (  )  const [inline]

Definition at line 23 of file ODJBH4Config.h.

References m_use_buffer.

00023 { return m_use_buffer; }

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

Implements IODConfig.

Definition at line 62 of file ODJBH4Config.cc.

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

00064 {
00065   this->checkConnection();
00066   int next_id=fetchNextId();
00067 
00068   try {
00069     m_writeStmt = m_conn->createStatement();
00070     m_writeStmt->setSQL("INSERT INTO ECAL_Jbh4_CONFIGURATION ( jbh4_configuration_id, jbh4_tag, "
00071                         " useBuffer, halModuleFile, halAddressTableFile, halStaticTableFile, halcbd8210serialnumber, "
00072                         " caenbridgetype, caenlinknumber, caenboardnumber) "
00073                         " VALUES ( :1, :2, :3, :4, :5, :6, :7, :8 , :9, :10 )");
00074 
00075     m_writeStmt->setInt(1, next_id);
00076     m_ID=next_id;
00077   } catch (SQLException &e) {
00078     throw(runtime_error("ODJBH4Config::prepareWrite():  "+e.getMessage()));
00079   }
00080 }

void ODJBH4Config::setCaenBoardNumber ( int  x  )  [inline]

Definition at line 44 of file ODJBH4Config.h.

References m_caen3.

00044 { m_caen3 = x ; }

void ODJBH4Config::setCaenBridgeType ( std::string  x  )  [inline]

Definition at line 38 of file ODJBH4Config.h.

References m_caen1.

00038 { m_caen1 = x; }

void ODJBH4Config::setCaenLinkNumber ( int  x  )  [inline]

Definition at line 41 of file ODJBH4Config.h.

References m_caen2.

00041 { m_caen2 = x; }

void ODJBH4Config::setCbd8210SerialNumber ( std::string  x  )  [inline]

Definition at line 35 of file ODJBH4Config.h.

References m_serial.

00035 { m_serial = x; }

void ODJBH4Config::setHalAddressTableFile ( std::string  x  )  [inline]

Definition at line 28 of file ODJBH4Config.h.

References m_hal_add_file.

00028 { m_hal_add_file = x; }

void ODJBH4Config::setHalModuleFile ( std::string  x  )  [inline]

Definition at line 25 of file ODJBH4Config.h.

References m_hal_mod_file.

00025 { m_hal_mod_file = x; }

void ODJBH4Config::setHalStaticTableFile ( std::string  x  )  [inline]

Definition at line 31 of file ODJBH4Config.h.

References m_hal_tab_file.

00031 { m_hal_tab_file = x; }

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

Definition at line 18 of file ODJBH4Config.h.

References m_ID.

00018 { m_ID = id; }

void ODJBH4Config::setUseBuffer ( int  x  )  [inline]

Definition at line 22 of file ODJBH4Config.h.

References m_use_buffer.

00022 { m_use_buffer = x; }

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

Definition at line 84 of file ODJBH4Config.cc.

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

00086 {
00087   this->checkConnection();
00088   this->checkPrepare();
00089 
00090   try {
00091 
00092     // number 1 is the id number 2 is the tag
00093     m_writeStmt->setString(2, this->getConfigTag());
00094 
00095     m_writeStmt->setInt(3, this->getUseBuffer());
00096     m_writeStmt->setString(4,  this->getHalModuleFile() );
00097     m_writeStmt->setString(5, this->getHalAddressTableFile() );
00098     m_writeStmt->setString(6, this->getHalStaticTableFile() );
00099     m_writeStmt->setString(7, this->getCbd8210SerialNumber() );
00100     m_writeStmt->setString(8, this->getCaenBridgeType() );
00101     m_writeStmt->setInt(9, this->getCaenLinkNumber() );
00102     m_writeStmt->setInt(10, this->getCaenBoardNumber() );
00103  
00104     m_writeStmt->executeUpdate();
00105 
00106 
00107   } catch (SQLException &e) {
00108     throw(runtime_error("ODJBH4Config::writeDB():  "+e.getMessage()));
00109   }
00110   // Now get the ID
00111   if (!this->fetchID()) {
00112     throw(runtime_error("ODJBH4Config::writeDB:  Failed to write"));
00113   }
00114 
00115 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 11 of file ODJBH4Config.h.


Member Data Documentation

std::string ODJBH4Config::m_caen1 [private]

Definition at line 65 of file ODJBH4Config.h.

Referenced by clear(), getCaenBridgeType(), and setCaenBridgeType().

int ODJBH4Config::m_caen2 [private]

Definition at line 66 of file ODJBH4Config.h.

Referenced by clear(), getCaenLinkNumber(), and setCaenLinkNumber().

int ODJBH4Config::m_caen3 [private]

Definition at line 67 of file ODJBH4Config.h.

Referenced by clear(), getCaenBoardNumber(), and setCaenBoardNumber().

std::string ODJBH4Config::m_hal_add_file [private]

Definition at line 62 of file ODJBH4Config.h.

Referenced by clear(), getHalAddressTableFile(), and setHalAddressTableFile().

std::string ODJBH4Config::m_hal_mod_file [private]

Definition at line 61 of file ODJBH4Config.h.

Referenced by clear(), getHalModuleFile(), and setHalModuleFile().

std::string ODJBH4Config::m_hal_tab_file [private]

Definition at line 63 of file ODJBH4Config.h.

Referenced by clear(), getHalStaticTableFile(), and setHalStaticTableFile().

int ODJBH4Config::m_ID [private]

Definition at line 58 of file ODJBH4Config.h.

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

std::string ODJBH4Config::m_serial [private]

Definition at line 64 of file ODJBH4Config.h.

Referenced by clear(), getCbd8210SerialNumber(), and setCbd8210SerialNumber().

int ODJBH4Config::m_use_buffer [private]

Definition at line 60 of file ODJBH4Config.h.

Referenced by clear(), getUseBuffer(), and setUseBuffer().


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