CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/OnlineDB/EcalCondDB/interface/IDBObject.h

Go to the documentation of this file.
00001 #ifndef IDBOBJECT_H
00002 #define IDBOBJECT_H
00003 
00004 #include <stdexcept>
00005 #include "OnlineDB/Oracle/interface/Oracle.h"
00006 
00007 // XXX remove later
00008 #include <iostream>
00009 
00013 class IDBObject {
00014  public:
00015   // give the interface class permission to use the functions
00016   friend class EcalCondDBInterface;
00017 
00018   static int const ECALDB_NROWS=1024;
00019   
00020   virtual ~IDBObject() {}
00021 
00022   // Sets the connection
00023   inline void setConnection(oracle::occi::Environment* env, oracle::occi::Connection* conn) 
00024     {
00025       m_env = env;
00026       m_conn = conn;
00027     }
00028 
00029   inline oracle::occi::Environment * getEnv() const {
00030     return m_env;
00031   }
00032   inline oracle::occi::Connection * getConn() const {
00033     return m_conn;
00034   }
00035 
00036  protected:
00037   // Database connection to use
00038   oracle::occi::Environment* m_env;
00039   oracle::occi::Connection* m_conn;
00040   
00041   void checkConnection() const
00042     throw(std::runtime_error)
00043     {
00044       if (m_conn == NULL) {
00045         throw std::runtime_error("ERROR:  Connection was not set");
00046       }
00047     }
00048 };
00049 
00050 #endif