1 #ifndef LIBR2C2_TRACKITER_H_
2 #define LIBR2C2_TRACKITER_H_
5 #include <msp/core/refptr.h>
13 An iterator for traversing tracks.
23 TrackIter(Track *, unsigned);
25 Track *track() const { return _track; }
26 unsigned entry() const { return _entry; }
27 const TrackType::Endpoint &endpoint() const;
30 int get_exit(unsigned) const;
32 TrackIter next() const;
33 TrackIter next(unsigned) const;
34 TrackIter reverse() const;
35 TrackIter reverse(unsigned) const;
36 TrackIter flip() const;
38 Track &operator*() const;
39 Track *operator->() const { return _track; }
40 bool operator==(const TrackIter &) const;
41 bool operator!=(const TrackIter &other) const { return !(*this==other); }
42 operator bool() const { return _track!=0; }
47 A track iterator that detects looping.
49 A list of visited tracks is maintained internally to the iterator. This list
50 is shared between iterators as long as next() is only called once per iterator.
51 Subsequent calls to next() cause the head of the list to be copied.
53 class TrackLoopIter: public TrackIter
56 typedef std::list<Track *> TrackList;
58 Msp::RefPtr<TrackList> _visited;
59 TrackList::iterator _last;
64 TrackLoopIter(Track *, unsigned);
65 TrackLoopIter(const TrackIter &);
67 TrackLoopIter(const TrackIter &, Msp::RefPtr<TrackList>, const TrackList::iterator &);
70 bool looped() const { return _looped; }
72 TrackLoopIter next() const;
73 TrackLoopIter next(unsigned) const;