+
+/**
+A track iterator that detects looping.
+
+A list of visited tracks is maintained internally to the iterator. This list
+is shared between iterators as long as next() is only called once per iterator.
+Subsequent calls to next() cause the head of the list to be copied.
+*/
+class TrackLoopIter: public TrackIter
+{
+private:
+ typedef std::list<Track *> TrackList;
+
+ Msp::RefPtr<TrackList> _visited;
+ TrackList::iterator _last;
+ bool _looped;
+
+public:
+ TrackLoopIter();
+ TrackLoopIter(Track *, unsigned);
+ TrackLoopIter(const TrackIter &);
+private:
+ TrackLoopIter(const TrackIter &, Msp::RefPtr<TrackList>, const TrackList::iterator &);
+
+public:
+ bool looped() const { return _looped; }
+
+ TrackLoopIter next() const;
+ TrackLoopIter next(unsigned) const;
+};
+