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

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

Constructor & Destructor Documentation

ODLTSConfig::ODLTSConfig ( )

Definition at line 11 of file ODLTSConfig.cc.

References hitfit::clear(), and NULL.

12 {
13  m_env = NULL;
14  m_conn = NULL;
15  m_writeStmt = NULL;
16  m_readStmt = NULL;
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
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
ODLTSConfig::~ODLTSConfig ( )

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.

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)
throw (std::runtime_error
)
private

Definition at line 127 of file ODLTSConfig.cc.

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

129 {
130  this->checkConnection();
131  result->clear();
132  if(result->getId()==0 && (result->getConfigTag()=="") ){
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(rset->getString(2));
149 
150  result->setTriggerType( rset->getString(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("ODLTSConfig::fetchData(): "+e.getMessage()));
158  }
159 }
int getId() const
Definition: ODLTSConfig.h:19
void clear()
Definition: ODLTSConfig.cc:23
void setId(int id)
Definition: ODLTSConfig.h:18
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
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
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 setRate(int x)
Definition: ODLTSConfig.h:27
void checkConnection() const
Definition: IDBObject.h:41
int ODLTSConfig::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 161 of file ODLTSConfig.cc.

References alignCSCRings::e.

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("ODLTSConfig::fetchID: "+e.getMessage()));
187  }
188 
189  return m_ID;
190 }
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 ODLTSConfig::fetchNextId ( )
throw (std::runtime_error
)
private

Definition at line 53 of file ODLTSConfig.cc.

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

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("ODLTSConfig::fetchNextId(): "+e.getMessage()));
70  }
71 
72 }
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 ODLTSConfig::getId ( ) 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 ( )
inlinevirtual

Implements IODConfig.

Definition at line 16 of file ODLTSConfig.h.

16 { return "ECAL_LTS_CONFIGURATION"; }
std::string ODLTSConfig::getTriggerType ( void  ) 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

Definition at line 31 of file ODLTSConfig.h.

References m_delay.

31 { return m_delay; }
void ODLTSConfig::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 75 of file ODLTSConfig.cc.

References alignCSCRings::e.

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("ODLTSConfig::prepareWrite(): "+e.getMessage()));
92  }
93 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int fetchNextId()
Definition: ODLTSConfig.cc:53
void checkConnection() const
Definition: IDBObject.h:41
void ODLTSConfig::setId ( int  id)
inline

Definition at line 18 of file ODLTSConfig.h.

References m_ID.

18 { m_ID = 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.

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 ( )
throw (std::runtime_error
)
private

Definition at line 97 of file ODLTSConfig.cc.

References alignCSCRings::e.

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("ODLTSConfig::writeDB(): "+e.getMessage()));
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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int getRate() const
Definition: ODLTSConfig.h:28
int getNumberOfEvents() const
Definition: ODLTSConfig.h:25
void checkPrepare()
Definition: IODConfig.h:39
std::string getTriggerType() const
Definition: ODLTSConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41

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