CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 <stdexcept>
9 #include <iostream>
10 #include <map>
11 #include <boost/ptr_container/ptr_list.hpp>
16 
17 class LMFUnique: public IUniqueDBObject {
18  public:
20  typedef oracle::occi::Statement Statement;
21  friend class EcalCondDBInterface;
22 
23  LMFUnique() {
24  _profiling = false;
25  m_env = NULL;
26  m_conn = NULL;
27  m_ID = 0;
28  setClassName("LMFUnique"); nodebug();
29  }
30  LMFUnique(oracle::occi::Environment* env,
31  oracle::occi::Connection* conn) {
32  _profiling = false;
33  m_ID = 0;
34  setClassName("LMFUnique"); nodebug();
35  setConnection(env, conn);
36  }
38  _profiling = false;
39  m_ID = 0;
40  setClassName("LMFUnique"); nodebug();
41  setConnection(c->getEnv(), c->getConn());
42  }
43 
44  virtual ~LMFUnique();
45 
46  virtual bool isValid() const { return true; }
47  virtual bool isValid() { return true; }
48  virtual bool exists();
49 
50  // int getID() { return m_ID; }
52  int getID() const { return m_ID; }
53  int getInt(std::string fieldname) const;
55  std::string getClassName() const { return m_className; }
56  std::string getString(std::string fieldname) const;
57 
58  int fetchID() noexcept(false);
59 
60  LMFUnique& setString(std::string key, std::string value);
61  LMFUnique& setInt(std::string key, int value);
62  void attach(std::string name, LMFUnique *u);
63  void setByID(int id) noexcept(false);
64 
65  virtual void dump() const ;
66  virtual void dump(int n) const ;
67 
68  inline void debug() { m_debug = 1; }
69  inline void nodebug() { m_debug = 0; }
70 
71  virtual boost::ptr_list<LMFUnique> fetchAll() const noexcept(false);
72 
73  virtual bool operator<(const LMFUnique &r) {
74  return (m_ID < r.m_ID);
75  }
76  virtual bool operator<=(const LMFUnique &r) {
77  return (m_ID <= r.m_ID);
78  }
79  void startProfiling() { _profiling = true; }
80  void stopProfiling() { _profiling = false; }
81 
82  private:
83  virtual std::string writeDBSql(Statement *stmt) { return ""; }
84  virtual std::string fetchIdSql(Statement *stmt) { return ""; }
85  virtual std::string fetchAllSql(Statement *stmt) const;
87  int id) { return ""; }
88 
89  virtual void getParameters(ResultSet *rset) {}
90  virtual void fetchParentIDs() {}
91  virtual LMFUnique * createObject() const;
92 
93  protected:
94  virtual int writeDB() noexcept(false);
95  virtual int writeForeignKeys() noexcept(false);
96  virtual void setClassName(std::string s) { m_className = s; }
97 
99  char m_debug;
100  // this is a map of string fields and their values
101  std::map<std::string, std::string> m_stringFields;
102  // this is a map of int fields and their values
103  std::map<std::string, int> m_intFields;
104  // this is a map of objects related to this by a foreign key
105  std::map<std::string, LMFUnique*> m_foreignKeys;
107 };
108 
109 #endif
std::string m_className
Definition: LMFUnique.h:98
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int getID() const
Definition: LMFUnique.h:52
virtual boost::ptr_list< LMFUnique > fetchAll() const noexcept(false)
Definition: LMFUnique.cc:64
void nodebug()
Definition: LMFUnique.h:69
bool _profiling
Definition: LMFUnique.h:106
#define noexcept
std::string sequencePostfix(const Tm &t)
Definition: LMFUnique.cc:10
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:19
virtual void setClassName(std::string s)
Definition: LMFUnique.h:96
#define NULL
Definition: scimark2.h:8
virtual LMFUnique * createObject() const
Definition: LMFUnique.cc:189
virtual void dump() const
Definition: LMFUnique.cc:112
oracle::occi::Environment * getEnv() const
LMFUnique()
Definition: LMFUnique.h:23
virtual std::string setByIDSql(Statement *stmt, int id)
Definition: LMFUnique.h:86
oracle::occi::Connection * getConn() const
virtual bool exists()
Definition: LMFUnique.cc:174
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:203
virtual std::string writeDBSql(Statement *stmt)
Definition: LMFUnique.h:83
void setByID(int id) noexcept(false)
Definition: LMFUnique.cc:286
oracle::occi::Connection * conn
std::map< std::string, std::string > m_stringFields
Definition: LMFUnique.h:101
void stopProfiling()
Definition: LMFUnique.h:80
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
int fetchID() noexcept(false)
Definition: LMFUnique.cc:213
virtual bool operator<=(const LMFUnique &r)
Definition: LMFUnique.h:76
LMFUnique(EcalDBConnection *c)
Definition: LMFUnique.h:37
LMFUnique(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: LMFUnique.h:30
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:105
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
LMFUnique & setString(std::string key, std::string value)
Definition: LMFUnique.cc:15
std::string getClassName() const
Definition: LMFUnique.h:55
virtual int writeDB() noexcept(false)
Definition: LMFUnique.cc:339
virtual std::string fetchIdSql(Statement *stmt)
Definition: LMFUnique.h:84
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void startProfiling()
Definition: LMFUnique.h:79
virtual bool isValid()
Definition: LMFUnique.h:47
virtual bool isValid() const
Definition: LMFUnique.h:46
virtual ~LMFUnique()
Definition: LMFUnique.cc:7
virtual std::string fetchAllSql(Statement *stmt) const
Definition: LMFUnique.cc:183
oracle::occi::Statement * stmt
std::string getString(std::string fieldname) const
Definition: LMFUnique.cc:194
virtual int writeForeignKeys() noexcept(false)
Definition: LMFUnique.cc:323
char m_debug
Definition: LMFUnique.h:99
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
volatile std::atomic< bool > shutdown_flag false
virtual void fetchParentIDs()
Definition: LMFUnique.h:90
std::string getClassName()
Definition: LMFUnique.h:54
void attach(std::string name, LMFUnique *u)
Definition: LMFUnique.cc:50
void debug()
Definition: LMFUnique.h:68
Definition: Tm.h:13
virtual void getParameters(ResultSet *rset)
Definition: LMFUnique.h:89
std::map< std::string, int > m_intFields
Definition: LMFUnique.h:103