test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
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 ()
 
- 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) 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
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) throw (std::runtime_error)
 
unsigned char * readClob (Clob &clob, int size) throw (std::runtime_error)
 
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
 
void terminateReadStatement () throw (std::runtime_error)
 
void terminateWriteStatement () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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 ( )

Definition at line 10 of file ODJBH4Config.cc.

References hitfit::clear(), and NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
16  m_config_tag="";
17  m_ID=0;
18  clear();
19 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
ODJBH4Config::~ODJBH4Config ( )

Definition at line 23 of file ODJBH4Config.cc.

24 {
25 }

Member Function Documentation

void ODJBH4Config::clear ( void  )
private

Definition at line 27 of file ODJBH4Config.cc.

27  {
28 
29  m_use_buffer=0;
30  m_hal_mod_file="";
31  m_hal_add_file="";
32  m_hal_tab_file="";
33  m_serial="";
34  m_caen1="";
35  m_caen2=0;
36  m_caen3=0;
37 
38 }
std::string m_hal_tab_file
Definition: ODJBH4Config.h:63
std::string m_serial
Definition: ODJBH4Config.h:64
std::string m_caen1
Definition: ODJBH4Config.h:65
std::string m_hal_mod_file
Definition: ODJBH4Config.h:61
std::string m_hal_add_file
Definition: ODJBH4Config.h:62
void ODJBH4Config::fetchData ( ODJBH4Config result)
throw (std::runtime_error
)
private

Definition at line 118 of file ODJBH4Config.cc.

References alignCSCRings::e, and query::result.

120 {
121  this->checkConnection();
122  result->clear();
123  if(result->getId()==0){
124  throw(std::runtime_error("ODJBH4Config::fetchData(): no Id defined for this ODJBH4Config "));
125  }
126 
127  try {
128 
129  m_readStmt->setSQL("SELECT * FROM ECAL_Jbh4_CONFIGURATION "
130  " where ( jbh4_configuration_id = :1 or jbh4_tag=:2 )");
131  m_readStmt->setInt(1, result->getId());
132  m_readStmt->setString(2, result->getConfigTag());
133  ResultSet* rset = m_readStmt->executeQuery();
134 
135  rset->next();
136 
137  result->setId(rset->getInt(1));
138  result->setConfigTag(rset->getString(2));
139 
140  result->setUseBuffer( rset->getInt(3) );
141  result->setHalModuleFile( rset->getString(4) );
142  result->setHalAddressTableFile( rset->getString(5) );
143  result->setHalStaticTableFile( rset->getString(6) );
144  result->setCbd8210SerialNumber( rset->getString(7) );
145  result->setCaenBridgeType( rset->getString(8) );
146  result->setCaenLinkNumber( rset->getInt(9) );
147  result->setCaenBoardNumber( rset->getInt(10) );
148 
149  } catch (SQLException &e) {
150  throw(std::runtime_error("ODJBH4Config::fetchData(): "+e.getMessage()));
151  }
152 }
int getId() const
Definition: ODJBH4Config.h:19
void setHalModuleFile(std::string x)
Definition: ODJBH4Config.h:25
void setUseBuffer(int x)
Definition: ODJBH4Config.h:22
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setCaenBoardNumber(int x)
Definition: ODJBH4Config.h:44
void setId(int id)
Definition: ODJBH4Config.h:18
void setCaenLinkNumber(int x)
Definition: ODJBH4Config.h:41
void setCbd8210SerialNumber(std::string x)
Definition: ODJBH4Config.h:35
void setHalStaticTableFile(std::string x)
Definition: ODJBH4Config.h:31
void setCaenBridgeType(std::string x)
Definition: ODJBH4Config.h:38
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConfigTag(std::string x)
Definition: IODConfig.h:31
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
void setHalAddressTableFile(std::string x)
Definition: ODJBH4Config.h:28
int ODJBH4Config::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 154 of file ODJBH4Config.cc.

References alignCSCRings::e.

155 {
156  // Return from memory if available
157  if (m_ID!=0) {
158  return m_ID;
159  }
160 
161  this->checkConnection();
162 
163  try {
164  Statement* stmt = m_conn->createStatement();
165  stmt->setSQL("SELECT jbh4_configuration_id FROM ecal_jbh4_configuration "
166  "WHERE jbh4_tag=:jbh4_tag ");
167 
168 
169  stmt->setString(1, getConfigTag());
170 
171  ResultSet* rset = stmt->executeQuery();
172 
173  if (rset->next()) {
174  m_ID = rset->getInt(1);
175  } else {
176  m_ID = 0;
177  }
178  m_conn->terminateStatement(stmt);
179  } catch (SQLException &e) {
180  throw(std::runtime_error("ODJBH4Config::fetchID: "+e.getMessage()));
181  }
182 
183  return m_ID;
184 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
int ODJBH4Config::fetchNextId ( )
throw (std::runtime_error
)
private

Definition at line 41 of file ODJBH4Config.cc.

References alignCSCRings::e, and query::result.

41  {
42 
43  int result=0;
44  try {
45  this->checkConnection();
46 
47  m_readStmt = m_conn->createStatement();
48  m_readStmt->setSQL("select ecal_JBH4_config_sq.NextVal from dual");
49  ResultSet* rset = m_readStmt->executeQuery();
50  while (rset->next ()){
51  result= rset->getInt(1);
52  }
53  m_conn->terminateStatement(m_readStmt);
54  return result;
55 
56  } catch (SQLException &e) {
57  throw(std::runtime_error("ODJBH4Config::fetchNextId(): "+e.getMessage()));
58  }
59 
60 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple result
Definition: query.py:137
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
int ODJBH4Config::getCaenBoardNumber ( ) const
inline

Definition at line 45 of file ODJBH4Config.h.

References m_caen3.

45 { return m_caen3 ; }
std::string ODJBH4Config::getCaenBridgeType ( ) const
inline

Definition at line 39 of file ODJBH4Config.h.

References m_caen1.

39 { return m_caen1; }
std::string m_caen1
Definition: ODJBH4Config.h:65
int ODJBH4Config::getCaenLinkNumber ( ) const
inline

Definition at line 42 of file ODJBH4Config.h.

References m_caen2.

42 { return m_caen2; }
std::string ODJBH4Config::getCbd8210SerialNumber ( ) const
inline

Definition at line 36 of file ODJBH4Config.h.

References m_serial.

36 { return m_serial; }
std::string m_serial
Definition: ODJBH4Config.h:64
std::string ODJBH4Config::getHalAddressTableFile ( ) const
inline

Definition at line 29 of file ODJBH4Config.h.

References m_hal_add_file.

29 { return m_hal_add_file; }
std::string m_hal_add_file
Definition: ODJBH4Config.h:62
std::string ODJBH4Config::getHalModuleFile ( ) const
inline

Definition at line 26 of file ODJBH4Config.h.

References m_hal_mod_file.

26 { return m_hal_mod_file; }
std::string m_hal_mod_file
Definition: ODJBH4Config.h:61
std::string ODJBH4Config::getHalStaticTableFile ( ) const
inline

Definition at line 32 of file ODJBH4Config.h.

References m_hal_tab_file.

32 { return m_hal_tab_file; }
std::string m_hal_tab_file
Definition: ODJBH4Config.h:63
int ODJBH4Config::getId ( ) const
inline

Definition at line 19 of file ODJBH4Config.h.

References m_ID.

19 { return m_ID; }
std::string ODJBH4Config::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 16 of file ODJBH4Config.h.

16 { return "ECAL_JBH4_CONFIGURATION"; }
int ODJBH4Config::getUseBuffer ( ) const
inline

Definition at line 23 of file ODJBH4Config.h.

References m_use_buffer.

23 { return m_use_buffer; }
void ODJBH4Config::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 62 of file ODJBH4Config.cc.

References alignCSCRings::e.

64 {
65  this->checkConnection();
66  int next_id=fetchNextId();
67 
68  try {
69  m_writeStmt = m_conn->createStatement();
70  m_writeStmt->setSQL("INSERT INTO ECAL_Jbh4_CONFIGURATION ( jbh4_configuration_id, jbh4_tag, "
71  " useBuffer, halModuleFile, halAddressTableFile, halStaticTableFile, halcbd8210serialnumber, "
72  " caenbridgetype, caenlinknumber, caenboardnumber) "
73  " VALUES ( :1, :2, :3, :4, :5, :6, :7, :8 , :9, :10 )");
74 
75  m_writeStmt->setInt(1, next_id);
76  m_ID=next_id;
77  } catch (SQLException &e) {
78  throw(std::runtime_error("ODJBH4Config::prepareWrite(): "+e.getMessage()));
79  }
80 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
int fetchNextId()
Definition: ODJBH4Config.cc:41
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkConnection() const
Definition: IDBObject.h:41
void ODJBH4Config::setCaenBoardNumber ( int  x)
inline

Definition at line 44 of file ODJBH4Config.h.

References m_caen3, and x.

44 { m_caen3 = x ; }
Definition: DDAxes.h:10
void ODJBH4Config::setCaenBridgeType ( std::string  x)
inline

Definition at line 38 of file ODJBH4Config.h.

References m_caen1, and x.

38 { m_caen1 = x; }
std::string m_caen1
Definition: ODJBH4Config.h:65
Definition: DDAxes.h:10
void ODJBH4Config::setCaenLinkNumber ( int  x)
inline

Definition at line 41 of file ODJBH4Config.h.

References m_caen2, and x.

41 { m_caen2 = x; }
Definition: DDAxes.h:10
void ODJBH4Config::setCbd8210SerialNumber ( std::string  x)
inline

Definition at line 35 of file ODJBH4Config.h.

References m_serial, and x.

35 { m_serial = x; }
std::string m_serial
Definition: ODJBH4Config.h:64
Definition: DDAxes.h:10
void ODJBH4Config::setHalAddressTableFile ( std::string  x)
inline

Definition at line 28 of file ODJBH4Config.h.

References m_hal_add_file, and x.

28 { m_hal_add_file = x; }
Definition: DDAxes.h:10
std::string m_hal_add_file
Definition: ODJBH4Config.h:62
void ODJBH4Config::setHalModuleFile ( std::string  x)
inline

Definition at line 25 of file ODJBH4Config.h.

References m_hal_mod_file, and x.

25 { m_hal_mod_file = x; }
std::string m_hal_mod_file
Definition: ODJBH4Config.h:61
Definition: DDAxes.h:10
void ODJBH4Config::setHalStaticTableFile ( std::string  x)
inline

Definition at line 31 of file ODJBH4Config.h.

References m_hal_tab_file, and x.

31 { m_hal_tab_file = x; }
std::string m_hal_tab_file
Definition: ODJBH4Config.h:63
Definition: DDAxes.h:10
void ODJBH4Config::setId ( int  id)
inline

Definition at line 18 of file ODJBH4Config.h.

References m_ID.

18 { m_ID = id; }
void ODJBH4Config::setUseBuffer ( int  x)
inline

Definition at line 22 of file ODJBH4Config.h.

References m_use_buffer, and x.

22 { m_use_buffer = x; }
Definition: DDAxes.h:10
void ODJBH4Config::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 84 of file ODJBH4Config.cc.

References alignCSCRings::e.

86 {
87  this->checkConnection();
88  this->checkPrepare();
89 
90  try {
91 
92  // number 1 is the id number 2 is the tag
93  m_writeStmt->setString(2, this->getConfigTag());
94 
95  m_writeStmt->setInt(3, this->getUseBuffer());
96  m_writeStmt->setString(4, this->getHalModuleFile() );
97  m_writeStmt->setString(5, this->getHalAddressTableFile() );
98  m_writeStmt->setString(6, this->getHalStaticTableFile() );
99  m_writeStmt->setString(7, this->getCbd8210SerialNumber() );
100  m_writeStmt->setString(8, this->getCaenBridgeType() );
101  m_writeStmt->setInt(9, this->getCaenLinkNumber() );
102  m_writeStmt->setInt(10, this->getCaenBoardNumber() );
103 
104  m_writeStmt->executeUpdate();
105 
106 
107  } catch (SQLException &e) {
108  throw(std::runtime_error("ODJBH4Config::writeDB(): "+e.getMessage()));
109  }
110  // Now get the ID
111  if (!this->fetchID()) {
112  throw(std::runtime_error("ODJBH4Config::writeDB: Failed to write"));
113  }
114 
115 }
std::string getHalModuleFile() const
Definition: ODJBH4Config.h:26
Statement * m_writeStmt
Definition: IODConfig.h:36
std::string getCbd8210SerialNumber() const
Definition: ODJBH4Config.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string getCaenBridgeType() const
Definition: ODJBH4Config.h:39
int getCaenLinkNumber() const
Definition: ODJBH4Config.h:42
void checkPrepare()
Definition: IODConfig.h:39
int getUseBuffer() const
Definition: ODJBH4Config.h:23
std::string getHalAddressTableFile() const
Definition: ODJBH4Config.h:29
int getCaenBoardNumber() const
Definition: ODJBH4Config.h:45
std::string getConfigTag()
Definition: IODConfig.h:32
std::string getHalStaticTableFile() const
Definition: ODJBH4Config.h:32
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

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 getCaenBridgeType(), and setCaenBridgeType().

int ODJBH4Config::m_caen2
private

Definition at line 66 of file ODJBH4Config.h.

Referenced by getCaenLinkNumber(), and setCaenLinkNumber().

int ODJBH4Config::m_caen3
private

Definition at line 67 of file ODJBH4Config.h.

Referenced by getCaenBoardNumber(), and setCaenBoardNumber().

std::string ODJBH4Config::m_hal_add_file
private

Definition at line 62 of file ODJBH4Config.h.

Referenced by getHalAddressTableFile(), and setHalAddressTableFile().

std::string ODJBH4Config::m_hal_mod_file
private

Definition at line 61 of file ODJBH4Config.h.

Referenced by getHalModuleFile(), and setHalModuleFile().

std::string ODJBH4Config::m_hal_tab_file
private

Definition at line 63 of file ODJBH4Config.h.

Referenced by getHalStaticTableFile(), and setHalStaticTableFile().

int ODJBH4Config::m_ID
private

Definition at line 58 of file ODJBH4Config.h.

Referenced by getId(), and setId().

std::string ODJBH4Config::m_serial
private

Definition at line 64 of file ODJBH4Config.h.

Referenced by getCbd8210SerialNumber(), and setCbd8210SerialNumber().

int ODJBH4Config::m_use_buffer
private

Definition at line 60 of file ODJBH4Config.h.

Referenced by getUseBuffer(), and setUseBuffer().