00001 #ifndef DBIWRT_H 00002 #define DBIWRT_H 00003 00004 #include "DatabaseInterface/DbiWriter.h" 00005 #include "DybDbi/DbiCtx.h" 00006 #include <string> 00007 using namespace std ; 00008 00009 /* 00010 Wrapper for DbiWriter<T> providing 00011 00012 * controlled record of the context used 00013 * access by default context 00014 * access by string context representation 00015 00016 */ 00017 00018 template <class T> class DbiWrt 00019 { 00020 public: 00021 DbiWrt(); // default context 00022 DbiWrt(const DbiCtx& ctx); // ctx is copy ctored in 00023 DbiWrt(const char* wctx); // ctx ctored in-situ from string 00024 00025 DbiWrt(const DbiWrt<T>& other); // copy ctor 00026 DbiWrt<T>* Clone(); 00027 00028 00029 virtual ~DbiWrt(); 00030 00031 //DbiWrt<T>* Clone(); 00032 const char* GetName(); 00033 const DbiCtx& GetCtx(); 00034 00035 const DbiWriter<T>* GetWriter(); 00036 void Write( T* instance ); 00037 Bool_t Close(const char* filepath=NULL); // close the writer ... sending to DB 00038 00039 DbiTableProxy& TableProxy(); 00040 00041 00042 // for debugging only 00043 Bool_t CanOutput(Bool_t reportErrors=kTRUE); 00044 Bool_t IsOpen(Bool_t reportErrors=kTRUE); 00045 00046 private: 00047 void Delete(); 00048 void MakeWriter(); 00049 00050 string m_name ; 00051 DbiCtx m_ctx ; 00052 DbiWriter<T>* m_wrt ; 00053 00054 }; 00055 00056 #endif