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 <algorithm>
9 #include <cstring>
10 #include <iostream>
11 #include <list>
12 #include <map>
13 #include <memory>
14 #include <stdexcept>
15 
20 
21 class LMFUnique : public IUniqueDBObject {
22 public:
23  typedef oracle::occi::ResultSet ResultSet;
24  typedef oracle::occi::Statement Statement;
25  friend class EcalCondDBInterface;
26 
28  _profiling = false;
29  m_env = nullptr;
30  m_conn = nullptr;
31  m_ID = 0;
32  setClassName("LMFUnique");
33  nodebug();
34  }
35  LMFUnique(oracle::occi::Environment *env, oracle::occi::Connection *conn) {
36  _profiling = false;
37  m_ID = 0;
38  setClassName("LMFUnique");
39  nodebug();
41  }
43  _profiling = false;
44  m_ID = 0;
45  setClassName("LMFUnique");
46  nodebug();
47  setConnection(c->getEnv(), c->getConn());
48  }
49 
50  ~LMFUnique() override;
51 
52  virtual bool isValid() const { return true; }
53  virtual bool isValid() { return true; }
54  virtual bool exists();
55 
56  // int getID() { return m_ID; }
58  int getID() const { return m_ID; }
59  int getInt(std::string fieldname) const;
61  std::string getClassName() const { return m_className; }
62  std::string getString(std::string fieldname) const;
63 
64  int fetchID() noexcept(false) override;
65 
66  LMFUnique &setString(std::string key, std::string value);
67  LMFUnique &setInt(std::string key, int value);
68  void attach(std::string name, LMFUnique *u);
69  void setByID(int id) noexcept(false) override;
70 
71  virtual void dump() const;
72  virtual void dump(int n) const;
73 
74  inline void debug() { m_debug = 1; }
75  inline void nodebug() { m_debug = 0; }
76 
77  virtual std::list<std::unique_ptr<LMFUnique>> fetchAll() const noexcept(false);
78 
79  virtual bool operator<(const LMFUnique &r) { return (m_ID < r.m_ID); }
80  virtual bool operator<=(const LMFUnique &r) { return (m_ID <= r.m_ID); }
81  void startProfiling() { _profiling = true; }
82  void stopProfiling() { _profiling = false; }
83 
84 private:
85  virtual std::string writeDBSql(Statement *stmt) { return ""; }
86  virtual std::string fetchIdSql(Statement *stmt) { return ""; }
87  virtual std::string fetchAllSql(Statement *stmt) const;
88  virtual std::string setByIDSql(Statement *stmt, int id) { return ""; }
89 
90  virtual void fetchParentIDs() {}
91  virtual LMFUnique *createObject() const;
92 
93 protected:
94  virtual void getParameters(ResultSet *rset) {}
95  virtual int writeDB() noexcept(false);
96  virtual int writeForeignKeys() noexcept(false);
97  virtual void setClassName(std::string s) { m_className = s; }
98 
100  char m_debug;
101  // this is a map of string fields and their values
102  std::map<std::string, std::string> m_stringFields;
103  // this is a map of int fields and their values
104  std::map<std::string, int> m_intFields;
105  // this is a map of objects related to this by a foreign key
106  std::map<std::string, LMFUnique *> m_foreignKeys;
108 };
109 
110 #endif
LMFUnique::setClassName
virtual void setClassName(std::string s)
Definition: LMFUnique.h:97
LMFUnique::m_foreignKeys
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:106
EcalCondDBInterface
Definition: EcalCondDBInterface.h:37
IUniqueDBObject::m_ID
int m_ID
Definition: IUniqueDBObject.h:18
funct::false
false
Definition: Factorize.h:29
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:80
LMFUnique::writeDBSql
virtual std::string writeDBSql(Statement *stmt)
Definition: LMFUnique.h:85
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
LMFUnique::m_className
std::string m_className
Definition: LMFUnique.h:99
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:88
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::m_debug
char m_debug
Definition: LMFUnique.h:100
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:53
LMFUnique::writeForeignKeys
virtual int writeForeignKeys() noexcept(false)
Definition: LMFUnique.cc:302
LMFUnique::m_intFields
std::map< std::string, int > m_intFields
Definition: LMFUnique.h:104
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:35
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:52
LMFUnique::fetchParentIDs
virtual void fetchParentIDs()
Definition: LMFUnique.h:90
IUniqueDBObject
Definition: IUniqueDBObject.h:11
Tm
Definition: Tm.h:13
LMFUnique::fetchIdSql
virtual std::string fetchIdSql(Statement *stmt)
Definition: LMFUnique.h:86
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:42
IUniqueDBObject.h
LMFUnique::getClassName
std::string getClassName() const
Definition: LMFUnique.h:61
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:107
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
LMFUnique::getClassName
std::string getClassName()
Definition: LMFUnique.h:60
LMFUnique::LMFUnique
LMFUnique()
Definition: LMFUnique.h:27
alignCSCRings.r
r
Definition: alignCSCRings.py:93
LMFUnique::fetchAll
virtual std::list< std::unique_ptr< LMFUnique > > fetchAll() const noexcept(false)
Definition: LMFUnique.cc:61
LMFUnique::startProfiling
void startProfiling()
Definition: LMFUnique.h:81
std
Definition: JetResolutionObject.h:76
LMFUnique::getID
int getID() const
Definition: LMFUnique.h:58
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:24
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:102
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:82
LMFUnique::debug
void debug()
Definition: LMFUnique.h:74
LMFUnique::getParameters
virtual void getParameters(ResultSet *rset)
Definition: LMFUnique.h:94
LMFUnique::nodebug
void nodebug()
Definition: LMFUnique.h:75
LMFUnique
Definition: LMFUnique.h:21
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
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:23