#ifndef DBIRESULTSETHANDLE_H // this will switch users code from using IDbiResultSetHandle to COMET::IDbiResultSetHandle #define USE_NEW_DBI_API #define DBIRESULTSETHANDLE_H /** * * $Id: IDbiResultSetHandle.hxx,v 1.1 2011/01/18 05:49:20 finch Exp $ * * \class COMET::IDbiResultSetHandle * * * \brief * Concept Templated class COMET::of pointers to Result objects. * ResultHandle objects are lightweight and provide type safe access * to a specific table. * * \brief * Purpose ResultHandles are the primary application interface * to the IDbi. Users instantiate ResultHandles with the information * necessary define a table query and then interrogate the object * for the results. * * Contact: A.Finch@lancaster.ac.uk * * */ #include #include using std::string; #include "IDbi.hxx" #include "IDbiResultSet.hxx" #include "IDbiDatabaseManager.hxx" //Only for cleaner #include "IDbiValidityRec.hxx" #include "IVldContext.hxx" namespace COMET { class IDbiResultSet; class IDbiResultKey; class IDbiSqlContext; class IDbiTableProxy; } namespace COMET { template class IDbiResultSetHandle { public: // Constructors and destructors. IDbiResultSetHandle(); IDbiResultSetHandle(const IDbiResultSetHandle& that); IDbiResultSetHandle(const COMET::IVldContext& vc, IDbi::Task task = IDbi::kDefaultTask, IDbi::AbortTest abortTest = IDbi::kTableMissing, Bool_t findFullTimeWindow = true); IDbiResultSetHandle(const string& tableName, const COMET::IVldContext& vc, IDbi::Task task = IDbi::kDefaultTask, IDbi::AbortTest abortTest = IDbi::kTableMissing, Bool_t findFullTimeWindow = true); IDbiResultSetHandle(const string& tableName, const IDbiSqlContext& context, const IDbi::Task& task = IDbi::kAnyTask, const string& data = "", const string& fillOpts = "", IDbi::AbortTest abortTest = IDbi::kTableMissing); IDbiResultSetHandle(const string& tableName, const IDbiValidityRec& vrec, IDbi::AbortTest abortTest = IDbi::kTableMissing); IDbiResultSetHandle(const string& tableName, UInt_t seqNo, UInt_t dbNo, IDbi::AbortTest abortTest = IDbi::kTableMissing); virtual ~IDbiResultSetHandle(); // State testing member functions const IDbiResultKey* GetKey() const; UInt_t GetNumRows() const; const IDbiResultSet* GetResult() const { return fResult; } Int_t GetResultID() const; const T* GetRow(UInt_t rowNum) const; const T* GetRowByIndex(UInt_t index) const; const IDbiValidityRec* GetValidityRec(const IDbiTableRow* row=0) const; IDbiTableProxy& TableProxy() const; Bool_t ResultsFromDb() const; static IDbiTableProxy& GetTableProxy(); static IDbiTableProxy& GetTableProxy(const string& tableName); // State changing member functions UInt_t NextQuery(Bool_t forwards = kTRUE); UInt_t NewQuery(COMET::IVldContext vc, IDbi::Task task=0, Bool_t findFullTimeWindow = true); UInt_t NewQuery(const IDbiSqlContext& context, const IDbi::Task& task = 0, const string& data = "", const string& fillOpts = ""); UInt_t NewQuery(const IDbiValidityRec& vrec); UInt_t NewQuery(UInt_t seqNo,UInt_t dbNo); private: void Disconnect(); void SetContext(const IDbiValidityRec& vrec); Bool_t ApplyAbortTest(); // 12 Jun 2002: Disabled (not implemented) assignment // Data members /// Test which if failed triggers abort. IDbi::AbortTest fAbortTest; /// Proxy for associated database table. IDbiTableProxy& fTableProxy; // State from last query. /// Pointer to query result. May be zero! const IDbiResultSet* fResult; /// from query context. COMET::DbiDetector::Detector_t fDetType; /// from query context. COMET::DbiSimFlag::SimFlag_t fSimType; #ifndef __CINT__ // Hide map from CINT; it complains about missing Streamer() etc. static std::map fgNameToProxy; #endif // __CINT__ static IDbiTableProxy* fgTableProxy; ClassDefT(IDbiResultSetHandle,0) // ResultHandle for specific database table. }; }; ClassDefT2(IDbiResultSetHandle,T) #endif // DBIRESULTSETHANDLE_H