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
ODFEDelaysInfo Class Reference

#include <ODFEDelaysInfo.h>

Inheritance diagram for ODFEDelaysInfo:
IODConfig IDBObject

Public Member Functions

int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
int getId () const
 
std::string getTable () override
 
int getVersion () const
 
 ODFEDelaysInfo ()
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setVersion (int id)
 
 ~ODFEDelaysInfo () 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 (ODFEDelaysInfo *result) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

int m_ID
 
int m_version
 

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

Constructor & Destructor Documentation

ODFEDelaysInfo::ODFEDelaysInfo ( )

Definition at line 12 of file ODFEDelaysInfo.cc.

References clear().

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

Definition at line 25 of file ODFEDelaysInfo.cc.

25 {}

Member Function Documentation

void ODFEDelaysInfo::clear ( void  )
private

Definition at line 23 of file ODFEDelaysInfo.cc.

23 {}
void ODFEDelaysInfo::fetchData ( ODFEDelaysInfo result)
privatenoexcept

Definition at line 110 of file ODFEDelaysInfo.cc.

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

110  {
111  this->checkConnection();
112 
113  result->clear();
114  if (result->getId() == 0 && (result->getConfigTag().empty())) {
115  throw(std::runtime_error("ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
116  }
117 
118  try {
119  if (result->getId() != 0) {
120  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where rec_id = :1 ");
121  m_readStmt->setInt(1, result->getId());
122  } else if (!result->getConfigTag().empty()) {
123  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where tag=:1 AND version=:2 ");
124  m_readStmt->setString(1, result->getConfigTag());
125  m_readStmt->setInt(2, result->getVersion());
126  } else {
127  // we should never pass here
128  throw(std::runtime_error("ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
129  }
130 
131  ResultSet* rset = m_readStmt->executeQuery();
132  rset->next();
133 
134  // 1 is the id and 2 is the config tag and 3 is the version
135 
136  result->setId(rset->getInt(1));
137  result->setConfigTag(rset->getString(2));
138  result->setVersion(rset->getInt(3));
139 
140  } catch (SQLException& e) {
141  throw(std::runtime_error(std::string("ODFEDelaysInfo::fetchData(): ") + e.getMessage()));
142  }
143 }
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getId() const
void setVersion(int id)
int getVersion() const
std::string getTable() override
void setId(int id)
void setConfigTag(std::string x)
Definition: IODConfig.h:29
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
std::string getConfigTag()
Definition: IODConfig.h:30
int ODFEDelaysInfo::fetchID ( )
noexcept

Definition at line 145 of file ODFEDelaysInfo.cc.

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

145  {
146  // Return from memory if available
147  if (m_ID != 0) {
148  return m_ID;
149  }
150 
151  this->checkConnection();
152 
153  try {
154  Statement* stmt = m_conn->createStatement();
155  stmt->setSQL("SELECT rec_id FROM " + getTable() + "WHERE tag=:1 and version=:2 ");
156 
157  stmt->setString(1, getConfigTag());
158  stmt->setInt(2, getVersion());
159 
160  ResultSet* rset = stmt->executeQuery();
161 
162  if (rset->next()) {
163  m_ID = rset->getInt(1);
164  } else {
165  m_ID = 0;
166  }
167  m_conn->terminateStatement(stmt);
168  } catch (SQLException& e) {
169  throw(std::runtime_error(std::string("ODFEDelaysInfo::fetchID: ") + e.getMessage()));
170  }
171 
172  return m_ID;
173 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getVersion() const
std::string getTable() override
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30
int ODFEDelaysInfo::fetchNextId ( )
noexcept

Definition at line 27 of file ODFEDelaysInfo.cc.

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

27  {
28  int result = 0;
29  try {
30  this->checkConnection();
31 
32  m_readStmt = m_conn->createStatement();
33  m_readStmt->setSQL("select COND2CONF_INFO_SQ.NextVal from DUAL ");
34  ResultSet* rset = m_readStmt->executeQuery();
35  while (rset->next()) {
36  result = rset->getInt(1);
37  }
38  result++;
39  m_conn->terminateStatement(m_readStmt);
40  std::cout << " the id is going to be : " << result << endl;
41  return result;
42 
43  } catch (SQLException& e) {
44  throw(std::runtime_error(std::string("ODFEDelaysInfo::fetchNextId(): ") + e.getMessage()));
45  }
46 }
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
tuple cout
Definition: gather_cfg.py:144
int ODFEDelaysInfo::getId ( void  ) const
inline

Definition at line 19 of file ODFEDelaysInfo.h.

References m_ID.

19 { return m_ID; }
std::string ODFEDelaysInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 16 of file ODFEDelaysInfo.h.

16 { return "DELAYS_INFO"; }
int ODFEDelaysInfo::getVersion ( ) const
inline

Definition at line 24 of file ODFEDelaysInfo.h.

References m_version.

24 { return m_version; }
void ODFEDelaysInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 48 of file ODFEDelaysInfo.cc.

References alignCSCRings::e, getId(), and AlCaHLTBitMon_QueryRunRegistry::string.

48  {
49  this->checkConnection();
50 
51  int next_id = 0;
52  if (getId() == 0) {
53  next_id = fetchNextId();
54  }
55 
56  try {
57  m_writeStmt = m_conn->createStatement();
58  m_writeStmt->setSQL("INSERT INTO " + getTable() +
59  " ( rec_id, tag, version) "
60  " VALUES ( :1, :2, :3 ) ");
61 
62  m_writeStmt->setInt(1, next_id);
63  m_ID = next_id;
64 
65  } catch (SQLException& e) {
66  throw(std::runtime_error(std::string("ODFEDelaysInfo::prepareWrite(): ") + e.getMessage()));
67  }
68 }
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 getId() const
std::string getTable() override
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
int fetchNextId() noexcept(false)
void ODFEDelaysInfo::setId ( int  id)
inline

Definition at line 18 of file ODFEDelaysInfo.h.

References gpuClustering::id, and m_ID.

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

Definition at line 70 of file ODFEDelaysInfo.cc.

70  {
71  // parses the result of the XML parser that is a map of
72  // string string with variable name variable value
73 
74  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
75  if (ci->first == "VERSION")
76  setVersion(atoi(ci->second.c_str()));
77  if (ci->first == "TAG")
78  setConfigTag(ci->second);
79  }
80 }
void setVersion(int id)
void setConfigTag(std::string x)
Definition: IODConfig.h:29
void ODFEDelaysInfo::setVersion ( int  id)
inline

Definition at line 23 of file ODFEDelaysInfo.h.

References gpuClustering::id, and m_version.

23 { m_version = id; }
uint16_t *__restrict__ id
void ODFEDelaysInfo::writeDB ( )
privatenoexcept

Definition at line 82 of file ODFEDelaysInfo.cc.

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

82  {
83  this->checkConnection();
84  this->checkPrepare();
85 
86  try {
87  // number 1 is the id
88  m_writeStmt->setString(2, this->getConfigTag());
89  m_writeStmt->setInt(3, this->getVersion());
90 
91  m_writeStmt->executeUpdate();
92 
93  } catch (SQLException& e) {
94  throw(std::runtime_error(std::string("ODFEDelaysInfo::writeDB(): ") + e.getMessage()));
95  }
96 
97  // Now get the ID
98  if (!this->fetchID()) {
99  throw(std::runtime_error("ODFEDelaysInfo::writeDB: Failed to write"));
100  } else {
101  int old_version = this->getVersion();
102  m_readStmt = m_conn->createStatement();
103  this->fetchData(this);
104  m_conn->terminateStatement(m_readStmt);
105  if (this->getVersion() != old_version)
106  std::cout << "ODFEDelaysInfo>>WARNING version is " << getVersion() << endl;
107  }
108 }
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 fetchID() noexcept(false)
void fetchData(ODFEDelaysInfo *result) noexcept(false)
int getVersion() const
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
std::string getConfigTag()
Definition: IODConfig.h:30
tuple cout
Definition: gather_cfg.py:144
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODFEDelaysInfo.h.

Member Data Documentation

int ODFEDelaysInfo::m_ID
private

Definition at line 40 of file ODFEDelaysInfo.h.

Referenced by getId(), and setId().

int ODFEDelaysInfo::m_version
private

Definition at line 41 of file ODFEDelaysInfo.h.

Referenced by getVersion(), and setVersion().