TDbiValidityRecBuilder.hxx

Go to the documentation of this file.
00001 #ifndef DBIVALIDITYRECBUILDER_H
00002 #define DBIVALIDITYRECBUILDER_H
00003 
00004 /**
00005  *
00006  * $Id: TDbiValidityRecBuilder.hxx,v 1.1 2011/01/18 05:49:20 finch Exp $
00007  *
00008  * \class TDbiValidityRecBuilder
00009  *
00010  *
00011  * \brief
00012  * <b>Concept</b> Constructor for the set of effective TDbiValidityRec
00013  *   objects for the current query.
00014  *
00015  * \brief
00016  * <b>Purpose</b> Parse a TDbiInRowStream from a validity query and build
00017  *   TDbiValidityRecs for the best, with TVldRange trimmed by neighbouring
00018  *   validity records of higher priority. For non-aggregated tables
00019  *   there will only be one TDbiValidityRec, but for aggregated data,
00020  *   there will be one for each aggregate
00021  *
00022  * Contact: A.Finch@lancaster.ac.uk
00023  *
00024  *
00025  */
00026 
00027 #include <string>
00028 #include <map>
00029 #include <vector>
00030 
00031 #include "TDbi.hxx"
00032 #include "TDbiValidityRec.hxx"
00033 #include "TVldContext.hxx"
00034 
00035 
00036 class TDbiDBProxy;
00037 
00038 
00039 class TDbiValidityRecBuilder
00040 {
00041 
00042 
00043 public:
00044 
00045 // Typedefs and enums
00046 
00047   enum { kMAX_AGGREGATE_NO = 1000 };
00048 
00049 // Constructors and destructors
00050            TDbiValidityRecBuilder(const TDbiDBProxy& proxy,
00051                                  const TVldContext& vc,
00052                                  const TDbi::Task& task,
00053                                  Int_t selectDbNo = -1,
00054                                  Bool_t findFullTimeWindow = true);
00055            TDbiValidityRecBuilder(const TDbiDBProxy& proxy,
00056                                  const string& context,
00057                                  const TDbi::Task& task);
00058             TDbiValidityRecBuilder(const TDbiValidityRec& vr,
00059                                   const std::string tableName);
00060 
00061  virtual ~TDbiValidityRecBuilder();
00062 
00063 // State testing member functions
00064           std::string GetL2CacheName() const;
00065             TDbi::Task GetTask() const { return fTask; }
00066                UInt_t GetNumValidityRec() const {
00067                                                  return fVRecs.size(); }
00068 ///             Get index of AggNo or -1 if missing.
00069                 Int_t IndexOfAggno(Int_t aggNo) const;
00070                Bool_t IsExtendedContext() const {
00071                                             return fIsExtendedContext; }
00072 const TDbiValidityRec& GetValidityRec(Int_t rowNo) const;
00073 const TDbiValidityRec& GetValidityRecFromAggNo(Int_t aggNo) const {
00074                return this->GetValidityRec(this->IndexOfAggno(aggNo)); }
00075  const TDbiValidityRec& GetValidityRecFromSeqNo(UInt_t SeqNo) const;
00076                Bool_t NonAggregated() const {
00077                  return  ! this->IsExtendedContext()
00078                         && this->GetNumValidityRec() == 1; }
00079 
00080 // State changing member functions
00081 
00082 
00083 private:
00084 
00085 // State changing member functions
00086 
00087 ///  Add new aggregate into tables and return its index
00088 UInt_t AddNewAgg(const TDbiValidityRec& vrec,Int_t aggNo);
00089 ///  Add new aggregate gap into tables and return its index
00090 UInt_t AddNewGap(Int_t aggNo);
00091 
00092   void MakeGapRec(const TVldContext& vc,
00093                   const string& tableName,
00094                   Bool_t findFullTimeWindow = true);
00095 
00096 // Data members
00097 
00098              TDbiValidityRec fGap;     // Default (gap) validity record
00099 /// True for extended context query.
00100                      Bool_t fIsExtendedContext;
00101                   TDbi::Task fTask;    // Query task
00102 /// Table of effective ValidityRecs.
00103 /// For context specific queries indexed by row number 0,..
00104 /// The first row is guaranteed to correspond to aggregate -1,
00105 /// although this may be a gap.  Other aggregates may come in any order.
00106 /// For extended context queries first entry is a gap (to be consistent
00107 /// with aggregated query) and all entries are filled in the order they
00108 /// are loaded.
00109 
00110 std::vector<TDbiValidityRec> fVRecs;
00111 /// Map of Aggregate number to index in fVRecs.
00112  std::map<Int_t,UInt_t>  fAggNoToIndex;
00113 
00114 
00115 ClassDef(TDbiValidityRecBuilder,0) // Creator of eff. ValidityRecs
00116 
00117 };
00118 
00119 
00120 #endif  // DBIVALIDITYRECBUILDER_H
00121 

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1