]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/track.cpp
Add an abstraction for things that are attached to tracks
[r2c2.git] / source / libr2c2 / track.cpp
index 43bacc3d8bc10f6a4653716064cbffb331e2ed0c..26fb59e0fa7e756b619ad718d090dec6b6f05314 100644 (file)
@@ -1,4 +1,5 @@
 #include <cmath>
+#include <msp/core/maputils.h>
 #include "block.h"
 #include "catalogue.h"
 #include "driver.h"
@@ -331,6 +332,21 @@ bool Track::break_link(unsigned i)
        return true;
 }
 
+void Track::add_attachment(TrackAttachment &a)
+{
+       if(find(attachments.begin(), attachments.end(), &a)!=attachments.end())
+               throw key_error(&a);
+       attachments.push_back(&a);
+}
+
+void Track::remove_attachment(TrackAttachment &a)
+{
+       AttachmentList::iterator i = find(attachments.begin(), attachments.end(), &a);
+       if(i==attachments.end())
+               throw key_error(&a);
+       attachments.erase(i);
+}
+
 void Track::save(list<DataFile::Statement> &st) const
 {
        st.push_back((DataFile::Statement("position"), position.x, position.y, position.z));