#ifndef DBIDBPROXY_H #define DBIDBPROXY_H /** * * $Id: IDbiDBProxy.hxx,v 1.1 2011/01/18 05:49:19 finch Exp $ * * \class COMET::IDbiDBProxy * * * \brief * Concept Object to query a specific database table. * * \brief * Purpose To encapsulate the standard context query and * the management of SEQNOs and meta-data. This allows clients to * execute queries without specifying SQL. IDbiDBProxy also supports * "Extended Context" queries which provides a framework in which * clients can extended the basic query and can use SQL to fine tune * their requests. * * \brief * Uage Notes The object can be "programmed" with an SQL condition * using SetSqlCondition. If not null the string is prefixed with *"where" and used when responding to the following validity queries:- * QueryAllValidities * QueryValidity * * Contact: A.Finch@lancaster.ac.uk * * */ #include using std::string; #include #include #include "IDbi.hxx" namespace COMET { class IDbiCascader; class IDbiInRowStream; class IDbiTableMetaData; class IDbiTableProxy; class IDbiValidityRec; } namespace COMET { class IVldContext; }; namespace COMET { class IVldTimeStamp; }; namespace COMET { class IDbiDBProxy { public: #ifndef __CINT__ typedef const std::vector SeqList_t; #endif // Constructors. IDbiDBProxy(IDbiCascader& cascader, const string& tableName, const IDbiTableMetaData* metaData, const IDbiTableMetaData* metaValid, const IDbiTableProxy* tableProxy); virtual ~IDbiDBProxy(); // State testing member functions Bool_t HasEpoch() const; UInt_t GetNumDb() const; const string& GetTableName() const { return fTableName; } const IDbiTableProxy* GetTableProxy() const { return fTableProxy; } void StoreMetaData(IDbiTableMetaData& metaData) const; Bool_t TableExists(Int_t selectDbNo=-1) const; // Query (input) member functions void FindTimeBoundaries(const COMET::IVldContext& vc, const IDbi::Task& task, UInt_t dbNo, const IDbiValidityRec& lowestPriorityVrec, Bool_t resolveByCreationDate, COMET::IVldTimeStamp& start, COMET::IVldTimeStamp& end) const; IDbiInRowStream* QueryAllValidities(UInt_t dbNo,UInt_t seqNo=0) const; IDbiInRowStream* QuerySeqNo(UInt_t seqNo,UInt_t dbNo) const; #ifndef __CINT__ /// Secondary query for aggregate and extended context queries. IDbiInRowStream* QuerySeqNos(SeqList_t& seqNos, UInt_t dbNo, const string& sqlData = "", const string& fillOpts = "") const; #endif IDbiInRowStream* QueryValidity(const COMET::IVldContext& vc, const IDbi::Task& task, UInt_t dbNo) const; IDbiInRowStream* QueryValidity(const string& context, const IDbi::Task& task, UInt_t dbNo) const; IDbiInRowStream* QueryValidity(UInt_t seqNo, UInt_t dbNo) const; // Store (output) member functions Bool_t ReplaceInsertDate(const COMET::IVldTimeStamp& ts, UInt_t SeqNo, UInt_t dbNo) const; Bool_t RemoveSeqNo(UInt_t seqNo, UInt_t dbNo) const; Bool_t ReplaceSeqNo(UInt_t oldSeqNo, UInt_t newSeqNo, UInt_t dbNo) const; // State changing member functions void SetSqlCondition(const string& sql) { fSqlCondition = sql; } private: // Disabled (not implemented) copy constructor and asignment. IDbiDBProxy(const IDbiDBProxy&); COMET::IDbiDBProxy& operator=(const COMET::IDbiDBProxy&); // Data members /// Reference to one and only cascader IDbiCascader& fCascader; /// Owned by IDbiTableProxy const IDbiTableMetaData* fMetaData; /// Owned by IDbiTableProxy const IDbiTableMetaData* fMetaValid; /// Optional condition to be applied. /// See Usage Notes. string fSqlCondition; /// Table Name string fTableName; /// Owning IDbiTableProxy. const IDbiTableProxy* fTableProxy; ClassDef(IDbiDBProxy,0) // Proxy for physical database. }; }; #endif // DBIDBPROXY_H