CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODScanConfig Class Reference

#include <ODScanConfig.h>

Inheritance diagram for ODScanConfig:
IODConfig IDBObject

Public Member Functions

int getFromVal () const
 
int getId () const
 
std::string getScanType () const
 
int getStep () const
 
std::string getTable () override
 
int getToVal () const
 
int getTypeId () const
 
 ODScanConfig ()
 
void setFromVal (int x)
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setScanType (std::string x)
 
void setStep (int x)
 
void setToVal (int x)
 
void setTypeId (int x)
 
 ~ODScanConfig () 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 (ODScanConfig *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

int m_from_val
 
int m_ID
 
int m_step
 
int m_to_val
 
std::string m_type
 
int m_type_id
 

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 ODScanConfig.h.

Constructor & Destructor Documentation

ODScanConfig::ODScanConfig ( )

Definition at line 11 of file ODScanConfig.cc.

References clear().

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16  m_config_tag = "";
17  m_ID = 0;
18  clear();
19 }
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
ODScanConfig::~ODScanConfig ( )
override

Definition at line 21 of file ODScanConfig.cc.

21 {}

Member Function Documentation

void ODScanConfig::clear ( void  )
private

Definition at line 23 of file ODScanConfig.cc.

23  {
24  m_type_id = 0;
25  m_type = "";
26  m_from_val = 0;
27  m_to_val = 0;
28  m_step = 0;
29 }
std::string m_type
Definition: ODScanConfig.h:49
void ODScanConfig::fetchData ( ODScanConfig result)
privatenoexcept

Definition at line 113 of file ODScanConfig.cc.

References alignCSCRings::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

113  {
114  this->checkConnection();
115  result->clear();
116  if (result->getId() == 0 && (result->getConfigTag().empty())) {
117  throw(std::runtime_error("ODScanConfig::fetchData(): no Id defined for this ODScanConfig "));
118  }
119 
120  try {
121  m_readStmt->setSQL(
122  "SELECT * "
123  "FROM ECAL_SCAN_DAT "
124  " where (scan_id = :1 or scan_tag=:2 )");
125  m_readStmt->setInt(1, result->getId());
126  m_readStmt->setString(2, result->getConfigTag());
127 
128  ResultSet* rset = m_readStmt->executeQuery();
129 
130  rset->next();
131 
132  // id 1 is the scan_id
133  result->setId(rset->getInt(1));
134  result->setConfigTag(rset->getString(2));
135  result->setTypeId(rset->getInt(3));
136  result->setScanType(rset->getString(4));
137  result->setFromVal(rset->getInt(5));
138  result->setToVal(rset->getInt(6));
139  result->setStep(rset->getInt(7));
140 
141  } catch (SQLException& e) {
142  throw(std::runtime_error(std::string("ODScanConfig::fetchData(): ") + e.getMessage()));
143  }
144 }
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setToVal(int x)
Definition: ODScanConfig.h:30
void setId(int id)
Definition: ODScanConfig.h:18
int getId() const
Definition: ODScanConfig.h:19
void setScanType(std::string x)
Definition: ODScanConfig.h:24
void setFromVal(int x)
Definition: ODScanConfig.h:27
void setConfigTag(std::string x)
Definition: IODConfig.h:29
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
void setTypeId(int x)
Definition: ODScanConfig.h:21
std::string getConfigTag()
Definition: IODConfig.h:30
void setStep(int x)
Definition: ODScanConfig.h:33
int ODScanConfig::fetchID ( )
privatenoexcept

Definition at line 146 of file ODScanConfig.cc.

References alignCSCRings::e, and AlCaHLTBitMon_QueryRunRegistry::string.

146  {
147  // Return from memory if available
148  if (m_ID != 0) {
149  return m_ID;
150  }
151 
152  this->checkConnection();
153 
154  try {
155  Statement* stmt = m_conn->createStatement();
156  stmt->setSQL(
157  "SELECT scan_id FROM ecal_scan_dat "
158  "WHERE scan_tag=:scan_tag ");
159 
160  stmt->setString(1, getConfigTag());
161 
162  ResultSet* rset = stmt->executeQuery();
163 
164  if (rset->next()) {
165  m_ID = rset->getInt(1);
166  } else {
167  m_ID = 0;
168  }
169  m_conn->terminateStatement(stmt);
170  } catch (SQLException& e) {
171  throw(std::runtime_error(std::string("ODScanConfig::fetchID: ") + e.getMessage()));
172  }
173 
174  return m_ID;
175 }
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
int ODScanConfig::fetchNextId ( )
privatenoexcept

Definition at line 31 of file ODScanConfig.cc.

References alignCSCRings::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 28 of file ODScanConfig.h.

References m_from_val.

28 { return m_from_val; }
int ODScanConfig::getId ( void  ) const
inline

Definition at line 19 of file ODScanConfig.h.

References m_ID.

19 { return m_ID; }
std::string ODScanConfig::getScanType ( ) const
inline

Definition at line 25 of file ODScanConfig.h.

References m_type.

25 { return m_type; }
std::string m_type
Definition: ODScanConfig.h:49
int ODScanConfig::getStep ( ) const
inline

Definition at line 34 of file ODScanConfig.h.

References m_step.

34 { return m_step; }
std::string ODScanConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 16 of file ODScanConfig.h.

16 { return "ECAL_Scan_DAT"; }
int ODScanConfig::getToVal ( ) const
inline

Definition at line 31 of file ODScanConfig.h.

References m_to_val.

31 { return m_to_val; }
int ODScanConfig::getTypeId ( ) const
inline

Definition at line 22 of file ODScanConfig.h.

References m_type_id.

22 { return m_type_id; }
void ODScanConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 70 of file ODScanConfig.cc.

References alignCSCRings::e, and AlCaHLTBitMon_QueryRunRegistry::string.

70  {
71  this->checkConnection();
72  int next_id = fetchNextId();
73 
74  try {
75  m_writeStmt = m_conn->createStatement();
76  m_writeStmt->setSQL(
77  "INSERT INTO ECAL_scan_dat ( scan_id, scan_tag ,"
78  " type_id, scan_type , FROM_VAL , TO_VAL, STEP )"
79  " VALUES ( :1, :2, :3, :4, :5, :6, :7)");
80  m_writeStmt->setInt(1, next_id);
81  m_ID = next_id;
82 
83  } catch (SQLException& e) {
84  throw(std::runtime_error(std::string("ODScanConfig::prepareWrite(): ") + e.getMessage()));
85  }
86 }
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: ODScanConfig.cc:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
void ODScanConfig::setFromVal ( int  x)
inline

Definition at line 27 of file ODScanConfig.h.

References m_from_val, and x.

27 { m_from_val = x; }
void ODScanConfig::setId ( int  id)
inline

Definition at line 18 of file ODScanConfig.h.

References gpuClustering::id, and m_ID.

18 { m_ID = id; }
uint16_t *__restrict__ id
void ODScanConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 50 of file ODScanConfig.cc.

50  {
51  // parses the result of the XML parser that is a map of
52  // string string with variable name variable value
53 
54  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
55  if (ci->first == "SCAN_ID")
56  setConfigTag(ci->second);
57  if (ci->first == "TYPE_ID")
58  setTypeId(atoi(ci->second.c_str()));
59  if (ci->first == "TYPE" || ci->first == "SCAN_TYPE")
60  setScanType(ci->second);
61  if (ci->first == "FROM" || ci->first == "FROM_VAL")
62  setFromVal(atoi(ci->second.c_str()));
63  if (ci->first == "TO" || ci->first == "TO_VAL")
64  setToVal(atoi(ci->second.c_str()));
65  if (ci->first == "STEP")
66  setStep(atoi(ci->second.c_str()));
67  }
68 }
void setToVal(int x)
Definition: ODScanConfig.h:30
void setScanType(std::string x)
Definition: ODScanConfig.h:24
void setFromVal(int x)
Definition: ODScanConfig.h:27
void setConfigTag(std::string x)
Definition: IODConfig.h:29
void setTypeId(int x)
Definition: ODScanConfig.h:21
void setStep(int x)
Definition: ODScanConfig.h:33
void ODScanConfig::setScanType ( std::string  x)
inline

Definition at line 24 of file ODScanConfig.h.

References m_type, and x.

24 { m_type = x; }
std::string m_type
Definition: ODScanConfig.h:49
void ODScanConfig::setStep ( int  x)
inline

Definition at line 33 of file ODScanConfig.h.

References m_step, and x.

33 { m_step = x; }
void ODScanConfig::setToVal ( int  x)
inline

Definition at line 30 of file ODScanConfig.h.

References m_to_val, and x.

30 { m_to_val = x; }
void ODScanConfig::setTypeId ( int  x)
inline

Definition at line 21 of file ODScanConfig.h.

References m_type_id, and x.

21 { m_type_id = x; }
void ODScanConfig::writeDB ( )
privatenoexcept

Definition at line 88 of file ODScanConfig.cc.

References alignCSCRings::e, and AlCaHLTBitMon_QueryRunRegistry::string.

88  {
89  this->checkConnection();
90  this->checkPrepare();
91 
92  try {
93  // number 1 is the id
94  m_writeStmt->setString(2, this->getConfigTag());
95 
96  m_writeStmt->setInt(3, this->getTypeId());
97  m_writeStmt->setString(4, this->getScanType());
98  m_writeStmt->setInt(5, this->getFromVal());
99  m_writeStmt->setInt(6, this->getToVal());
100  m_writeStmt->setInt(7, this->getStep());
101 
102  m_writeStmt->executeUpdate();
103 
104  } catch (SQLException& e) {
105  throw(std::runtime_error(std::string("ODScanConfig::writeDB(): ") + e.getMessage()));
106  }
107  // Now get the ID
108  if (!this->fetchID()) {
109  throw(std::runtime_error("ODScanConfig::writeDB: Failed to write"));
110  }
111 }
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getStep() const
Definition: ODScanConfig.h:34
int getToVal() const
Definition: ODScanConfig.h:31
int getFromVal() const
Definition: ODScanConfig.h:28
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30
int fetchID() noexcept(false)
std::string getScanType() const
Definition: ODScanConfig.h:25
int getTypeId() const
Definition: ODScanConfig.h:22
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODScanConfig.h.

Member Data Documentation

int ODScanConfig::m_from_val
private

Definition at line 50 of file ODScanConfig.h.

Referenced by getFromVal(), and setFromVal().

int ODScanConfig::m_ID
private

Definition at line 46 of file ODScanConfig.h.

Referenced by getId(), and setId().

int ODScanConfig::m_step
private

Definition at line 52 of file ODScanConfig.h.

Referenced by getStep(), and setStep().

int ODScanConfig::m_to_val
private

Definition at line 51 of file ODScanConfig.h.

Referenced by getToVal(), and setToVal().

std::string ODScanConfig::m_type
private

Definition at line 49 of file ODScanConfig.h.

Referenced by getScanType(), and setScanType().

int ODScanConfig::m_type_id
private

Definition at line 48 of file ODScanConfig.h.

Referenced by getTypeId(), and setTypeId().