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 using namespace std; 00010 00014 class IDBObject { 00015 public: 00016 // give the interface class permission to use the functions 00017 friend class EcalCondDBInterface; 00018 00019 static int const ECALDB_NROWS=1000; 00020 00021 virtual ~IDBObject() {} 00022 00023 // Sets the connection 00024 inline void setConnection(oracle::occi::Environment* env, oracle::occi::Connection* conn) 00025 { 00026 m_env = env; 00027 m_conn = conn; 00028 } 00029 00030 00031 00032 00033 protected: 00034 // Database connection to use 00035 oracle::occi::Environment* m_env; 00036 oracle::occi::Connection* m_conn; 00037 00038 void checkConnection() const 00039 throw(std::runtime_error) 00040 { 00041 if (m_conn == NULL) { 00042 throw std::runtime_error("ERROR: Connection was not set"); 00043 } 00044 } 00045 }; 00046 00047 #endif