From c52c0e591be55cb2c7251689c69c642e3cb3601c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 11 Apr 2014 20:28:56 +0300 Subject: [PATCH] Add a function to check if a track chain forms a loop --- source/libr2c2/trackchain.cpp | 5 +++++ source/libr2c2/trackchain.h | 1 + 2 files changed, 6 insertions(+) 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 &); -- 2.45.2