CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODJBH4Config Class Reference

#include <ODJBH4Config.h>

Inheritance diagram for ODJBH4Config:
IODConfig IDBObject

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 () override
 
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 () override
 
- Public Member Functions inherited from IODConfig
std::string getConfigTag ()
 
void setConfigTag (std::string x)
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Private Member Functions

void clear ()
 
void fetchData (ODJBH4Config *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

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
 

Additional Inherited Members

- Public Types inherited from IODConfig
typedef oracle::occi::Clob Clob
 
typedef oracle::occi::SQLException SQLException
 
typedef oracle::occi::Statement Statement
 
typedef oracle::occi::Stream Stream
 
- Public Attributes inherited from IODConfig
std::string m_config_tag
 
- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IODConfig
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
unsigned char * readClob (Clob &clob, int size) noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IODConfig
Statementm_readStmt
 
Statementm_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 9 of file ODJBH4Config.h.

Constructor & Destructor Documentation

◆ ODJBH4Config()

ODJBH4Config::ODJBH4Config ( )

Definition at line 10 of file ODJBH4Config.cc.

References l1ct::clear().

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15  m_config_tag = "";
16  m_ID = 0;
17  clear();
18 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
std::string m_config_tag
Definition: IODConfig.h:25
Statement * m_readStmt
Definition: IODConfig.h:34

◆ ~ODJBH4Config()

ODJBH4Config::~ODJBH4Config ( )
override

Definition at line 20 of file ODJBH4Config.cc.

20 {}

Member Function Documentation

◆ clear()

void ODJBH4Config::clear ( void  )
private

Definition at line 22 of file ODJBH4Config.cc.

22  {
23  m_use_buffer = 0;
24  m_hal_mod_file = "";
25  m_hal_add_file = "";
26  m_hal_tab_file = "";
27  m_serial = "";
28  m_caen1 = "";
29  m_caen2 = 0;
30  m_caen3 = 0;
31 }
std::string m_hal_tab_file
Definition: ODJBH4Config.h:59
std::string m_serial
Definition: ODJBH4Config.h:60
std::string m_caen1
Definition: ODJBH4Config.h:61
std::string m_hal_mod_file
Definition: ODJBH4Config.h:57
std::string m_hal_add_file
Definition: ODJBH4Config.h:58

◆ fetchData()

void ODJBH4Config::fetchData ( ODJBH4Config result)
privatenoexcept

Definition at line 99 of file ODJBH4Config.cc.

References MillePedeFileConverter_cfg::e, and mps_fire::result.

99  {
100  this->checkConnection();
101  result->clear();
102  if (result->getId() == 0) {
103  throw(std::runtime_error("ODJBH4Config::fetchData(): no Id defined for this ODJBH4Config "));
104  }
105 
106  try {
107  m_readStmt->setSQL(
108  "SELECT * FROM ECAL_Jbh4_CONFIGURATION "
109  " where ( jbh4_configuration_id = :1 or jbh4_tag=:2 )");
110  m_readStmt->setInt(1, result->getId());
111  m_readStmt->setString(2, result->getConfigTag());
112  ResultSet *rset = m_readStmt->executeQuery();
113 
114  rset->next();
115 
116  result->setId(rset->getInt(1));
117  result->setConfigTag(rset->getString(2));
118 
119  result->setUseBuffer(rset->getInt(3));
120  result->setHalModuleFile(rset->getString(4));
121  result->setHalAddressTableFile(rset->getString(5));
122  result->setHalStaticTableFile(rset->getString(6));
123  result->setCbd8210SerialNumber(rset->getString(7));
124  result->setCaenBridgeType(rset->getString(8));
125  result->setCaenLinkNumber(rset->getInt(9));
126  result->setCaenBoardNumber(rset->getInt(10));
127 
128  } catch (SQLException &e) {
129  throw(std::runtime_error("ODJBH4Config::fetchData(): " + e.getMessage()));
130  }
131 }
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34

◆ fetchID()

int ODJBH4Config::fetchID ( )
privatenoexcept

Definition at line 133 of file ODJBH4Config.cc.

References MillePedeFileConverter_cfg::e.

133  {
134  // Return from memory if available
135  if (m_ID != 0) {
136  return m_ID;
137  }
138 
139  this->checkConnection();
140 
141  try {
142  Statement *stmt = m_conn->createStatement();
143  stmt->setSQL(
144  "SELECT jbh4_configuration_id FROM ecal_jbh4_configuration "
145  "WHERE jbh4_tag=:jbh4_tag ");
146 
147  stmt->setString(1, getConfigTag());
148 
149  ResultSet *rset = stmt->executeQuery();
150 
151  if (rset->next()) {
152  m_ID = rset->getInt(1);
153  } else {
154  m_ID = 0;
155  }
156  m_conn->terminateStatement(stmt);
157  } catch (SQLException &e) {
158  throw(std::runtime_error("ODJBH4Config::fetchID: " + e.getMessage()));
159  }
160 
161  return m_ID;
162 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30

◆ fetchNextId()

int ODJBH4Config::fetchNextId ( )
privatenoexcept

Definition at line 33 of file ODJBH4Config.cc.

References MillePedeFileConverter_cfg::e, and mps_fire::result.

33  {
34  int result = 0;
35  try {
36  this->checkConnection();
37 
38  m_readStmt = m_conn->createStatement();
39  m_readStmt->setSQL("select ecal_JBH4_config_sq.NextVal from dual");
40  ResultSet *rset = m_readStmt->executeQuery();
41  while (rset->next()) {
42  result = rset->getInt(1);
43  }
44  m_conn->terminateStatement(m_readStmt);
45  return result;
46 
47  } catch (SQLException &e) {
48  throw(std::runtime_error("ODJBH4Config::fetchNextId(): " + e.getMessage()));
49  }
50 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34

◆ getCaenBoardNumber()

int ODJBH4Config::getCaenBoardNumber ( ) const
inline

Definition at line 43 of file ODJBH4Config.h.

References m_caen3.

43 { return m_caen3; }

◆ getCaenBridgeType()

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

Definition at line 37 of file ODJBH4Config.h.

References m_caen1.

37 { return m_caen1; }
std::string m_caen1
Definition: ODJBH4Config.h:61

◆ getCaenLinkNumber()

int ODJBH4Config::getCaenLinkNumber ( ) const
inline

Definition at line 40 of file ODJBH4Config.h.

References m_caen2.

40 { return m_caen2; }

◆ getCbd8210SerialNumber()

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

Definition at line 34 of file ODJBH4Config.h.

References m_serial.

34 { return m_serial; }
std::string m_serial
Definition: ODJBH4Config.h:60

◆ getHalAddressTableFile()

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

Definition at line 28 of file ODJBH4Config.h.

References m_hal_add_file.

28 { return m_hal_add_file; }
std::string m_hal_add_file
Definition: ODJBH4Config.h:58

◆ getHalModuleFile()

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

Definition at line 25 of file ODJBH4Config.h.

References m_hal_mod_file.

25 { return m_hal_mod_file; }
std::string m_hal_mod_file
Definition: ODJBH4Config.h:57

◆ getHalStaticTableFile()

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

Definition at line 31 of file ODJBH4Config.h.

References m_hal_tab_file.

31 { return m_hal_tab_file; }
std::string m_hal_tab_file
Definition: ODJBH4Config.h:59

◆ getId()

int ODJBH4Config::getId ( void  ) const
inline

Definition at line 19 of file ODJBH4Config.h.

References m_ID.

19 { return m_ID; }

◆ getTable()

std::string ODJBH4Config::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 16 of file ODJBH4Config.h.

16 { return "ECAL_JBH4_CONFIGURATION"; }

◆ getUseBuffer()

int ODJBH4Config::getUseBuffer ( ) const
inline

Definition at line 22 of file ODJBH4Config.h.

References m_use_buffer.

22 { return m_use_buffer; }

◆ prepareWrite()

void ODJBH4Config::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 52 of file ODJBH4Config.cc.

References MillePedeFileConverter_cfg::e.

52  {
53  this->checkConnection();
54  int next_id = fetchNextId();
55 
56  try {
57  m_writeStmt = m_conn->createStatement();
58  m_writeStmt->setSQL(
59  "INSERT INTO ECAL_Jbh4_CONFIGURATION ( jbh4_configuration_id, jbh4_tag, "
60  " useBuffer, halModuleFile, halAddressTableFile, halStaticTableFile, halcbd8210serialnumber, "
61  " caenbridgetype, caenlinknumber, caenboardnumber) "
62  " VALUES ( :1, :2, :3, :4, :5, :6, :7, :8 , :9, :10 )");
63 
64  m_writeStmt->setInt(1, next_id);
65  m_ID = next_id;
66  } catch (SQLException &e) {
67  throw(std::runtime_error("ODJBH4Config::prepareWrite(): " + e.getMessage()));
68  }
69 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchNextId() noexcept(false)
Definition: ODJBH4Config.cc:33
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

◆ setCaenBoardNumber()

void ODJBH4Config::setCaenBoardNumber ( int  x)
inline

Definition at line 42 of file ODJBH4Config.h.

References m_caen3, and x.

42 { m_caen3 = x; }

◆ setCaenBridgeType()

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

Definition at line 36 of file ODJBH4Config.h.

References m_caen1, and x.

36 { m_caen1 = x; }
std::string m_caen1
Definition: ODJBH4Config.h:61

◆ setCaenLinkNumber()

void ODJBH4Config::setCaenLinkNumber ( int  x)
inline

Definition at line 39 of file ODJBH4Config.h.

References m_caen2, and x.

39 { m_caen2 = x; }

◆ setCbd8210SerialNumber()

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

Definition at line 33 of file ODJBH4Config.h.

References m_serial, and x.

33 { m_serial = x; }
std::string m_serial
Definition: ODJBH4Config.h:60

◆ setHalAddressTableFile()

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

Definition at line 27 of file ODJBH4Config.h.

References m_hal_add_file, and x.

27 { m_hal_add_file = x; }
std::string m_hal_add_file
Definition: ODJBH4Config.h:58

◆ setHalModuleFile()

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

Definition at line 24 of file ODJBH4Config.h.

References m_hal_mod_file, and x.

24 { m_hal_mod_file = x; }
std::string m_hal_mod_file
Definition: ODJBH4Config.h:57

◆ setHalStaticTableFile()

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

Definition at line 30 of file ODJBH4Config.h.

References m_hal_tab_file, and x.

30 { m_hal_tab_file = x; }
std::string m_hal_tab_file
Definition: ODJBH4Config.h:59

◆ setId()

void ODJBH4Config::setId ( int  id)
inline

◆ setUseBuffer()

void ODJBH4Config::setUseBuffer ( int  x)
inline

Definition at line 21 of file ODJBH4Config.h.

References m_use_buffer, and x.

◆ writeDB()

void ODJBH4Config::writeDB ( )
privatenoexcept

Definition at line 71 of file ODJBH4Config.cc.

References MillePedeFileConverter_cfg::e.

71  {
72  this->checkConnection();
73  this->checkPrepare();
74 
75  try {
76  // number 1 is the id number 2 is the tag
77  m_writeStmt->setString(2, this->getConfigTag());
78 
79  m_writeStmt->setInt(3, this->getUseBuffer());
80  m_writeStmt->setString(4, this->getHalModuleFile());
81  m_writeStmt->setString(5, this->getHalAddressTableFile());
82  m_writeStmt->setString(6, this->getHalStaticTableFile());
83  m_writeStmt->setString(7, this->getCbd8210SerialNumber());
84  m_writeStmt->setString(8, this->getCaenBridgeType());
85  m_writeStmt->setInt(9, this->getCaenLinkNumber());
86  m_writeStmt->setInt(10, this->getCaenBoardNumber());
87 
88  m_writeStmt->executeUpdate();
89 
90  } catch (SQLException &e) {
91  throw(std::runtime_error("ODJBH4Config::writeDB(): " + e.getMessage()));
92  }
93  // Now get the ID
94  if (!this->fetchID()) {
95  throw(std::runtime_error("ODJBH4Config::writeDB: Failed to write"));
96  }
97 }
std::string getCaenBridgeType() const
Definition: ODJBH4Config.h:37
int fetchID() noexcept(false)
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getHalModuleFile() const
Definition: ODJBH4Config.h:25
int getCaenBoardNumber() const
Definition: ODJBH4Config.h:43
int getCaenLinkNumber() const
Definition: ODJBH4Config.h:40
int getUseBuffer() const
Definition: ODJBH4Config.h:22
std::string getHalStaticTableFile() const
Definition: ODJBH4Config.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getHalAddressTableFile() const
Definition: ODJBH4Config.h:28
std::string getCbd8210SerialNumber() const
Definition: ODJBH4Config.h:34
std::string getConfigTag()
Definition: IODConfig.h:30
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODJBH4Config.h.

Member Data Documentation

◆ m_caen1

std::string ODJBH4Config::m_caen1
private

Definition at line 61 of file ODJBH4Config.h.

Referenced by getCaenBridgeType(), and setCaenBridgeType().

◆ m_caen2

int ODJBH4Config::m_caen2
private

Definition at line 62 of file ODJBH4Config.h.

Referenced by getCaenLinkNumber(), and setCaenLinkNumber().

◆ m_caen3

int ODJBH4Config::m_caen3
private

Definition at line 63 of file ODJBH4Config.h.

Referenced by getCaenBoardNumber(), and setCaenBoardNumber().

◆ m_hal_add_file

std::string ODJBH4Config::m_hal_add_file
private

Definition at line 58 of file ODJBH4Config.h.

Referenced by getHalAddressTableFile(), and setHalAddressTableFile().

◆ m_hal_mod_file

std::string ODJBH4Config::m_hal_mod_file
private

Definition at line 57 of file ODJBH4Config.h.

Referenced by getHalModuleFile(), and setHalModuleFile().

◆ m_hal_tab_file

std::string ODJBH4Config::m_hal_tab_file
private

Definition at line 59 of file ODJBH4Config.h.

Referenced by getHalStaticTableFile(), and setHalStaticTableFile().

◆ m_ID

int ODJBH4Config::m_ID
private

Definition at line 54 of file ODJBH4Config.h.

Referenced by getId(), and setId().

◆ m_serial

std::string ODJBH4Config::m_serial
private

Definition at line 60 of file ODJBH4Config.h.

Referenced by getCbd8210SerialNumber(), and setCbd8210SerialNumber().

◆ m_use_buffer

int ODJBH4Config::m_use_buffer
private

Definition at line 56 of file ODJBH4Config.h.

Referenced by getUseBuffer(), and setUseBuffer().