00001 #ifndef DBIRESULTKEY 00002 #define DBIRESULTKEY 00003 00004 /** 00005 * 00006 * $Id: TDbiResultKey.hxx,v 1.1 2011/01/18 05:49:20 finch Exp $ 00007 * 00008 * \class TDbiResultKey 00009 * 00010 * 00011 * \brief 00012 * <b>Concept</b> Summarises the composition of a single TDbiResultSet. 00013 * 00014 * \brief 00015 * <b>Purpose</b> To serve as summary of a single query. 00016 * 00017 * Contact: A.Finch@lancaster.ac.uk 00018 * 00019 * 00020 */ 00021 00022 #include <list> 00023 #include <iosfwd> 00024 #include <string> 00025 00026 #include "TObject.h" 00027 00028 #include "TVldTimeStamp.hxx" 00029 00030 class TDbiResultKey; 00031 00032 std::ostream& operator<<(std::ostream& os, const TDbiResultKey& key); 00033 00034 class TDbiResultKey : public TObject 00035 { 00036 00037 public: 00038 00039 using TObject::Compare; 00040 00041 // Constructors and destructors. 00042 TDbiResultKey(const TDbiResultKey* that = 0); 00043 TDbiResultKey(std::string tableName, 00044 std::string rowName, 00045 UInt_t seqno, 00046 TVldTimeStamp ts); 00047 virtual ~TDbiResultKey(); 00048 00049 // State testing member functions 00050 std::string AsString() const; 00051 Float_t Compare(const TDbiResultKey* that) const; 00052 static const TDbiResultKey* 00053 GetEmptyKey() { return &fgEmptyKey; } 00054 Int_t GetNumVrecs() const { return fNumVRecKeys; } 00055 std::string GetTableRowName() const; 00056 Bool_t IsEqualTo(const TDbiResultKey* that) const { 00057 return this->Compare(that) == 1.; } 00058 00059 // State changing member functions 00060 00061 void AddVRecKey(UInt_t seqno, TVldTimeStamp ts); 00062 00063 00064 // push VRecKey put to the public: portion so that rootcint dict compiles 00065 /// Container for a SeqNo and CreationDate pair. 00066 struct VRecKey { 00067 VRecKey() : SeqNo(0), CreationDate() {} 00068 VRecKey(UInt_t seqno, TVldTimeStamp ts) : SeqNo(seqno), CreationDate(ts) {} 00069 UInt_t SeqNo; 00070 TVldTimeStamp CreationDate; 00071 }; 00072 00073 private: 00074 00075 static TDbiResultKey fgEmptyKey; 00076 00077 // Data members 00078 00079 /// Name of database table 00080 std::string fTableName; 00081 00082 /// Name of row objects. 00083 std::string fRowName; 00084 00085 /// Key for individual TDbiValidityRec 00086 std::list<TDbiResultKey::VRecKey> fVRecKeys; 00087 00088 /// Optimisation: list::size() is slow! 00089 Int_t fNumVRecKeys; 00090 00091 ClassDef(TDbiResultKey,1) // output string stream 00092 00093 }; 00094 00095 00096 #endif // DBIRESULTKEY 00097 00098