CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkRepIter.h
Go to the documentation of this file.
1#ifndef TRKREPITER_H
2#define TRKREPITER_H
3#include "boost/shared_ptr.hpp"
4#include <iterator>
5
6//FIXME: only works on Linux: class TrkHitOnTrkIter : public std::iterator_traits<TrkHitOnTrk *>
7//FIXME: only works on Linux: class TrkHitOnTrkIter : public std::random_access_iterator<const TrkHitOnTrk, ptrdiff_t>
8//FIXME: only works on SunOS58: class TrkHitOnTrkIter : public std::iterator<std::random_access_iterator_tag,TrkHitOnTrk>
9//
10//
11//FIXME: new idea: give TrkRepIter a constructor which tells it
12// to iterate either of all reps, or unique ones only
13// (i.e. give the iterator a memory of those reps it
14// has already seeni, or search the vector 'in front'
15// of the current position?)
16// Furthermore, give a reference to the TrkRecoTrk vector
17// of sharep pointers of reps...
18
19class TrkRep;
20
22{
23public:
24 typedef std::random_access_iterator_tag iterator_category;
25 // typedef const TrkRep value_type;
27 typedef ptrdiff_t difference_type;
30
31 TrkRepIter(const TrkRepIter& rhs) : _l(rhs._l),_i(rhs._i) {};
32
33 pointer get() const { return (*_l)[_i]; }
34 pointer operator->() const { return get(); }
35 reference operator*() const { return *get(); }
36
37 TrkRepIter& operator-=(int i) { _i-=i; return *this; }
38 TrkRepIter& operator+=(int i) { _i+=i; return *this; }
39 TrkRepIter& operator--() { --_i; return *this; } // prefix --
40 TrkRepIter& operator++() { ++_i; return *this; } // prefix ++
41
42 TrkRepIter operator--(int) { TrkRepIter x(*this); --_i; return x; } // postfix --
43 TrkRepIter operator++(int) { TrkRepIter x(*this); ++_i; return x; } // postfix ++
44
45
46 ptrdiff_t operator-(const TrkRepIter& i) const { return _i - i._i; }
47 bool operator==(const TrkRepIter& i) const { return _l.get() == i._l.get()
48 && _i == i._i; }
49 bool operator!=(const TrkRepIter& i) const { return !operator==(i); }
50
51private:
52 friend class TrkRecoTrk; // allow TrkRecoTrk to create TrkRepIters -- and nobody else!
53 typedef std::vector<pointer> TRL;
54 TrkRepIter(boost::shared_ptr<TRL> l,int i) : _l(l),_i(i) {};
55
56 boost::shared_ptr< std::vector<pointer> > _l;
57 unsigned _i;
58};
59#endif
Double_t x[10]
pointer operator->() const
Definition TrkRepIter.h:34
TrkRep value_type
Definition TrkRepIter.h:26
TrkRepIter & operator--()
Definition TrkRepIter.h:39
TrkRepIter operator++(int)
Definition TrkRepIter.h:43
pointer get() const
Definition TrkRepIter.h:33
TrkRepIter(const TrkRepIter &rhs)
Definition TrkRepIter.h:31
std::random_access_iterator_tag iterator_category
Definition TrkRepIter.h:24
bool operator!=(const TrkRepIter &i) const
Definition TrkRepIter.h:49
TrkRepIter & operator+=(int i)
Definition TrkRepIter.h:38
ptrdiff_t difference_type
Definition TrkRepIter.h:27
bool operator==(const TrkRepIter &i) const
Definition TrkRepIter.h:47
TrkRepIter & operator-=(int i)
Definition TrkRepIter.h:37
reference operator*() const
Definition TrkRepIter.h:35
ptrdiff_t operator-(const TrkRepIter &i) const
Definition TrkRepIter.h:46
TrkRepIter operator--(int)
Definition TrkRepIter.h:42
value_type & reference
Definition TrkRepIter.h:29
value_type * pointer
Definition TrkRepIter.h:28
TrkRepIter & operator++()
Definition TrkRepIter.h:40