CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollectionV.h

Go to the documentation of this file.
00001 #ifndef RECOCALOTOOLS_METACOLLECTIONS_CALORECHITMETACOLLECTIONV_H
00002 #define RECOCALOTOOLS_METACOLLECTIONS_CALORECHITMETACOLLECTIONV_H 1
00003 
00004 #include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
00005 #include <iterator>
00006 
00007 
00008 
00018 class CaloRecHitMetaCollectionV {
00019 public:
00020   class Iterator {
00021   public:
00022     typedef std::random_access_iterator_tag iterator_category;
00023     typedef const CaloRecHit& value_type;
00024     typedef int difference_type;
00025     typedef const CaloRecHit& reference;
00026     typedef const CaloRecHit* pointer;
00027     typedef int offset_type;
00028 
00029     Iterator() : collection_(0), offset_(0) { }
00030     Iterator(const Iterator& it) : collection_(it.collection_), offset_(it.offset_) { }
00031     Iterator(const CaloRecHitMetaCollectionV* col, offset_type pos) : collection_(col), offset_(pos) { }
00032     Iterator& operator=(const Iterator& it) { collection_=it.collection_; offset_=it.offset_; return (*this); }
00033 
00035     reference operator*() const;
00037     pointer operator->() const;
00038 
00040     bool operator==(const Iterator& it) const;
00042     bool operator!=(const Iterator& it) const;
00043 
00045     Iterator& operator++();
00047     Iterator operator++(int);
00049     Iterator& operator--();
00051     Iterator operator--(int);
00052     
00053     // Random-access iterator requirements
00054     reference operator[](const difference_type n) const;
00055     Iterator& operator+=(const difference_type n);
00056     Iterator operator+(const difference_type n) const;
00057     Iterator& operator-=(const difference_type n);
00058     Iterator operator-(const difference_type n) const;
00059     bool operator<(const Iterator& i) const; 
00060 
00061   private:
00062     const CaloRecHitMetaCollectionV* collection_;
00063     offset_type offset_;
00064   };
00065 //
00066 // add virtual descructor
00067 //
00068   virtual ~CaloRecHitMetaCollectionV() {}
00069   typedef Iterator const_iterator;
00070 
00072   virtual const_iterator find(const DetId& id) const;
00073 
00075   const_iterator begin() const { return const_iterator(this,0); }
00077   const_iterator end() const { return const_iterator(this,(const_iterator::offset_type)(size_)); }
00079   unsigned int size() const { return size_; }
00080 
00082   virtual const CaloRecHit* at(const_iterator::offset_type i) const = 0;
00083   
00084 protected:
00085   CaloRecHitMetaCollectionV();
00086   unsigned int size_; // must be updated by derived classes 
00087 };
00088 
00089 #endif