X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrack.cpp;h=2a7cc6adc4b8ccc4c7c66ab8e8c5a9e037db9073;hb=a4a6af55ad5a9bfa14067532b1d1c914ef4c6668;hp=26fb59e0fa7e756b619ad718d090dec6b6f05314;hpb=895fdb9568cda40898e5bb646061c14a41dc0124;p=r2c2.git diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index 26fb59e..2a7cc6a 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -5,11 +5,26 @@ #include "driver.h" #include "layout.h" #include "track.h" +#include "trackattachment.h" #include "tracktype.h" using namespace std; using namespace Msp; +namespace { + +struct AttachmentCompare +{ + unsigned entry; + + AttachmentCompare(unsigned e): entry(e) { } + + bool operator()(const R2C2::TrackAttachment *a1, const R2C2::TrackAttachment *a2) const + { return a1->get_offset_from_endpoint(entry)get_offset_from_endpoint(entry); } +}; + +} + namespace R2C2 { Track::Track(Layout &l, const TrackType &t): @@ -154,8 +169,6 @@ void Track::set_sensor_id(unsigned i) sensor_id = i; layout.create_blocks(*this); - if(layout.has_driver() && sensor_id) - layout.get_driver().add_sensor(sensor_id); } void Track::set_active_path(unsigned p) @@ -347,6 +360,13 @@ void Track::remove_attachment(TrackAttachment &a) attachments.erase(i); } +Track::AttachmentList Track::get_attachments_ordered(unsigned epi) const +{ + AttachmentList result = attachments; + result.sort(AttachmentCompare(epi)); + return result; +} + void Track::save(list &st) const { st.push_back((DataFile::Statement("position"), position.x, position.y, position.z));