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().

12 {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17  m_config_tag="";
18  m_ID=0;
19  clear();
20 
21 }
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
void clear()
Definition: ODLTSConfig.cc:23
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
ODLTSConfig::~ODLTSConfig ( )
override

Definition at line 32 of file ODLTSConfig.cc.

33 {
34 }

Member Function Documentation

void ODLTSConfig::clear ( void  )
private

Definition at line 23 of file ODLTSConfig.cc.

Referenced by getTrigLocL1Delay().

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

Definition at line 127 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

129 {
130  this->checkConnection();
131  result->clear();
132  if(result->getId()==0 && (result->getConfigTag().empty()) ){
133  throw(std::runtime_error("ODLTSConfig::fetchData(): no Id defined for this ODLTSConfig "));
134  }
135 
136  try {
137 
138  m_readStmt->setSQL("SELECT * "
139  "FROM ECAL_LTS_CONFIGURATION "
140  " where ( lts_configuration_id = :1 or lts_tag=:2 ) " );
141  m_readStmt->setInt(1, result->getId());
142  m_readStmt->setString(2, result->getConfigTag());
143  ResultSet* rset = m_readStmt->executeQuery();
144 
145  rset->next();
146  // 1 is the id and 2 is the config tag
147  result->setId(rset->getInt(1));
148  result->setConfigTag(getOraString(rset,2));
149 
150  result->setTriggerType( getOraString(rset,3) );
151  result->setNumberOfEvents( rset->getInt(4) );
152  result->setRate( rset->getInt(5) );
153  result->setTrigLocL1Delay( rset->getInt(6) );
154 
155 
156  } catch (SQLException &e) {
157  throw(std::runtime_error(std::string("ODLTSConfig::fetchData(): ")+getOraMessage(&e)));
158  }
159 }
int getId() const
Definition: ODLTSConfig.h:19
void clear()
Definition: ODLTSConfig.cc:23
void setId(int id)
Definition: ODLTSConfig.h:18
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
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:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void setRate(int x)
Definition: ODLTSConfig.h:27
int ODLTSConfig::fetchID ( )
privatenoexcept

Definition at line 161 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

162 {
163  // Return from memory if available
164  if (m_ID!=0) {
165  return m_ID;
166  }
167 
168  this->checkConnection();
169 
170  try {
171  Statement* stmt = m_conn->createStatement();
172  stmt->setSQL("SELECT lts_configuration_id FROM ecal_lts_configuration "
173  "WHERE lts_tag=:lts_tag " );
174 
175  stmt->setString(1, getConfigTag());
176 
177  ResultSet* rset = stmt->executeQuery();
178 
179  if (rset->next()) {
180  m_ID = rset->getInt(1);
181  } else {
182  m_ID = 0;
183  }
184  m_conn->terminateStatement(stmt);
185  } catch (SQLException &e) {
186  throw(std::runtime_error(std::string("ODLTSConfig::fetchID: ")+getOraMessage(&e)));
187  }
188 
189  return m_ID;
190 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
int ODLTSConfig::fetchNextId ( )
privatenoexcept

Definition at line 53 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

53  {
54 
55  int result=0;
56  try {
57  this->checkConnection();
58 
59  m_readStmt = m_conn->createStatement();
60  m_readStmt->setSQL("select ecal_lts_config_sq.NextVal from dual");
61  ResultSet* rset = m_readStmt->executeQuery();
62  while (rset->next ()){
63  result= rset->getInt(1);
64  }
65  m_conn->terminateStatement(m_readStmt);
66  return result;
67 
68  } catch (SQLException &e) {
69  throw(std::runtime_error(std::string("ODLTSConfig::fetchNextId(): ")+getOraMessage(&e)));
70  }
71 
72 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
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 75 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

77 {
78  this->checkConnection();
79  int next_id=fetchNextId();
80 
81  try {
82  m_writeStmt = m_conn->createStatement();
83  m_writeStmt->setSQL("INSERT INTO ECAL_LTS_CONFIGURATION ( lts_configuration_id, lts_tag, "
84  "trigger_type, num_of_events, rate, trig_loc_l1_delay ) "
85  "VALUES ( "
86  ":1, :2, :3, :4 , :5, :6 )");
87  m_writeStmt->setInt(1, next_id);
88  m_ID=next_id;
89 
90  } catch (SQLException &e) {
91  throw(std::runtime_error(std::string("ODLTSConfig::prepareWrite(): ")+getOraMessage(&e)));
92  }
93 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchNextId() noexcept(false)
Definition: ODLTSConfig.cc:53
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
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 36 of file ODLTSConfig.cc.

Referenced by getTrigLocL1Delay().

36  {
37 
38  // parses the result of the XML parser that is a map of
39  // string string with variable name variable value
40 
41  for( std::map<std::string, std::string >::const_iterator ci=
42  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
43 
44  if(ci->first== "LTS_CONFIGURATION_ID") setConfigTag(ci->second);
45  if(ci->first== "NUM_OF_EVENTS") setNumberOfEvents(atoi(ci->second.c_str()) );
46  if(ci->first== "RATE") setRate(atoi(ci->second.c_str() ));
47  if(ci->first== "TRIGGER_TYPE") setTriggerType(ci->second );
48  if(ci->first== "TRIG_LOC_L1_DELAY") setTrigLocL1Delay(atoi(ci->second.c_str() ));
49  }
50 
51 }
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:31
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 97 of file ODLTSConfig.cc.

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

Referenced by getTrigLocL1Delay().

99 {
100  this->checkConnection();
101  this->checkPrepare();
102 
103  try {
104 
105  m_writeStmt->setString(2, this->getConfigTag());
106  m_writeStmt->setString(3, this->getTriggerType());
107  m_writeStmt->setInt(4, this->getNumberOfEvents());
108  m_writeStmt->setInt(5, this->getRate());
109  m_writeStmt->setInt(6, this->getTrigLocL1Delay());
110 
111  m_writeStmt->executeUpdate();
112 
113 
114  } catch (SQLException &e) {
115  throw(std::runtime_error(std::string("ODLTSConfig::writeDB(): ")+getOraMessage(&e)));
116  }
117  // Now get the ID
118  if (!this->fetchID()) {
119  throw(std::runtime_error("ODLTSConfig::writeDB: Failed to write"));
120  }
121 
122 
123 }
Statement * m_writeStmt
Definition: IODConfig.h:36
int getTrigLocL1Delay() const
Definition: ODLTSConfig.h:31
int getRate() const
Definition: ODLTSConfig.h:28
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getNumberOfEvents() const
Definition: ODLTSConfig.h:25
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int fetchID() noexcept(false)
Definition: ODLTSConfig.cc:161
std::string getTriggerType() const
Definition: ODLTSConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39

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().