_track(t, e),
_offset(_track ? o : 0),
_path((_track && _offset) ? _track->get_active_path() : -1)
-{ }
+{
+ validate();
+}
TrackOffsetIter::TrackOffsetIter(Track *t, unsigned e, unsigned p, float o):
_track(t, e),
_offset(o),
_path(p)
-{ }
+{
+ validate();
+}
TrackOffsetIter::TrackOffsetIter(const TrackIter &t, float o):
_track(t),
_offset(_track ? o : 0),
_path((_track && _offset) ? _track->get_active_path() : -1)
-{ }
+{
+ validate();
+}
TrackOffsetIter::TrackOffsetIter(const TrackIter &t, unsigned p, float o):
_track(t),
_offset(o),
_path(p)
-{ }
+{
+ validate();
+}
+
+void TrackOffsetIter::validate()
+{
+ if(!_track)
+ return;
+
+ if(_offset<0)
+ throw invalid_argument("TrackOffsetIter::TrackOffsetIter");
+
+ if(_path>=0)
+ {
+ if(!_track.endpoint().has_path(_path))
+ throw invalid_argument("TrackOffsetIter::TrackOffsetIter");
+ if(_offset>_track->get_type().get_path_length(_path))
+ throw invalid_argument("TrackOffsetIter::TrackOffsetIter");
+ }
+}
BlockIter TrackOffsetIter::block_iter() const
{
TrackOffsetIter(const TrackIter &, float = 0);
TrackOffsetIter(const TrackIter &, unsigned, float);
+private:
+ void validate();
+
+public:
Track *track() const { return _track.track(); }
unsigned entry() const { return _track.entry(); }
const TrackIter &track_iter() const { return _track; }