]> git.tdb.fi Git - r2c2.git/commitdiff
Add a function to check if a track chain forms a loop
authorMikko Rasa <tdb@tdb.fi>
Fri, 11 Apr 2014 17:28:56 +0000 (20:28 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 11 Apr 2014 19:35:12 +0000 (22:35 +0300)
source/libr2c2/trackchain.cpp
source/libr2c2/trackchain.h

index b256b705f95aa5bc21dceca556b767f3d962c676..0c3282ad4845a4893f2c776fef7d2f49d2c48413 100644 (file)
@@ -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<Track *>(&obj))
index e2d6176f2c1733ff093975d39ef5afe132bbebc4..7d3c518a92842aa076350b701182b7fd6054df86 100644 (file)
@@ -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 &);