00001 #ifndef DBIRESULTAGG_H 00002 #define DBIRESULTAGG_H 00003 00004 /** 00005 * 00006 * 00007 * 00008 * \class TDbiResultSetAgg 00009 * 00010 * 00011 * \brief ResultAgg is a concrete sub-class of TDbiResultSet. 00012 * 00013 * <b>Concept</b> ResultAgg is a concrete sub-class of 00014 * TDbiResultSet that represents a single database query for either:- 00015 * 00016 * 1) A specific context with aggregated data (i.e. rows 00017 * with AggNo != -1) 00018 * 00019 * or:- 00020 * 00021 * 2) Any extended context query, even if that only produces 00022 * a single row of unaggregated data. 00023 * 00024 * The table is indexed using the index returned by 00025 * TDbiTableRow::GetIndex which can be overridden by concrete 00026 * subclasses. 00027 * 00028 * <b>Purpose</b> To present the user with a single logical table even 00029 * though the component parts may held in multiple TDbiResultSets and 00030 * be loaded by separate I/O operations. 00031 * 00032 * Contact: A.Finch@lancaster.ac.uk 00033 * 00034 * 00035 */ 00036 00037 #include <string> 00038 using std::string; 00039 #include <vector> 00040 00041 #include "TDbiResultSet.hxx" 00042 00043 class TDbiCache; 00044 class TDbiTDbiBinaryFile; 00045 class TDbiDBProxy; 00046 class TDbiInRowStream; 00047 class TDbiTableRow; 00048 class TDbiValidityRecBuilder; 00049 00050 class TDbiResultSetAgg : public TDbiResultSet 00051 { 00052 00053 00054 public: 00055 00056 // Only some Satisfies methods are overriden so include base class ones. 00057 using TDbiResultSet::Satisfies; 00058 00059 // Constructors and destructors. 00060 TDbiResultSetAgg(const string& tableName = "Unknown", 00061 const TDbiTableRow* tableRow = 0, 00062 TDbiCache* cache = 0, 00063 const TDbiValidityRecBuilder* vrecBuilder = 0, 00064 const TDbiDBProxy* proxy=0, 00065 const string& sqlQualifiers = "" ); 00066 virtual ~TDbiResultSetAgg(); 00067 00068 // State testing member functions 00069 00070 virtual TDbiResultKey* CreateKey() const; 00071 virtual UInt_t GetNumAggregates() const { 00072 return 1 + fResults.size(); }; 00073 virtual UInt_t GetNumRows() const { 00074 return fSize; } 00075 virtual const TDbiTableRow* GetTableRow(UInt_t row) const; 00076 virtual const TDbiValidityRec& GetValidityRec( 00077 const TDbiTableRow* row=0) const; 00078 00079 // State changing member functions. 00080 00081 virtual Bool_t Satisfies(const string& sqlQualifiers); 00082 virtual void Streamer(TDbiBinaryFile& bf); 00083 00084 00085 private: 00086 00087 // Data members 00088 00089 /// Array of TDbiResultSets (vector<TDbiResultSet*>). 00090 /// The array index is NOT the aggregate number; it simply matches 00091 /// the rows are supplied by the TDbiValidityRecBuilder with first 00092 /// row of TDbiValidityRecBuilder excluded i.e. row n of builder 00093 /// creates a TDbiResultSet pointed to by fResults[n-1]; 00094 std::vector<const TDbiResultSet*> fResults; 00095 00096 /// Look-up: Row no. -> TableRow 00097 std::vector<const TDbiTableRow*> fRowKeys; 00098 00099 /// Current set size. 00100 UInt_t fSize; 00101 00102 ClassDef(TDbiResultSetAgg,0) // Results table of aggregated data. 00103 00104 }; 00105 00106 00107 00108 #endif // DBIRESULTAGG_H 00109