40 #ifndef _trackiterator_h
41 #define _trackiterator_h
45 #ifndef SWIG // STD headers are bad for Swig
49 #include "crossplatform.h"
56 template <
typename InterpolatableType>
class Track;
75 template<
typename InterpolatorType>
106 { Location +=
Step; }
109 { Location -=
Step; }
121 : TargetTrack(TrackToIterate), Location(WhereToStart), Step(
Increment)
126 : TargetTrack(Copy.TargetTrack), Location(Copy.Location), Step(Copy.Step)
145 (Other.
Location-std::numeric_limits<Real>::epsilon())<=Location &&
146 Location<=(Other.
Location+std::numeric_limits<Real>::epsilon());
183 ThisType Results(*
this);
204 ThisType Results(*
this);
239 ThisType Results(*
this);
248 ThisType Results(*
this);
273 {
return Location < Right.
Location; }
279 {
return Location > Right.
Location; }
285 {
return Location <= Right.
Location; }
291 {
return Location >= Right.
Location; }
297 {
return *
this + Steps; }
303 template<
typename InterpolatableType>
307 {
return Iter + Steps; }
312 template<
typename InterpolatableType>
316 {
return Iter - Steps; }
358 template<
typename InterpolatorType>
407 MaxInt Length(EndTime - StartTime);
408 MaxInt Progress(CurrentTime - StartTime);
409 Real RangeLength(EndRange - StartRange);
424 Real StartOnTrack = 0.0,
425 Real EndOnTrack = 1.0,
426 MaxInt Duration = 1000000,
428 : StartTime(WhenToStart),
429 EndTime(Duration+WhenToStart),
430 TargetTrack(TrackToIterate),
431 StartRange(StartOnTrack),
437 : StartTime(Copy.StartTime),
438 CurrentTime(Copy.CurrentTime),
439 EndTime(Copy.EndTime),
440 TargetTrack(Copy.TargetTrack),
441 StartRange(Copy.StartRange),
442 EndRange(Copy.EndRange)
502 ThisType Results(*
this);
InterpolatableType value_type
What type is this iterator working with.
ThisType & operator--()
Move the SmoothTrackIterator backwards on the track by on step.
std::input_iterator_tag iterator_category
This almost supports random access iteration, it does not support any kind of writing to the containe...
InterpolatorType::InterpolatableType InterpolatableType
The type the interpolator this works with uses.
bool Boole
Generally acts a single bit, true or false.
Boole AtStart() const
Is this iterator at the beginning of its range on the track.
const ThisType operator[](Integer Steps)
Get an iterator an arbitrary number of steps forward or backwards.
Boole operator!=(const ThisType &Other) const
Is this TimedTrackIterator not on the same track and in the same place as another.
Boole operator==(const ThisType &Other) const
Is this TimedTrackIterator on the same track and in the same place as another.
TimedTrackIterator< InterpolatorType > ThisType
The kind of this iterator.
void Decrement()
Move the iterator in the opposite direction from the step.
const TargetTrackType *const TargetTrack
The track this works against.
ThisType & operator++()
Move the SmoothTrackIterator forwards on the track by on step.
ThisType & operator++()
Move the TimedTrackIterator forwards on the track by an amount proportionate to time elapsed...
Boole operator!=(const ThisType &Other) const
Is this SmoothTrackIterator not on the same track and in the same place as another.
Boole operator<=(const ThisType &Right)
Compare which iterator is further along the track.
Boole operator<(const ThisType &Right)
Compare which iterator is further along the track.
const ThisType operator--(int)
Move the SmoothTrackIterator backwards on the track and get a copy of its location before...
int Integer
A datatype used to represent any integer close to.
A simple reference counting pointer.
TimedTrackIterator(const TargetTrackType *const TrackToIterate=0, Real StartOnTrack=0.0, Real EndOnTrack=1.0, MaxInt Duration=1000000, MaxInt WhenToStart=crossplatform::GetTimeStamp())
The constructor for and iterator.
MaxInt CurrentTime
Where is this iterator now.
MaxInt StartTime
What Time does iteration start at.
SmoothTrackIterator< InterpolatableType > & operator+(Integer Steps, SmoothTrackIterator< InterpolatableType > &Iter)
This allows for addition with and an Integer on the Left hand side, such as: 2 + Iter.
void StepAdjust(Integer Steps)
Move the iterator a multiple (including negative multiples) of the step.
SmoothTrackIterator(const TargetTrackType *const TrackToIterate=0, Real WhereToStart=0.0, Real Increment=0.01)
The constructor for an iterator that can take an arbitrary amount steps through a series of data poin...
ThisType & operator+=(Integer Steps)
Move this iterator a given amount of steps forward.
InterpolatorType::InterpolatableType InterpolatableType
The type the interpolator this works with uses.
virtual InterpolatableType operator*() const
Get the location on track from the last time it was incremented.
Real StartRange
Where Should Iteration Start.
const ThisType operator++(int)
Move the TimedTrackIterator forwards on the track by an amount proportionate to time elapsed...
InterpolatableType value_type
What type is this iterator working with.
Boole operator>=(const ThisType &Right)
Compare which iterator is further toward the track beginning.
float Real
A Datatype used to represent a real floating point number.
const ThisType operator-(Integer Steps)
Move a copy this iterator a negativemultiple of steps relative to the amount subtract.
Track< InterpolatorType > TargetTrackType
What kind of track with this iterate over.
InterpolatableType & reference
The type of a reference to the iterated type.
SmoothTrackIterator< InterpolatableType > & operator-(Integer Steps, SmoothTrackIterator< InterpolatableType > &Iter)
This allows for subtraction with and an Integer on the Left hand side, such as: 2 + Iter...
const ThisType operator++(int)
Move the SmoothTrackIterator forwards on the track and get a copy of its location before...
MaxInt Now()
Get a timestamp, in microseconds. This will generally be some multiple of the GetTimeStampResolution ...
virtual InterpolatableType GetInterpolated(Real Percentage) const
Get a value from somewhere on the track with 0.0 being the beginning and 1.0 being the end...
virtual InterpolatableType operator*() const
Get the current location on the SmoothTrackIterator.
ThisType & operator-=(Integer Steps)
Move this iterator a given amount of steps backwards.
TimedTrackIterator(const ThisType &Copy)
Create a copy of an TimedTrackIterator.
This file describes and implements a reference counted pointer that is NOT threadsafe.
InterpolatableType & reference
The type of a reference to the iterated type.
virtual CountedPtr< InterpolatableType > operator->() const
Dereference this with the syntax for pointer member access.
void Update(MaxInt Now=crossplatform::GetTimeStamp())
Update the current location of this iterator based on the current time.
const ThisType operator+(Integer Steps)
Move a copy of this iterator a multiple of steps relative to the amount added.
Boole operator>(const ThisType &Right)
Compare which iterator is further toward the track beginning.
An Iterator that can take an arbitrary amount of steps through a track.
Boole BoundsCorrect()
If this is iterator is beyond the bounds of the track it target wrap it around to the other side...
SmoothTrackIterator< InterpolatorType > & operator=(const ThisType &Other)
Change this SmoothTrackIterator to match another (Except for Track)
std::random_access_iterator_tag iterator_category
This almost supports random access iteration, it does not support any kind of writing to the containe...
SmoothTrackIterator(const ThisType &Copy)
Create a copy of an SmoothTrackIterator.
Boole operator==(const ThisType &Other) const
Is this SmoothTrackIterator on the same track and in the same place as another.
void Increment()
Move the iterator in the direction of the step.
Real Step
How far should this.
long long MaxInt
A large integer type suitable for compile time math and long term microsecond time keeping...
Track< InterpolatorType > TargetTrackType
What kind of track with this iterate over.
Real Location
Where on the track are we?
virtual CountedPtr< InterpolatableType > operator->() const
Derefernce this with the syntax for pointer member access.
Boole AtEnd() const
Is this iterator at the end of its range on the track.
TimedTrackIterator< InterpolatorType > & operator=(const ThisType &Other)
Change this TimedTrackIterator to match another (Except for Track)
The bulk of the engine components go in this namspace.
double PreciseReal
A Real number that is at least as precise as the Real and could be considerably moreso, perhaps Doubly precise. This type might be poorly aligned but very precise.
Integer BoundsCheck() const
Is the Iterator inside the track?
This will take the same amount of clock time to iterate over a range.
const TargetTrackType *const TargetTrack
The track this works against.
InterpolatableType GetDereferenced() const
Do the math for determining where/when the iterator is.
Real difference_type
When doing iterator math what is the type of math results.
MaxInt EndTime
What Time does iteration ed at.
InterpolatableType * pointer
The type of a pointer to the iterated type.
A base type that provides container features for different tracks.
SmoothTrackIterator< InterpolatorType > ThisType
The kind of this iterator.
Real EndRange
Where should iteration stop.
InterpolatableType * pointer
The type of a pointer to the iterated type.