CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/TrkBase/TrkBase-00-01-12/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 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
21class TrkRepIter
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]