Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:06

0001 #ifndef FWCore_Reflection_IterWithDict_h
0002 #define FWCore_Reflection_IterWithDict_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 IterWithDict:  An iterator for a TList so a range for loop can be used
0007 
0008 ----------------------------------------------------------------------*/
0009 
0010 #include "TList.h"
0011 
0012 namespace edm {
0013 
0014   class IterWithDictBase {
0015   private:
0016     TIter iter_;
0017     bool atEnd_;
0018 
0019   protected:
0020     void advance();
0021     TIter const& iter() const;
0022 
0023   public:
0024     IterWithDictBase();
0025     explicit IterWithDictBase(TList*);
0026     bool operator!=(IterWithDictBase const&) const;
0027   };
0028 
0029   template <typename T>
0030   class IterWithDict : public IterWithDictBase {
0031   public:
0032     IterWithDict() : IterWithDictBase() {}
0033     explicit IterWithDict(TList* list) : IterWithDictBase(list) {}
0034     IterWithDict<T>& operator++() {
0035       advance();
0036       return *this;
0037     }
0038     T* operator*() const { return static_cast<T*>(*iter()); }
0039   };
0040 
0041 }  // namespace edm
0042 
0043 #endif  // FWCore_Reflection_IterWithDict_h