//////////////////////////////////////////////////////////////// // $Id: IMidasItr.hxx,v 1.4 2009/09/25 06:02:32 nickwest Exp $ // #ifndef TMidasItr_hxx_seen #define TMidasItr_hxx_seen #include "IMidasObj.hxx" #include /// IMidasItr is the partially abstract templated base class for all raw /// data iterators over a list of raw IMidasObj objects. /// /// The purpose of the IMidasItr is twofold:- /// /// namespace COMET { class IMidasBank; template class IMidasItr : public IMidasObj { public: IMidasItr(UShort_t rawDataVer = 0, UShort_t invalid_code = 0, const IMidasBank* parent = 0, Int_t size = -1); virtual ~IMidasItr(); /// Return true if list exhausted. Bool_t EOD() const { return this->NotValid("EOD") ? true : this->EODImp(); } /// Get next element of list. Return invalid element if list already exhausted. T Get(); /// Return the index to current element. 999999999 means invalid UInt_t GetIndex() const { return this->NotValid("GetIndex") ? 999999999 : fIndex; } /// Print the contents of all elements virtual void Print(const Option_t* opt = "") const; /// Reposition before first element of list so that Get() returns first void Rewind(); /// Position to specified index and return true if /// successful. SetPosition(0) is equivalent to Rewind() /// Caution: involves iteration. Bool_t SetPosition(UInt_t index); /// Get the number of elements. /// Caution: may involve iteration over the full set UInt_t Size() const; /// Return the complete set as a vector for random access. /// Caller must pass in the vector which is cleared before use. /// Caution: involves iteration and resulting list may be heavyweight void GetSet(std::vector& vec) const; protected: /// Bank name encoded channel information - see COMET::IMidasBank::fChannelInfo UInt_t GetChannelInfo() const { return fChannelInfo; } // The abstract methods that subclasses must implement virtual Bool_t EODImp() const = 0; virtual T GetImp() = 0; virtual void RewindImp() = 0; private: /// Index to the element that will be return by next Get(). /// When constructed it is set to 0. /// When at EOD is will be one greater than the list size. UInt_t fIndex; /// Size of list. If value when instantiated is < 0 compute size by iterating to EOD. Int_t fSize; /// Bank name encoded channel information - see COMET::IMidasBank::fChannelInfo UInt_t fChannelInfo; }; }; #endif