CMS 3D CMS Logo

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

#include <ODLTSConfig.h>

Inheritance diagram for ODLTSConfig:
IODConfig IDBObject

Public Member Functions

int getId () const
 
int getNumberOfEvents () const
 
int getRate () const
 
std::string getTable () override
 
std::string getTriggerType () const
 
int getTrigLocL1Delay () const
 
 ODLTSConfig ()
 
void setId (int id)
 
void setNumberOfEvents (int x)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setRate (int x)
 
void setTriggerType (std::string x)
 
void setTrigLocL1Delay (int x)
 
 ~ODLTSConfig () 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 (ODLTSConfig *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

int m_delay
 
int m_ID
 
int m_num
 
int m_rate
 
std::string m_trg_type
 

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

Constructor & Destructor Documentation

ODLTSConfig::ODLTSConfig ( )

Definition at line 11 of file ODLTSConfig.cc.

References hitfit::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
void clear()
Definition: ODLTSConfig.cc:21
std::string m_config_tag
Definition: IODConfig.h:25
Statement * m_readStmt
Definition: IODConfig.h:34
ODLTSConfig::~ODLTSConfig ( )
override

Definition at line 28 of file ODLTSConfig.cc.

28 {}

Member Function Documentation

void ODLTSConfig::clear ( void  )
private

Definition at line 21 of file ODLTSConfig.cc.

Referenced by getTrigLocL1Delay().

21  {
22  m_trg_type = "";
23  m_num = 0;
24  m_rate = 0;
25  m_delay = 0;
26 }
std::string m_trg_type
Definition: ODLTSConfig.h:44
void ODLTSConfig::fetchData ( ODLTSConfig result)
privatenoexcept

Definition at line 108 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

108  {
109  this->checkConnection();
110  result->clear();
111  if (result->getId() == 0 && (result->getConfigTag().empty())) {
112  throw(std::runtime_error("ODLTSConfig::fetchData(): no Id defined for this ODLTSConfig "));
113  }
114 
115  try {
116  m_readStmt->setSQL(
117  "SELECT * "
118  "FROM ECAL_LTS_CONFIGURATION "
119  " where ( lts_configuration_id = :1 or lts_tag=:2 ) ");
120  m_readStmt->setInt(1, result->getId());
121  m_readStmt->setString(2, result->getConfigTag());
122  ResultSet* rset = m_readStmt->executeQuery();
123 
124  rset->next();
125  // 1 is the id and 2 is the config tag
126  result->setId(rset->getInt(1));
127  result->setConfigTag(rset->getString(2));
128 
129  result->setTriggerType(rset->getString(3));
130  result->setNumberOfEvents(rset->getInt(4));
131  result->setRate(rset->getInt(5));
132  result->setTrigLocL1Delay(rset->getInt(6));
133 
134  } catch (SQLException& e) {
135  throw(std::runtime_error(std::string("ODLTSConfig::fetchData(): ") + e.getMessage()));
136  }
137 }
int getId() const
Definition: ODLTSConfig.h:19
void clear()
Definition: ODLTSConfig.cc:21
void setId(int id)
Definition: ODLTSConfig.h:18
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setNumberOfEvents(int x)
Definition: ODLTSConfig.h:24
void setTrigLocL1Delay(int x)
Definition: ODLTSConfig.h:30
void setTriggerType(std::string x)
Definition: ODLTSConfig.h:21
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
void setRate(int x)
Definition: ODLTSConfig.h:27
int ODLTSConfig::fetchID ( )
privatenoexcept

Definition at line 139 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

139  {
140  // Return from memory if available
141  if (m_ID != 0) {
142  return m_ID;
143  }
144 
145  this->checkConnection();
146 
147  try {
148  Statement* stmt = m_conn->createStatement();
149  stmt->setSQL(
150  "SELECT lts_configuration_id FROM ecal_lts_configuration "
151  "WHERE lts_tag=:lts_tag ");
152 
153  stmt->setString(1, getConfigTag());
154 
155  ResultSet* rset = stmt->executeQuery();
156 
157  if (rset->next()) {
158  m_ID = rset->getInt(1);
159  } else {
160  m_ID = 0;
161  }
162  m_conn->terminateStatement(stmt);
163  } catch (SQLException& e) {
164  throw(std::runtime_error(std::string("ODLTSConfig::fetchID: ") + e.getMessage()));
165  }
166 
167  return m_ID;
168 }
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 ODLTSConfig::fetchNextId ( )
privatenoexcept

Definition at line 48 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

48  {
49  int result = 0;
50  try {
51  this->checkConnection();
52 
53  m_readStmt = m_conn->createStatement();
54  m_readStmt->setSQL("select ecal_lts_config_sq.NextVal from dual");
55  ResultSet* rset = m_readStmt->executeQuery();
56  while (rset->next()) {
57  result = rset->getInt(1);
58  }
59  m_conn->terminateStatement(m_readStmt);
60  return result;
61 
62  } catch (SQLException& e) {
63  throw(std::runtime_error(std::string("ODLTSConfig::fetchNextId(): ") + e.getMessage()));
64  }
65 }
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
int ODLTSConfig::getId ( void  ) const
inline

Definition at line 19 of file ODLTSConfig.h.

References m_ID.

19 { return m_ID; }
int ODLTSConfig::getNumberOfEvents ( ) const
inline

Definition at line 25 of file ODLTSConfig.h.

References m_num.

25 { return m_num; }
int ODLTSConfig::getRate ( ) const
inline

Definition at line 28 of file ODLTSConfig.h.

References m_rate.

28 { return m_rate; }
std::string ODLTSConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 16 of file ODLTSConfig.h.

16 { return "ECAL_LTS_CONFIGURATION"; }
std::string ODLTSConfig::getTriggerType ( ) const
inline

Definition at line 22 of file ODLTSConfig.h.

References m_trg_type.

22 { return m_trg_type; }
std::string m_trg_type
Definition: ODLTSConfig.h:44
int ODLTSConfig::getTrigLocL1Delay ( ) const
inline
void ODLTSConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 67 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

67  {
68  this->checkConnection();
69  int next_id = fetchNextId();
70 
71  try {
72  m_writeStmt = m_conn->createStatement();
73  m_writeStmt->setSQL(
74  "INSERT INTO ECAL_LTS_CONFIGURATION ( lts_configuration_id, lts_tag, "
75  "trigger_type, num_of_events, rate, trig_loc_l1_delay ) "
76  "VALUES ( "
77  ":1, :2, :3, :4 , :5, :6 )");
78  m_writeStmt->setInt(1, next_id);
79  m_ID = next_id;
80 
81  } catch (SQLException& e) {
82  throw(std::runtime_error(std::string("ODLTSConfig::prepareWrite(): ") + e.getMessage()));
83  }
84 }
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: ODLTSConfig.cc:48
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
void ODLTSConfig::setId ( int  id)
inline

Definition at line 18 of file ODLTSConfig.h.

References triggerObjects_cff::id, and m_ID.

void ODLTSConfig::setNumberOfEvents ( int  x)
inline

Definition at line 24 of file ODLTSConfig.h.

References m_num, and x.

24 { m_num = x; }
void ODLTSConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 30 of file ODLTSConfig.cc.

Referenced by getTrigLocL1Delay().

30  {
31  // parses the result of the XML parser that is a map of
32  // string string with variable name variable value
33 
34  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
35  if (ci->first == "LTS_CONFIGURATION_ID")
36  setConfigTag(ci->second);
37  if (ci->first == "NUM_OF_EVENTS")
38  setNumberOfEvents(atoi(ci->second.c_str()));
39  if (ci->first == "RATE")
40  setRate(atoi(ci->second.c_str()));
41  if (ci->first == "TRIGGER_TYPE")
42  setTriggerType(ci->second);
43  if (ci->first == "TRIG_LOC_L1_DELAY")
44  setTrigLocL1Delay(atoi(ci->second.c_str()));
45  }
46 }
void setNumberOfEvents(int x)
Definition: ODLTSConfig.h:24
void setTrigLocL1Delay(int x)
Definition: ODLTSConfig.h:30
void setTriggerType(std::string x)
Definition: ODLTSConfig.h:21
void setConfigTag(std::string x)
Definition: IODConfig.h:29
void setRate(int x)
Definition: ODLTSConfig.h:27
void ODLTSConfig::setRate ( int  x)
inline

Definition at line 27 of file ODLTSConfig.h.

References m_rate, and x.

27 { m_rate = x; }
void ODLTSConfig::setTriggerType ( std::string  x)
inline

Definition at line 21 of file ODLTSConfig.h.

References m_trg_type, and x.

21 { m_trg_type = x; }
std::string m_trg_type
Definition: ODLTSConfig.h:44
void ODLTSConfig::setTrigLocL1Delay ( int  x)
inline

Definition at line 30 of file ODLTSConfig.h.

References m_delay, and x.

30 { m_delay = x; }
void ODLTSConfig::writeDB ( )
privatenoexcept

Definition at line 86 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

86  {
87  this->checkConnection();
88  this->checkPrepare();
89 
90  try {
91  m_writeStmt->setString(2, this->getConfigTag());
92  m_writeStmt->setString(3, this->getTriggerType());
93  m_writeStmt->setInt(4, this->getNumberOfEvents());
94  m_writeStmt->setInt(5, this->getRate());
95  m_writeStmt->setInt(6, this->getTrigLocL1Delay());
96 
97  m_writeStmt->executeUpdate();
98 
99  } catch (SQLException& e) {
100  throw(std::runtime_error(std::string("ODLTSConfig::writeDB(): ") + e.getMessage()));
101  }
102  // Now get the ID
103  if (!this->fetchID()) {
104  throw(std::runtime_error("ODLTSConfig::writeDB: Failed to write"));
105  }
106 }
Statement * m_writeStmt
Definition: IODConfig.h:33
int getTrigLocL1Delay() const
Definition: ODLTSConfig.h:31
int getRate() const
Definition: ODLTSConfig.h:28
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getNumberOfEvents() const
Definition: ODLTSConfig.h:25
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
int fetchID() noexcept(false)
Definition: ODLTSConfig.cc:139
std::string getTriggerType() const
Definition: ODLTSConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:30
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODLTSConfig.h.

Member Data Documentation

int ODLTSConfig::m_delay
private

Definition at line 47 of file ODLTSConfig.h.

Referenced by getTrigLocL1Delay(), and setTrigLocL1Delay().

int ODLTSConfig::m_ID
private

Definition at line 43 of file ODLTSConfig.h.

Referenced by getId(), and setId().

int ODLTSConfig::m_num
private

Definition at line 45 of file ODLTSConfig.h.

Referenced by getNumberOfEvents(), and setNumberOfEvents().

int ODLTSConfig::m_rate
private

Definition at line 46 of file ODLTSConfig.h.

Referenced by getRate(), and setRate().

std::string ODLTSConfig::m_trg_type
private

Definition at line 44 of file ODLTSConfig.h.

Referenced by getTriggerType(), and setTriggerType().