Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:53

0001 #ifndef IDBOBJECT_H
0002 #define IDBOBJECT_H
0003 
0004 #include <stdexcept>
0005 #include "OnlineDB/Oracle/interface/Oracle.h"
0006 
0007 // XXX remove later
0008 #include <iostream>
0009 
0010 /**
0011  *  Abstract base class for objects storable in the database
0012  */
0013 class IDBObject {
0014 public:
0015   // give the interface class permission to use the functions
0016   friend class EcalCondDBInterface;
0017 
0018   static int const ECALDB_NROWS = 1024;
0019 
0020   virtual ~IDBObject() {}
0021 
0022   // Sets the connection
0023   inline void setConnection(oracle::occi::Environment* env, oracle::occi::Connection* conn) {
0024     m_env = env;
0025     m_conn = conn;
0026   }
0027 
0028   inline oracle::occi::Environment* getEnv() const { return m_env; }
0029   inline oracle::occi::Connection* getConn() const { return m_conn; }
0030 
0031 protected:
0032   // Database connection to use
0033   oracle::occi::Environment* m_env;
0034   oracle::occi::Connection* m_conn;
0035 
0036   void checkConnection() const noexcept(false) {
0037     if (m_conn == nullptr) {
0038       throw std::runtime_error("ERROR:  Connection was not set");
0039     }
0040   }
0041 };
0042 
0043 #endif