BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/TrkBase/include/TrkBase/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
7// std::iterator_traits<TrkHitOnTrk *>
8// FIXME: only works on Linux: class TrkHitOnTrkIter : public
9// std::random_access_iterator<const TrkHitOnTrk, ptrdiff_t>
10// FIXME: only works on SunOS58: class TrkHitOnTrkIter : public
11// std::iterator<std::random_access_iterator_tag,TrkHitOnTrk>
12//
13//
14// FIXME: new idea: give TrkRepIter a constructor which tells it
15// to iterate either of all reps, or unique ones only
16// (i.e. give the iterator a memory of those reps it
17// has already seeni, or search the vector 'in front'
18// of the current position?)
19// Furthermore, give a reference to the TrkRecoTrk vector
20// of sharep pointers of reps...
21
22class TrkRep;
23
24class TrkRepIter {
25public:
26 typedef std::random_access_iterator_tag iterator_category;
27 // typedef const TrkRep value_type;
29 typedef ptrdiff_t difference_type;
32
33 TrkRepIter( const TrkRepIter& rhs ) : _l( rhs._l ), _i( rhs._i ){};
34
35 pointer get() const { return ( *_l )[_i]; }
36 pointer operator->() const { return get(); }
37 reference operator*() const { return *get(); }
38
40 _i -= i;
41 return *this;
42 }
44 _i += i;
45 return *this;
46 }
48 --_i;
49 return *this;
50 } // prefix --
52 ++_i;
53 return *this;
54 } // prefix ++
55
57 TrkRepIter x( *this );
58 --_i;
59 return x;
60 } // postfix --
62 TrkRepIter x( *this );
63 ++_i;
64 return x;
65 } // postfix ++
66
67 ptrdiff_t operator-( const TrkRepIter& i ) const { return _i - i._i; }
68 bool operator==( const TrkRepIter& i ) const { return _l.get() == i._l.get() && _i == i._i; }
69 bool operator!=( const TrkRepIter& i ) const { return !operator==( i ); }
70
71private:
72 friend class TrkRecoTrk; // allow TrkRecoTrk to create TrkRepIters -- and nobody else!
73 typedef std::vector<pointer> TRL;
74 TrkRepIter( boost::shared_ptr<TRL> l, int i ) : _l( l ), _i( i ){};
75
76 boost::shared_ptr<std::vector<pointer>> _l;
77 unsigned _i;
78};
79#endif
Double_t x[10]
ptrdiff_t operator-(const TrkRepIter &i) const