CMS 3D CMS Logo

LMFUnique.h
Go to the documentation of this file.
1 #ifndef LMFUNIQUE_H
2 #define LMFUNIQUE_H
3 
4 /*
5  Giovanni.Organtini@roma1.infn.it 2010
6  */
7 
8 #include <stdexcept>
9 #include <iostream>
10 #include <map>
11 #include <boost/ptr_container/ptr_list.hpp>
16 
17 class LMFUnique : public IUniqueDBObject {
18 public:
19  typedef oracle::occi::ResultSet ResultSet;
20  typedef oracle::occi::Statement Statement;
21  friend class EcalCondDBInterface;
22 
24  _profiling = false;
25  m_env = nullptr;
26  m_conn = nullptr;
27  m_ID = 0;
28  setClassName("LMFUnique");
29  nodebug();
30  }
31  LMFUnique(oracle::occi::Environment *env, oracle::occi::Connection *conn) {
32  _profiling = false;
33  m_ID = 0;
34  setClassName("LMFUnique");
35  nodebug();
37  }
39  _profiling = false;
40  m_ID = 0;
41  setClassName("LMFUnique");
42  nodebug();
43  setConnection(c->getEnv(), c->getConn());
44  }
45 
46  ~LMFUnique() override;
47 
48  virtual bool isValid() const { return true; }
49  virtual bool isValid() { return true; }
50  virtual bool exists();
51 
52  // int getID() { return m_ID; }
54  int getID() const { return m_ID; }
55  int getInt(std::string fieldname) const;
57  std::string getClassName() const { return m_className; }
58  std::string getString(std::string fieldname) const;
59 
60  int fetchID() noexcept(false) override;
61 
62  LMFUnique &setString(std::string key, std::string value);
63  LMFUnique &setInt(std::string key, int value);
64  void attach(std::string name, LMFUnique *u);
65  void setByID(int id) noexcept(false) override;
66 
67  virtual void dump() const;
68  virtual void dump(int n) const;
69 
70  inline void debug() { m_debug = 1; }
71  inline void nodebug() { m_debug = 0; }
72 
73  virtual boost::ptr_list<LMFUnique> fetchAll() const noexcept(false);
74 
75  virtual bool operator<(const LMFUnique &r) { return (m_ID < r.m_ID); }
76  virtual bool operator<=(const LMFUnique &r) { return (m_ID <= r.m_ID); }
77  void startProfiling() { _profiling = true; }
78  void stopProfiling() { _profiling = false; }
79 
80 private:
81  virtual std::string writeDBSql(Statement *stmt) { return ""; }
82  virtual std::string fetchIdSql(Statement *stmt) { return ""; }
83  virtual std::string fetchAllSql(Statement *stmt) const;
84  virtual std::string setByIDSql(Statement *stmt, int id) { return ""; }
85 
86  virtual void fetchParentIDs() {}
87  virtual LMFUnique *createObject() const;
88 
89 protected:
90  virtual void getParameters(ResultSet *rset) {}
91  virtual int writeDB() noexcept(false);
92  virtual int writeForeignKeys() noexcept(false);
93  virtual void setClassName(std::string s) { m_className = s; }
94 
96  char m_debug;
97  // this is a map of string fields and their values
98  std::map<std::string, std::string> m_stringFields;
99  // this is a map of int fields and their values
100  std::map<std::string, int> m_intFields;
101  // this is a map of objects related to this by a foreign key
102  std::map<std::string, LMFUnique *> m_foreignKeys;
104 };
105 
106 #endif
LMFUnique::setClassName
virtual void setClassName(std::string s)
Definition: LMFUnique.h:93
LMFUnique::m_foreignKeys
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:102
EcalCondDBInterface
Definition: EcalCondDBInterface.h:37
IUniqueDBObject::m_ID
int m_ID
Definition: IUniqueDBObject.h:18
funct::false
false
Definition: Factorize.h:34
LMFUnique::setByID
void setByID(int id) noexcept(false) override
Definition: LMFUnique.cc:267
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
LMFUnique::operator<=
virtual bool operator<=(const LMFUnique &r)
Definition: LMFUnique.h:76
LMFUnique::writeDBSql
virtual std::string writeDBSql(Statement *stmt)
Definition: LMFUnique.h:81
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
LMFUnique::m_className
std::string m_className
Definition: LMFUnique.h:95
LMFUnique::setInt
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:31
LMFUnique::setByIDSql
virtual std::string setByIDSql(Statement *stmt, int id)
Definition: LMFUnique.h:84
LMFUnique::writeDB
virtual int writeDB() noexcept(false)
Definition: LMFUnique.cc:316
LMFUnique::getInt
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:187
watchdog.const
const
Definition: watchdog.py:83
LMFUnique::fetchAll
virtual boost::ptr_list< LMFUnique > fetchAll() const noexcept(false)
Definition: LMFUnique.cc:61
LMFUnique::m_debug
char m_debug
Definition: LMFUnique.h:96
EcalDBConnection::stmt
oracle::occi::Statement * stmt
Definition: EcalDBConnection.h:73
Utilities.operator
operator
Definition: Utilities.py:24
LMFUnique::isValid
virtual bool isValid()
Definition: LMFUnique.h:49
LMFUnique::writeForeignKeys
virtual int writeForeignKeys() noexcept(false)
Definition: LMFUnique.cc:302
LMFUnique::m_intFields
std::map< std::string, int > m_intFields
Definition: LMFUnique.h:100
alignCSCRings.s
s
Definition: alignCSCRings.py:92
LMFUnique::dump
virtual void dump() const
Definition: LMFUnique.cc:104
LMFUnique::LMFUnique
LMFUnique(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: LMFUnique.h:31
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
LMFUnique::createObject
virtual LMFUnique * createObject() const
Definition: LMFUnique.cc:173
LMFUnique::isValid
virtual bool isValid() const
Definition: LMFUnique.h:48
LMFUnique::fetchParentIDs
virtual void fetchParentIDs()
Definition: LMFUnique.h:86
OrderedSet.t
t
Definition: OrderedSet.py:90
IUniqueDBObject
Definition: IUniqueDBObject.h:11
Tm
Definition: Tm.h:13
LMFUnique::fetchIdSql
virtual std::string fetchIdSql(Statement *stmt)
Definition: LMFUnique.h:82
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
web.browse_db.env
env
Definition: browse_db.py:18
LMFUnique::fetchID
int fetchID() noexcept(false) override
Definition: LMFUnique.cc:197
LMFUnique::LMFUnique
LMFUnique(EcalDBConnection *c)
Definition: LMFUnique.h:38
IUniqueDBObject.h
LMFUnique::getClassName
std::string getClassName() const
Definition: LMFUnique.h:57
LMFUnique::attach
void attach(std::string name, LMFUnique *u)
Definition: LMFUnique.cc:48
EcalDBConnection.h
LMFUnique::getString
std::string getString(std::string fieldname) const
Definition: LMFUnique.cc:178
LMFUnique::~LMFUnique
~LMFUnique() override
Definition: LMFUnique.cc:7
Tm.h
value
Definition: value.py:1
LMFUnique::_profiling
bool _profiling
Definition: LMFUnique.h:103
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
LMFUnique::getClassName
std::string getClassName()
Definition: LMFUnique.h:56
LMFUnique::LMFUnique
LMFUnique()
Definition: LMFUnique.h:23
alignCSCRings.r
r
Definition: alignCSCRings.py:93
LMFUnique::startProfiling
void startProfiling()
Definition: LMFUnique.h:77
std
Definition: JetResolutionObject.h:76
LMFUnique::getID
int getID() const
Definition: LMFUnique.h:54
IDBObject::setConnection
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
LMFUnique::Statement
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
LMFUnique::m_stringFields
std::map< std::string, std::string > m_stringFields
Definition: LMFUnique.h:98
LMFUnique::exists
virtual bool exists()
Definition: LMFUnique.cc:158
LMFUnique::setString
LMFUnique & setString(std::string key, std::string value)
Definition: LMFUnique.cc:14
Oracle.h
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
LMFUnique::sequencePostfix
std::string sequencePostfix(const Tm &t)
Definition: LMFUnique.cc:9
LMFUnique::stopProfiling
void stopProfiling()
Definition: LMFUnique.h:78
LMFUnique::debug
void debug()
Definition: LMFUnique.h:70
LMFUnique::getParameters
virtual void getParameters(ResultSet *rset)
Definition: LMFUnique.h:90
LMFUnique::nodebug
void nodebug()
Definition: LMFUnique.h:71
LMFUnique
Definition: LMFUnique.h:17
crabWrapper.key
key
Definition: crabWrapper.py:19
LMFUnique::fetchAllSql
virtual std::string fetchAllSql(Statement *stmt) const
Definition: LMFUnique.cc:167
EcalDBConnection
Definition: EcalDBConnection.h:15
LMFUnique::ResultSet
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:19