From: Mikko Rasa Date: Fri, 11 Apr 2014 17:28:56 +0000 (+0300) Subject: Add a function to check if a track chain forms a loop X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c52c0e591be55cb2c7251689c69c642e3cb3601c;p=r2c2.git Add a function to check if a track chain forms a loop --- diff --git a/source/libr2c2/trackchain.cpp b/source/libr2c2/trackchain.cpp index b256b70..0c3282a 100644 --- a/source/libr2c2/trackchain.cpp +++ b/source/libr2c2/trackchain.cpp @@ -135,6 +135,11 @@ bool TrackChain::has_track(Track &t) const return tracks.count(&t); } +bool TrackChain::is_loop() const +{ + return !tracks.empty() && !ends[0] && !ends[1]; +} + void TrackChain::object_removed(Object &obj) { if(Track *track = dynamic_cast(&obj)) diff --git a/source/libr2c2/trackchain.h b/source/libr2c2/trackchain.h index e2d6176..7d3c518 100644 --- a/source/libr2c2/trackchain.h +++ b/source/libr2c2/trackchain.h @@ -63,6 +63,7 @@ private: public: const TrackSet &get_tracks() const { return tracks; } bool has_track(Track &) const; + bool is_loop() const; private: void object_removed(Object &);