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

#include <FEConfigTimingInfo.h>

Inheritance diagram for FEConfigTimingInfo:
IODConfig IDBObject

Public Member Functions

 FEConfigTimingInfo ()
 
int fetchID () throw (std::runtime_error)
 
int fetchNextId () throw (std::runtime_error)
 
Tm getDBTime () const
 
int getId () const
 
int getID ()
 
std::string getTable ()
 
int getVersion () const
 
bool operator!= (const FEConfigTimingInfo &r) const
 
bool operator== (const FEConfigTimingInfo &r) const
 
void setByID (int id) throw (std::runtime_error)
 
void setDBTime (const Tm &x)
 
void setId (int id)
 
void setID (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setVersion (int id)
 
 ~FEConfigTimingInfo ()
 
- 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 (FEConfigTimingInfo *result) throw (std::runtime_error)
 
void fetchLastData (FEConfigTimingInfo *result) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeDB () throw (std::runtime_error)
 

Private Attributes

Tm m_db_time
 
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 () 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 11 of file FEConfigTimingInfo.h.

Constructor & Destructor Documentation

FEConfigTimingInfo::FEConfigTimingInfo ( )

Definition at line 13 of file FEConfigTimingInfo.cc.

References hitfit::clear(), and NULL.

14 {
15  m_env = NULL;
16  m_conn = NULL;
17  m_writeStmt = NULL;
18  m_readStmt = NULL;
19  m_config_tag="";
20  m_version=0;
21  m_ID=0;
22  clear();
23 }
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
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
FEConfigTimingInfo::~FEConfigTimingInfo ( )

Definition at line 31 of file FEConfigTimingInfo.cc.

32 {
33 }

Member Function Documentation

void FEConfigTimingInfo::clear ( void  )
private

Definition at line 26 of file FEConfigTimingInfo.cc.

26  {
27 }
void FEConfigTimingInfo::fetchData ( FEConfigTimingInfo result)
throw (std::runtime_error
)
private

Definition at line 125 of file FEConfigTimingInfo.cc.

References DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, and mps_fire::result.

127 {
128  this->checkConnection();
129  result->clear();
130  if(result->getId()==0 && (result->getConfigTag()=="") ){
131  throw(std::runtime_error("FEConfigTimingInfo::fetchData(): no Id defined for this FEConfigTimingInfo "));
132  }
133 
134  try {
136 
137  m_readStmt->setSQL("SELECT * FROM " + getTable() +
138  " where ( tim_conf_id= :1 or (tag=:2 AND version=:3 ) )" );
139  m_readStmt->setInt(1, result->getId());
140  m_readStmt->setString(2, result->getConfigTag());
141  m_readStmt->setInt(3, result->getVersion());
142  ResultSet* rset = m_readStmt->executeQuery();
143 
144  rset->next();
145 
146  // 1 is the id and 2 is the config tag and 3 is the version
147 
148  result->setId(rset->getInt(1));
149  result->setConfigTag(rset->getString(2));
150  result->setVersion(rset->getInt(3));
151  Date dbdate = rset->getDate(4);
152  result->setDBTime( dh.dateToTm( dbdate ));
153 
154  } catch (SQLException &e) {
155  throw(std::runtime_error("FEConfigTimingInfo::fetchData(): "+e.getMessage()));
156  }
157 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string getTable()
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setDBTime(const Tm &x)
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
tuple dh
Definition: cuy.py:353
int FEConfigTimingInfo::fetchID ( )
throw (std::runtime_error
)

Definition at line 184 of file FEConfigTimingInfo.cc.

References alignCSCRings::e.

185 {
186  // Return from memory if available
187  if (m_ID!=0) {
188  return m_ID;
189  }
190 
191  this->checkConnection();
192 
193  try {
194  Statement* stmt = m_conn->createStatement();
195  stmt->setSQL("SELECT tim_conf_id FROM "+ getTable()+
196  " WHERE tag=:1 and version=:2 " );
197 
198  stmt->setString(1, getConfigTag() );
199  stmt->setInt(2, getVersion() );
200 
201  ResultSet* rset = stmt->executeQuery();
202 
203  if (rset->next()) {
204  m_ID = rset->getInt(1);
205  } else {
206  m_ID = 0;
207  }
208  m_conn->terminateStatement(stmt);
209  } catch (SQLException &e) {
210  throw(std::runtime_error("FEConfigTimingInfo::fetchID: "+e.getMessage()));
211  }
212 
213  return m_ID;
214 }
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
std::string getTable()
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
void FEConfigTimingInfo::fetchLastData ( FEConfigTimingInfo result)
throw (std::runtime_error
)
private

Definition at line 159 of file FEConfigTimingInfo.cc.

References DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, and mps_fire::result.

161 {
162  this->checkConnection();
163  result->clear();
164  try {
166 
167  m_readStmt->setSQL("SELECT * FROM " + getTable() +
168  " where tim_conf_id = ( select max( tim_conf_id) from "+ getTable() +" ) " );
169  ResultSet* rset = m_readStmt->executeQuery();
170 
171  rset->next();
172 
173  result->setId(rset->getInt(1));
174  result->setConfigTag(rset->getString(2));
175  result->setVersion(rset->getInt(3));
176  Date dbdate = rset->getDate(4);
177  result->setDBTime( dh.dateToTm( dbdate ));
178 
179  } catch (SQLException &e) {
180  throw(std::runtime_error("FEConfigTimingInfo::fetchData(): "+e.getMessage()));
181  }
182 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string getTable()
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setDBTime(const Tm &x)
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
tuple dh
Definition: cuy.py:353
int FEConfigTimingInfo::fetchNextId ( )
throw (std::runtime_error
)

Definition at line 37 of file FEConfigTimingInfo.cc.

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

37  {
38 
39  int result=0;
40  try {
41  this->checkConnection();
42 
43  m_readStmt = m_conn->createStatement();
44  m_readStmt->setSQL("select FE_CONFIG_TIM_SQ.NextVal from DUAL ");
45  ResultSet* rset = m_readStmt->executeQuery();
46  while (rset->next ()){
47  result= rset->getInt(1);
48  }
49  result++;
50  m_conn->terminateStatement(m_readStmt);
51  return result;
52 
53  } catch (SQLException &e) {
54  throw(std::runtime_error("FEConfigTimingInfo::fetchNextId(): "+e.getMessage()));
55  }
56 
57 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple result
Definition: mps_fire.py:84
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
Tm FEConfigTimingInfo::getDBTime ( ) const
inline

Definition at line 32 of file FEConfigTimingInfo.h.

References m_db_time.

32 { return m_db_time;}
int FEConfigTimingInfo::getId ( ) const
inline

Definition at line 23 of file FEConfigTimingInfo.h.

References m_ID.

Referenced by getID(), and EcalTPGDBApp::writeToConfDB_Delay().

23 { return m_ID; }
int FEConfigTimingInfo::getID ( )
inline

Definition at line 26 of file FEConfigTimingInfo.h.

References getId().

26 { return getId() ;}
std::string FEConfigTimingInfo::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 19 of file FEConfigTimingInfo.h.

19 { return "FE_CONFIG_TIME_INFO"; }
int FEConfigTimingInfo::getVersion ( ) const
inline

Definition at line 29 of file FEConfigTimingInfo.h.

References m_version.

29 { return m_version; }
bool FEConfigTimingInfo::operator!= ( const FEConfigTimingInfo r) const
inline

Definition at line 44 of file FEConfigTimingInfo.h.

References alignCSCRings::r.

44 { return !(*this == r); }
bool FEConfigTimingInfo::operator== ( const FEConfigTimingInfo r) const
inline

Definition at line 43 of file FEConfigTimingInfo.h.

References m_ID.

43 { return (m_ID == r.m_ID ); }
void FEConfigTimingInfo::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 59 of file FEConfigTimingInfo.cc.

References alignCSCRings::e, and getId().

61 {
62  this->checkConnection();
63 
64  int next_id=0;
65  if(getId()==0){
66  next_id=fetchNextId();
67  }
68 
69  try {
70  m_writeStmt = m_conn->createStatement();
71  m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( tim_conf_id, tag, version) "
72  " VALUES ( :1, :2, :3 ) " );
73 
74  m_writeStmt->setInt(1, next_id);
75  m_ID=next_id;
76 
77  } catch (SQLException &e) {
78  throw(std::runtime_error("FEConfigTimingInfo::prepareWrite(): "+e.getMessage()));
79  }
80 
81 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string getTable()
void checkConnection() const
Definition: IDBObject.h:41
void FEConfigTimingInfo::setByID ( int  id)
throw (std::runtime_error
)

Definition at line 218 of file FEConfigTimingInfo.cc.

References DateHandler::dateToTm(), cuy::dh, and alignCSCRings::e.

220 {
221  this->checkConnection();
222 
224 
225  try {
226  Statement* stmt = m_conn->createStatement();
227 
228  stmt->setSQL("SELECT * FROM "+ getTable()+" WHERE tim_conf_id = :1");
229  stmt->setInt(1, id);
230 
231  ResultSet* rset = stmt->executeQuery();
232  if (rset->next()) {
233  this->setId(rset->getInt(1));
234  this->setConfigTag(rset->getString(2));
235  this->setVersion(rset->getInt(3));
236  Date dbdate = rset->getDate(4);
237  this->setDBTime( dh.dateToTm( dbdate ));
238  } else {
239  throw(std::runtime_error("FEConfigTimingInfo::setByID: Given tim_conf_id is not in the database"));
240  }
241 
242  m_conn->terminateStatement(stmt);
243  } catch (SQLException &e) {
244  throw(std::runtime_error("FEConfigTimingInfo::setByID: "+e.getMessage()));
245  }
246 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
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
std::string getTable()
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setDBTime(const Tm &x)
void checkConnection() const
Definition: IDBObject.h:41
tuple dh
Definition: cuy.py:353
void FEConfigTimingInfo::setDBTime ( const Tm x)
inline

Definition at line 33 of file FEConfigTimingInfo.h.

References m_db_time, and x.

void FEConfigTimingInfo::setId ( int  id)
inline

Definition at line 22 of file FEConfigTimingInfo.h.

References m_ID.

Referenced by setID().

22 { m_ID = id; }
void FEConfigTimingInfo::setID ( int  id)
inline

Definition at line 25 of file FEConfigTimingInfo.h.

References setId().

25 {setId(id);}
void FEConfigTimingInfo::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 83 of file FEConfigTimingInfo.cc.

83  {
84 
85  // parses the result of the XML parser that is a map of
86  // string string with variable name variable value
87 
88  for( std::map<std::string, std::string >::const_iterator ci=
89  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
90 
91  if(ci->first== "VERSION") setVersion(atoi(ci->second.c_str()) );
92  if(ci->first== "TAG") setConfigTag(ci->second);
93 
94  }
95 
96 }
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void FEConfigTimingInfo::setVersion ( int  id)
inline

Definition at line 28 of file FEConfigTimingInfo.h.

References m_version.

28 { m_version = id; }
void FEConfigTimingInfo::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 98 of file FEConfigTimingInfo.cc.

References alignCSCRings::e.

100 {
101  this->checkConnection();
102  this->checkPrepare();
103 
104  try {
105 
106  // number 1 is the id
107  m_writeStmt->setString(2, this->getConfigTag());
108  m_writeStmt->setInt(3, this->getVersion());
109 
110  m_writeStmt->executeUpdate();
111 
112 
113  } catch (SQLException &e) {
114  throw(std::runtime_error("FEConfigTimingInfo::writeDB(): "+e.getMessage()));
115  }
116  // Now get the ID
117  if (!this->fetchID()) {
118  throw(std::runtime_error("FEConfigTimingInfo::writeDB: Failed to write"));
119  }
120 
121 
122 }
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkPrepare()
Definition: IODConfig.h:39
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 13 of file FEConfigTimingInfo.h.

Member Data Documentation

Tm FEConfigTimingInfo::m_db_time
private

Definition at line 49 of file FEConfigTimingInfo.h.

Referenced by getDBTime(), and setDBTime().

int FEConfigTimingInfo::m_ID
private

Definition at line 48 of file FEConfigTimingInfo.h.

Referenced by getId(), operator==(), and setId().

int FEConfigTimingInfo::m_version
private

Definition at line 50 of file FEConfigTimingInfo.h.

Referenced by getVersion(), and setVersion().