TDbiValidityRec.hxx

Go to the documentation of this file.
00001 #ifndef TDBIVALIDITYREC_H
00002 #define TDBIVALIDITYREC_H
00003 
00004 /**
00005  *
00006  * $Id: TDbiValidityRec.hxx,v 1.1 2011/01/18 05:49:20 finch Exp $
00007  *
00008  * \class TDbiValidityRec
00009  *
00010  *
00011  * \brief
00012  * <b>Concept</b> A concrete data type corresponding to a single row in
00013  *  an  auxillary validity range database table.
00014  *
00015  * \brief
00016  * <b>Purpose</b> To resolve ambiguities in the case of multiple matches
00017  *   to a query and to record results of validity range trimming due to
00018  *   neighbouring database entries.
00019  *
00020  * Contact: A.Finch@lancaster.ac.uk
00021  *
00022  *
00023  */
00024 
00025 #include "TDbi.hxx"
00026 #include "TDbiTableRow.hxx"
00027 #include "TVldRange.hxx"
00028 #include "TVldTimeStamp.hxx"
00029 
00030 #include <iosfwd>
00031 #include <string>
00032 
00033 class TDbiBinaryFile;
00034 class TDbiTableProxy;
00035 class TDbiValidityRec;
00036 
00037 ostream& operator<<(ostream& s, const TDbiValidityRec& vRec);
00038 
00039 class TDbiValidityRec : public TDbiTableRow
00040 {
00041 
00042 
00043 public:
00044 
00045 // Constructors and destructors.
00046            TDbiValidityRec(Int_t dbNo = -1, Bool_t isGap = kTRUE);
00047            TDbiValidityRec(const TDbiValidityRec& from);
00048            TDbiValidityRec(const TVldRange& range,
00049                           TDbi::Task task,
00050                           Int_t aggNo,
00051                           UInt_t seqNo,
00052                           Int_t dbNo = -1,
00053                           Bool_t isGap = kFALSE,
00054                           TVldTimeStamp time = TVldTimeStamp(),
00055                           UInt_t epoch = 0);
00056   virtual ~TDbiValidityRec();
00057 
00058 // State testing member functions
00059 
00060   virtual TDbiTableRow* CreateTableRow() const {
00061                                            return new TDbiValidityRec; }
00062                  Int_t GetAggregateNo() const { return fAggregateNo; }
00063 
00064 
00065           TVldTimeStamp GetCreationDate() const { return fCreationDate; }
00066                 UInt_t GetDbNo() const { return fDbNo; }
00067                 UInt_t GetEpoch() const { return fEpoch; }
00068           TVldTimeStamp GetInsertDate() const { return fInsertDate; }
00069              TDbi::Task GetTask() const { return fTask; }
00070            std::string GetL2CacheName() const;
00071                 UInt_t GetSeqNo() const { return fSeqNo; }
00072   const TDbiTableProxy* GetTableProxy() const { return fTableProxy; }
00073        const TVldRange& GetVldRange() const { return fVldRange;}
00074                 Bool_t HasExpired(const TDbiValidityRec& other) const;
00075                 Bool_t HasExpired(const TVldContext& vc,
00076                                   const TDbi::Task& task) const;
00077                Bool_t IsCompatible(const TVldContext& vc,
00078                                     const TDbi::Task& task) const;
00079                 Bool_t IsGap() const { return fIsGap; }
00080                 Bool_t IsHigherPriority(const TDbiValidityRec& that,
00081                                         Bool_t useCreationDate = false) const;
00082 
00083 static     std::string GetL2CacheName(UInt_t seqLo, UInt_t seqHi, TVldTimeStamp ts);
00084 
00085 // State changing member functions
00086         void AndTimeWindow(const TVldTimeStamp& start,
00087                            const TVldTimeStamp& end);
00088         void SetAggregateNo(Int_t aggNo) { fAggregateNo = aggNo; }
00089         void SetDbNo(Int_t dbNo) { fDbNo = dbNo; }
00090         void SetEpoch(UInt_t epoch) { fEpoch = epoch; }
00091         void SetTableProxy(const TDbiTableProxy* tp) { fTableProxy = tp; }
00092         void SetTimeWindow(const TVldTimeStamp& start,
00093                            const TVldTimeStamp& end);
00094         void SetVldRange(const TVldRange& range) { fVldRange=range;}
00095         void Trim(const TVldTimeStamp& queryTime,
00096                   const TDbiValidityRec& other);
00097 
00098 // I/O  member functions
00099   virtual void Fill(TDbiInRowStream& rs,
00100                     const TDbiValidityRec* vrec);
00101   virtual void Store(TDbiOutRowStream& ors,
00102                     const TDbiValidityRec* vrec) const;
00103           void Streamer(TDbiBinaryFile& file);
00104 
00105 private:
00106 
00107 // Data members
00108 
00109 
00110 /// Aggregate number or:-
00111 ///    -1 Non-aggregated data or multiple aggregates
00112 ///    -2 undefined aggregates
00113   Int_t fAggregateNo;
00114 
00115 ///  Creation date
00116   TVldTimeStamp fCreationDate;
00117 
00118 /// Cascade no. of source db =-1 unknown
00119   Int_t fDbNo;
00120 
00121 ///  Insertion date
00122   TVldTimeStamp fInsertDate;
00123 
00124 ///  kTRUE if corresponds to a gap.
00125     Bool_t fIsGap;
00126 
00127 /// Task number
00128   TDbi::Task fTask;
00129 
00130 /// Sequence number or 0 if compound.
00131   Int_t fSeqNo;
00132 
00133 
00134 /// TDbiTableProxy that filled this (if any).
00135   const TDbiTableProxy* fTableProxy;
00136 
00137 /// Validity range of record.
00138   TVldRange fVldRange;
00139 
00140 /// Calibration Epoch
00141   UInt_t fEpoch;
00142 
00143 /// Reality (for possible, but improbable future use)
00144   UInt_t fReality;
00145 
00146 ClassDef(TDbiValidityRec,0)  // Validity range table row.
00147 
00148 };
00149 
00150 
00151 #endif  // TDBIVALIDITYREC_H
00152 

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1