00001 #ifndef COND_DBCommon_GenericRef_H 00002 #define COND_DBCommon_GenericRef_H 00003 #include <string> 00004 #include <typeinfo> 00005 #include "DataSvc/RefBase.h" 00006 namespace pool{ 00007 class IDataSvc; 00008 } 00009 namespace cond{ 00010 class PoolTransaction; 00011 /* 00012 adapter to pool::RefBase defines ref interface 00013 **/ 00014 class GenericRef{ 00015 public: 00016 // default constructor 00017 GenericRef(); 00018 explicit GenericRef( cond::PoolTransaction& pooldb ); 00019 // from externalized token 00020 GenericRef( cond::PoolTransaction& pooldb, 00021 const std::string& token); 00022 // from externalized token and class name 00023 GenericRef( cond::PoolTransaction& pooldb, 00024 const std::string& token, 00025 const std::string& className); 00026 // from type info 00027 GenericRef( cond::PoolTransaction& pooldb, 00028 const std::string& token, 00029 const std::type_info& refType ); 00030 // copy constructor 00031 GenericRef(const GenericRef& aCopy); 00032 /* Query interface 00033 **/ 00034 // externalised token 00035 const std::string token() const; 00036 // object name 00037 std::string className() const; 00038 // container name 00039 std::string containerName() const; 00040 /* update operations 00041 **/ 00042 // register for write 00043 void markWrite(const std::string& container); 00044 // register for update 00045 void markUpdate(); 00046 // register for delete 00047 void markDelete(); 00048 // RefBase assignment operator 00049 GenericRef& operator=(const GenericRef&); 00050 // default copy operator (defined copy policy) 00051 //void copy(const RefBase&); 00052 // copy the entire RefBase content, with type checking 00053 //void copyDeep(const RefBase&); 00054 // copy only the object pointer, with type checking 00055 //void copyShallow(const RefBase&); 00056 // export to another destination db; 00057 std::string exportTo( cond::PoolTransaction& destdb ); 00058 // reset the whole ref content 00059 void clear(); 00060 // explicitly delete the object pointee 00061 void reset(); 00062 // destructor 00063 virtual ~GenericRef(); 00064 protected: 00065 pool::IDataSvc* m_datasvc; 00066 pool::Placement* m_place; 00067 // wrap pool smart pointer 00068 pool::RefBase m_data; 00069 }; 00070 } 00071 #endif