CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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();
40  setConnection(env, conn);
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
std::string m_className
Definition: LMFUnique.h:99
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:31
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
int getID() const
Definition: LMFUnique.h:58
const edm::EventSetup & c
void nodebug()
Definition: LMFUnique.h:75
virtual std::list< std::unique_ptr< LMFUnique > > fetchAll() const noexcept(false)
Definition: LMFUnique.cc:61
bool _profiling
Definition: LMFUnique.h:107
std::string sequencePostfix(const Tm &t)
Definition: LMFUnique.cc:9
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:23
virtual void setClassName(std::string s)
Definition: LMFUnique.h:97
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:106
virtual LMFUnique * createObject() const
Definition: LMFUnique.cc:173
virtual void dump() const
Definition: LMFUnique.cc:104
oracle::occi::Environment * getEnv() const
LMFUnique()
Definition: LMFUnique.h:27
virtual std::string setByIDSql(Statement *stmt, int id)
Definition: LMFUnique.h:88
oracle::occi::Connection * getConn() const
void setByID(int id) noexcept(false) override
Definition: LMFUnique.cc:267
virtual bool exists()
Definition: LMFUnique.cc:158
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:187
virtual std::string writeDBSql(Statement *stmt)
Definition: LMFUnique.h:85
~LMFUnique() override
Definition: LMFUnique.cc:7
std::map< std::string, std::string > m_stringFields
Definition: LMFUnique.h:102
void stopProfiling()
Definition: LMFUnique.h:82
#define override(base_class)
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
tuple key
prepare the HTCondor submission files and eventually submit them
virtual bool operator<=(const LMFUnique &r)
Definition: LMFUnique.h:80
LMFUnique(EcalDBConnection *c)
Definition: LMFUnique.h:42
LMFUnique(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: LMFUnique.h:35
LMFUnique & setString(std::string key, std::string value)
Definition: LMFUnique.cc:14
std::string getClassName() const
Definition: LMFUnique.h:61
virtual int writeDB() noexcept(false)
Definition: LMFUnique.cc:316
virtual std::string fetchIdSql(Statement *stmt)
Definition: LMFUnique.h:86
void startProfiling()
Definition: LMFUnique.h:81
virtual bool isValid()
Definition: LMFUnique.h:53
virtual bool isValid() const
Definition: LMFUnique.h:52
virtual std::string fetchAllSql(Statement *stmt) const
Definition: LMFUnique.cc:167
tuple conn
Definition: getInfo.py:9
oracle::occi::Statement * stmt
std::string getString(std::string fieldname) const
Definition: LMFUnique.cc:178
virtual int writeForeignKeys() noexcept(false)
Definition: LMFUnique.cc:302
char m_debug
Definition: LMFUnique.h:100
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
virtual void fetchParentIDs()
Definition: LMFUnique.h:90
std::string getClassName()
Definition: LMFUnique.h:60
void attach(std::string name, LMFUnique *u)
Definition: LMFUnique.cc:48
void debug()
Definition: LMFUnique.h:74
Definition: Tm.h:13
int fetchID() noexcept(false) override
Definition: LMFUnique.cc:197
virtual void getParameters(ResultSet *rset)
Definition: LMFUnique.h:94
std::map< std::string, int > m_intFields
Definition: LMFUnique.h:104