]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/trackattachment.h
Add an abstraction for things that are attached to tracks
[r2c2.git] / source / libr2c2 / trackattachment.h
diff --git a/source/libr2c2/trackattachment.h b/source/libr2c2/trackattachment.h
new file mode 100644 (file)
index 0000000..8551250
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef LIBR2C2_TRACKATTACHMENT_H_
+#define LIBR2C2_TRACKATTACHMENT_H_
+
+#include "object.h"
+#include "trackiter.h"
+
+namespace R2C2 {
+
+class TrackAttachment: public Object
+{
+protected:
+       TrackIter track;
+       float offset;
+
+       TrackAttachment(Layout &);
+public:
+       virtual ~TrackAttachment();
+
+       const TrackIter &get_track_iter() const { return track; }
+       Track *get_track() const { return track.track(); }
+       unsigned get_entry() const { return track.entry(); }
+       float get_offset() const { return offset; }
+protected:
+       void attach_to(const TrackIter &, float);
+       void attach_to_closest(float);
+       float find_offset(const TrackIter &, const Vector &);
+
+public:
+       virtual Track *get_parent() const { return track.track(); }
+};
+
+} // namespace R2C2
+
+#endif