CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/OnlineDB/EcalCondDB/interface/LMFUnique.h

Go to the documentation of this file.
00001 #ifndef LMFUNIQUE_H
00002 #define LMFUNIQUE_H
00003 
00004 /*
00005  Copyright (c) Giovanni.Organtini@roma1.infn.it 2010
00006  */
00007 
00008 #include <stdexcept>
00009 #include <iostream>
00010 #include <map>
00011 #include <boost/ptr_container/ptr_list.hpp>
00012 #include "OnlineDB/EcalCondDB/interface/Tm.h"
00013 #include "OnlineDB/EcalCondDB/interface/IUniqueDBObject.h"
00014 #include "OnlineDB/Oracle/interface/Oracle.h"
00015 #include "OnlineDB/EcalCondDB/interface/EcalDBConnection.h"
00016 
00017 class LMFUnique: public IUniqueDBObject {
00018  public:
00019   typedef oracle::occi::ResultSet ResultSet;
00020   typedef oracle::occi::Statement Statement;
00021   friend class EcalCondDBInterface;
00022 
00023   LMFUnique() { 
00024     _profiling = false;
00025     m_env = NULL;
00026     m_conn = NULL;
00027     m_ID = 0;
00028     setClassName("LMFUnique"); nodebug(); 
00029   }
00030   LMFUnique(oracle::occi::Environment* env,
00031             oracle::occi::Connection* conn) {
00032     _profiling = false;
00033     m_ID = 0;
00034     setClassName("LMFUnique"); nodebug(); 
00035     setConnection(env, conn);
00036   }
00037   LMFUnique(EcalDBConnection *c) {
00038     _profiling = false;
00039     m_ID = 0;
00040     setClassName("LMFUnique"); nodebug(); 
00041     setConnection(c->getEnv(), c->getConn());
00042   }
00043 
00044   virtual ~LMFUnique();
00045 
00046   virtual bool isValid() const { return true; }
00047   virtual bool exists();
00048 
00049   //  int getID()       { return m_ID; } 
00050   std::string sequencePostfix(Tm t);
00051   int getID() const { return m_ID; } 
00052   int getInt(std::string fieldname) const;
00053   std::string getClassName() { return m_className; }
00054   std::string getClassName() const { return m_className; }
00055   std::string getString(std::string fieldname) const;
00056 
00057   int fetchID() throw(std::runtime_error); 
00058 
00059   LMFUnique& setString(std::string key, std::string value);
00060   LMFUnique& setInt(std::string key, int value);
00061   void attach(std::string name, LMFUnique *u);
00062   void setByID(int id) throw(std::runtime_error);
00063 
00064   virtual void dump() const ;
00065   virtual void dump(int n) const ;
00066 
00067   inline void debug() { m_debug = 1; }
00068   inline void nodebug() { m_debug = 0; }
00069 
00070   virtual boost::ptr_list<LMFUnique> fetchAll() const 
00071     throw (std::runtime_error);
00072 
00073   virtual bool operator<(const LMFUnique &r) {
00074     return (m_ID < r.m_ID);
00075   }
00076   virtual bool operator<=(const LMFUnique &r) {
00077     return (m_ID <= r.m_ID);
00078   }
00079   void startProfiling() { _profiling = true; }
00080   void stopProfiling() { _profiling = false; }
00081 
00082  private:
00083   virtual std::string writeDBSql(Statement *stmt) { return ""; } 
00084   virtual std::string fetchIdSql(Statement *stmt) { return ""; }
00085   virtual std::string fetchAllSql(Statement *stmt) const;
00086   virtual std::string setByIDSql(Statement *stmt, 
00087                                  int id) { return ""; }
00088 
00089   virtual void getParameters(ResultSet *rset) {}
00090   virtual void fetchParentIDs() {}
00091   virtual LMFUnique * createObject() const;
00092 
00093  protected:
00094   virtual int writeDB() throw(std::runtime_error);
00095   virtual int writeForeignKeys() throw(std::runtime_error);
00096   virtual void setClassName(std::string s) { m_className = s; }
00097 
00098   std::string m_className;
00099   char m_debug;
00100   // this is a map of string fields and their values
00101   std::map<std::string, std::string> m_stringFields;   
00102   // this is a map of int fields and their values
00103   std::map<std::string, int> m_intFields;
00104   // this is a map of objects related to this by a foreign key
00105   std::map<std::string, LMFUnique*> m_foreignKeys;
00106   bool _profiling;
00107 };
00108 
00109 #endif