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  Copyright (c) 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() throw(std::runtime_error);
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) throw(std::runtime_error);
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
72  throw (std::runtime_error);
73 
74  virtual bool operator<(const LMFUnique &r) {
75  return (m_ID < r.m_ID);
76  }
77  virtual bool operator<=(const LMFUnique &r) {
78  return (m_ID <= r.m_ID);
79  }
80  void startProfiling() { _profiling = true; }
81  void stopProfiling() { _profiling = false; }
82 
83  private:
84  virtual std::string writeDBSql(Statement *stmt) { return ""; }
85  virtual std::string fetchIdSql(Statement *stmt) { return ""; }
86  virtual std::string fetchAllSql(Statement *stmt) const;
88  int id) { return ""; }
89 
90  virtual void getParameters(ResultSet *rset) {}
91  virtual void fetchParentIDs() {}
92  virtual LMFUnique * createObject() const;
93 
94  protected:
95  virtual int writeDB() throw(std::runtime_error);
96  virtual int writeForeignKeys() throw(std::runtime_error);
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: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
void nodebug()
Definition: LMFUnique.h:69
bool _profiling
Definition: LMFUnique.h:107
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:19
virtual void setClassName(std::string s)
Definition: LMFUnique.h:97
#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:87
oracle::occi::Connection * getConn() const
virtual int writeDB()
Definition: LMFUnique.cc:339
virtual bool exists()
Definition: LMFUnique.cc:174
virtual int writeForeignKeys()
Definition: LMFUnique.cc:323
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:203
virtual std::string writeDBSql(Statement *stmt)
Definition: LMFUnique.h:84
void setByID(int id)
Definition: LMFUnique.cc:286
std::string sequencePostfix(Tm t)
Definition: LMFUnique.cc:10
int fetchID()
Definition: LMFUnique.cc:213
std::map< std::string, std::string > m_stringFields
Definition: LMFUnique.h:102
void stopProfiling()
Definition: LMFUnique.h:81
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
virtual bool operator<=(const LMFUnique &r)
Definition: LMFUnique.h:77
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:106
LMFUnique & setString(std::string key, std::string value)
Definition: LMFUnique.cc:15
std::string getClassName() const
Definition: LMFUnique.h:55
virtual boost::ptr_list< LMFUnique > fetchAll() const
Definition: LMFUnique.cc:64
virtual std::string fetchIdSql(Statement *stmt)
Definition: LMFUnique.h:85
string const
Definition: compareJSON.py:14
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void startProfiling()
Definition: LMFUnique.h:80
virtual bool isValid()
Definition: LMFUnique.h:47
virtual bool isValid() const
Definition: LMFUnique.h:46
virtual ~LMFUnique()
Definition: LMFUnique.cc:7
list key
Definition: combine.py:13
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
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:91
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:14
tuple conn
Definition: results_mgr.py:53
virtual void getParameters(ResultSet *rset)
Definition: LMFUnique.h:90
std::map< std::string, int > m_intFields
Definition: LMFUnique.h:104