Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::SmoothTrackIterator< InterpolatorType > Class Template Reference

An Iterator that can take an arbitrary amount of steps through a track. More...

#include <trackiterator.h>

+ Collaboration diagram for Mezzanine::SmoothTrackIterator< InterpolatorType >:

Public Types

typedef Real difference_type
 When doing iterator math what is the type of math results.
 
typedef InterpolatorType::InterpolatableType InterpolatableType
 The type the interpolator this works with uses.
 
typedef std::random_access_iterator_tag iterator_category
 This almost supports random access iteration, it does not support any kind of writing to the container.
 
typedef InterpolatableTypepointer
 The type of a pointer to the iterated type.
 
typedef InterpolatableTypereference
 The type of a reference to the iterated type.
 
typedef Track< InterpolatorType > TargetTrackType
 What kind of track with this iterate over.
 
typedef SmoothTrackIterator< InterpolatorType > ThisType
 The kind of this iterator.
 
typedef InterpolatableType value_type
 What type is this iterator working with.
 

Public Member Functions

 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 points. More...
 
 SmoothTrackIterator (const ThisType &Copy)
 Create a copy of an SmoothTrackIterator. More...
 
Integer BoundsCheck () const
 Is the Iterator inside the track? More...
 
Boole BoundsCorrect ()
 If this is iterator is beyond the bounds of the track it target wrap it around to the other side. More...
 
Boole operator!= (const ThisType &Other) const
 Is this SmoothTrackIterator not on the same track and in the same place as another. More...
 
virtual InterpolatableType operator* () const
 Get the current location on the SmoothTrackIterator. More...
 
const ThisType operator+ (Integer Steps)
 Move a copy of this iterator a multiple of steps relative to the amount added. More...
 
ThisTypeoperator++ ()
 Move the SmoothTrackIterator forwards on the track by on step. More...
 
const ThisType operator++ (int)
 Move the SmoothTrackIterator forwards on the track and get a copy of its location before. More...
 
ThisTypeoperator+= (Integer Steps)
 Move this iterator a given amount of steps forward. More...
 
const ThisType operator- (Integer Steps)
 Move a copy this iterator a negativemultiple of steps relative to the amount subtract. More...
 
ThisTypeoperator-- ()
 Move the SmoothTrackIterator backwards on the track by on step. More...
 
const ThisType operator-- (int)
 Move the SmoothTrackIterator backwards on the track and get a copy of its location before. More...
 
ThisTypeoperator-= (Integer Steps)
 Move this iterator a given amount of steps backwards. More...
 
virtual CountedPtr< InterpolatableTypeoperator-> () const
 Derefernce this with the syntax for pointer member access. More...
 
Boole operator< (const ThisType &Right)
 Compare which iterator is further along the track. More...
 
Boole operator<= (const ThisType &Right)
 Compare which iterator is further along the track. More...
 
SmoothTrackIterator< InterpolatorType > & operator= (const ThisType &Other)
 Change this SmoothTrackIterator to match another (Except for Track) More...
 
Boole operator== (const ThisType &Other) const
 Is this SmoothTrackIterator on the same track and in the same place as another. More...
 
Boole operator> (const ThisType &Right)
 Compare which iterator is further toward the track beginning. More...
 
Boole operator>= (const ThisType &Right)
 Compare which iterator is further toward the track beginning. More...
 
const ThisType operator[] (Integer Steps)
 Get an iterator an arbitrary number of steps forward or backwards. More...
 

Protected Member Functions

void Decrement ()
 Move the iterator in the opposite direction from the step.
 
void Increment ()
 Move the iterator in the direction of the step.
 
void StepAdjust (Integer Steps)
 Move the iterator a multiple (including negative multiples) of the step.
 

Protected Attributes

Real Location
 Where on the track are we?
 
Real Step
 How far should this.
 
const TargetTrackType *const TargetTrack
 The track this works against.
 

Detailed Description

template<typename InterpolatorType>
class Mezzanine::SmoothTrackIterator< InterpolatorType >

An Iterator that can take an arbitrary amount of steps through a track.

This stores a value between 0.0 and 1.0 as the current location on a track, and another value between 0.0 an 1.0 as how muc to move when incremented. Everytime this is dereferenced it makes a call against the track it targets and gets the point on the track that corresponds with is current location. For example, presume SomeTrack is a valid track instance:

SmoothTrackIterator< LinearInterpolator<Vector3> > Iter(&SomeTrack,0.0,1.0/200.0);
for(Whole Counter = 0; Counter<200; Counter++
{
std::cout << *Iter << std::endl;
}

This code will output 200 Vector3's lying on the path define by the track, which are each separated b approximately 0.5% ofthe tracks full length. If the track is small this could look pretty smooth

Definition at line 76 of file trackiterator.h.

Constructor & Destructor Documentation

template<typename InterpolatorType>
Mezzanine::SmoothTrackIterator< InterpolatorType >::SmoothTrackIterator ( const TargetTrackType *const  TrackToIterate = 0,
Real  WhereToStart = 0.0,
Real  Increment = 0.01 
)
inline

The constructor for an iterator that can take an arbitrary amount steps through a series of data points.

If default constructed this cannot be dereferenced and is only useful for comparisons

Parameters
TrackToIterateWhich track with this work against.
WhereToStartWhere on the track (range 0 to 1) Should iteration start.
IncrementWhen incremented how much should the location change? Defaults to .01 to create 100 steps.

Definition at line 120 of file trackiterator.h.

template<typename InterpolatorType>
Mezzanine::SmoothTrackIterator< InterpolatorType >::SmoothTrackIterator ( const ThisType Copy)
inline

Create a copy of an SmoothTrackIterator.

Parameters
CopyThe SmoothTrackIterator to copy.

Definition at line 125 of file trackiterator.h.

Member Function Documentation

template<typename InterpolatorType>
Integer Mezzanine::SmoothTrackIterator< InterpolatorType >::BoundsCheck ( ) const
inline

Is the Iterator inside the track?

Returns
This returns 0 if iterator is in the bounds of the track, -1 if before and 1 if after the bounds of the track.

Definition at line 211 of file trackiterator.h.

template<typename InterpolatorType>
Boole Mezzanine::SmoothTrackIterator< InterpolatorType >::BoundsCorrect ( )
inline

If this is iterator is beyond the bounds of the track it target wrap it around to the other side.

Since the location on the track is stored as a value between 0.0 and 1.0 as long asthe step is less than ,subtracting or adding one will preserve the apparent offset from the last location on looped tracks

Returns
True if the bounds where outside the track and false if they where not.

Definition at line 224 of file trackiterator.h.

template<typename InterpolatorType>
Boole Mezzanine::SmoothTrackIterator< InterpolatorType >::operator!= ( const ThisType Other) const
inline

Is this SmoothTrackIterator not on the same track and in the same place as another.

Parameters
OtherThe Other SmoothTrackIterator to compare this one too.
Returns
False if the track is the same and the location on the track is close enough to be within 1 epsilon.

Definition at line 151 of file trackiterator.h.

template<typename InterpolatorType>
virtual InterpolatableType Mezzanine::SmoothTrackIterator< InterpolatorType >::operator* ( ) const
inlinevirtual

Get the current location on the SmoothTrackIterator.

Returns
An instance of InterpolatableType that is read only
Warning
Most iterators return a reference, to allow changes in the underlying container. This returns points that are not stored, so they cannot be changed.
Note
Everytime this is called this it calls the interpolator in the Target Track, This should run in constant time, but is much slower than normal pointer dereferences.

Definition at line 158 of file trackiterator.h.

template<typename InterpolatorType>
const ThisType Mezzanine::SmoothTrackIterator< InterpolatorType >::operator+ ( Integer  Steps)
inline

Move a copy of this iterator a multiple of steps relative to the amount added.

Returns
A reference to this iterator to allow multiple math operations.
Note
Even though the results of this could be assignable doing so is useless without storing the results in a new iterator so this is made const.

Definition at line 237 of file trackiterator.h.

template<typename InterpolatorType>
ThisType& Mezzanine::SmoothTrackIterator< InterpolatorType >::operator++ ( )
inline

Move the SmoothTrackIterator forwards on the track by on step.

The iterator is moved to a new position by adding the step from the current location.

Returns
A Reference to this iterator after the change has been made.

Definition at line 192 of file trackiterator.h.

template<typename InterpolatorType>
const ThisType Mezzanine::SmoothTrackIterator< InterpolatorType >::operator++ ( int  )
inline

Move the SmoothTrackIterator forwards on the track and get a copy of its location before.

Like the prefix ++ this moves the iterator, but this returns a copy of the iterator before being incremented.

Returns
An iterator that is a copy of this one before the decrement.
Note
Even though the results of this could be assignable doing so is useless without storing the results in a new iterator so this is made const.

Definition at line 202 of file trackiterator.h.

template<typename InterpolatorType>
ThisType& Mezzanine::SmoothTrackIterator< InterpolatorType >::operator+= ( Integer  Steps)
inline

Move this iterator a given amount of steps forward.

Returns
A reference to this iterator so it could be used in other operations

Definition at line 255 of file trackiterator.h.

template<typename InterpolatorType>
const ThisType Mezzanine::SmoothTrackIterator< InterpolatorType >::operator- ( Integer  Steps)
inline

Move a copy this iterator a negativemultiple of steps relative to the amount subtract.

Returns
A reference to this iterator to allow multiple math operations.
Note
Even though the results of this could be assignable doing so is useless without storing the results in a new iterator so this is made const.

Definition at line 246 of file trackiterator.h.

template<typename InterpolatorType>
ThisType& Mezzanine::SmoothTrackIterator< InterpolatorType >::operator-- ( )
inline

Move the SmoothTrackIterator backwards on the track by on step.

The iterator is moved to a new position by subtracting the step from the current location.

Returns
A Reference to this iterator after the change has been made.

Definition at line 171 of file trackiterator.h.

template<typename InterpolatorType>
const ThisType Mezzanine::SmoothTrackIterator< InterpolatorType >::operator-- ( int  )
inline

Move the SmoothTrackIterator backwards on the track and get a copy of its location before.

Like the prefix – this moves the iterator, but this returns a copy of the iterator before being increment.

Returns
An iterator that is a copy of this one before the decrement.
Note
Even though the results of this could be assignable doing so is useless without storing the results in a new iterator so this is made const.

Definition at line 181 of file trackiterator.h.

template<typename InterpolatorType>
ThisType& Mezzanine::SmoothTrackIterator< InterpolatorType >::operator-= ( Integer  Steps)
inline

Move this iterator a given amount of steps backwards.

Returns
A reference to this iterator so it could be used in other operations

Definition at line 262 of file trackiterator.h.

template<typename InterpolatorType>
virtual CountedPtr<InterpolatableType> Mezzanine::SmoothTrackIterator< InterpolatorType >::operator-> ( ) const
inlinevirtual

Derefernce this with the syntax for pointer member access.

Returns
A Counted pointer to a temporary InterpolatableType instance.
Warning
This is read only because it is not stored anywhere.
Note
Everytime this is called it calls the interpolator in the Target Track.

Definition at line 164 of file trackiterator.h.

template<typename InterpolatorType>
Boole Mezzanine::SmoothTrackIterator< InterpolatorType >::operator< ( const ThisType Right)
inline

Compare which iterator is further along the track.

Note
The target track and the step size are ignored. This allows for potentially non-sensensical comparison.
Parameters
RightThe value on the right of the <.
Returns
true if this iterator is closer to the start of its track than right one, false otherwise.

Definition at line 272 of file trackiterator.h.

template<typename InterpolatorType>
Boole Mezzanine::SmoothTrackIterator< InterpolatorType >::operator<= ( const ThisType Right)
inline

Compare which iterator is further along the track.

Note
The target track and the step size are ignored. This allows for potentially non-sensensical comparison.
Parameters
RightThe value on the right of the <=.
Returns
true if this iterator is closer to the start of its track than right one(or they are equidistant), false otherwise.

Definition at line 284 of file trackiterator.h.

template<typename InterpolatorType>
SmoothTrackIterator<InterpolatorType>& Mezzanine::SmoothTrackIterator< InterpolatorType >::operator= ( const ThisType Other)
inline

Change this SmoothTrackIterator to match another (Except for Track)

Parameters
OtherThe SmoothTrackIterator to copy, except for its target track
Returns
A SmoothTrackIterator<InterpolatableType>

Definition at line 132 of file trackiterator.h.

template<typename InterpolatorType>
Boole Mezzanine::SmoothTrackIterator< InterpolatorType >::operator== ( const ThisType Other) const
inline

Is this SmoothTrackIterator on the same track and in the same place as another.

Parameters
OtherThe Other SmoothTrackIterator to compare this one too.
Returns
True if the track is the same and the location on the track is close enough to be within 1 epsilon.

Definition at line 142 of file trackiterator.h.

template<typename InterpolatorType>
Boole Mezzanine::SmoothTrackIterator< InterpolatorType >::operator> ( const ThisType Right)
inline

Compare which iterator is further toward the track beginning.

Note
The target track and the step size are ignored. This allows for potentially non-sensensical comparison.
Parameters
RightThe value on the right of the >.
Returns
true if the other iterator is closer to the start of its track than right one, false otherwise.

Definition at line 278 of file trackiterator.h.

template<typename InterpolatorType>
Boole Mezzanine::SmoothTrackIterator< InterpolatorType >::operator>= ( const ThisType Right)
inline

Compare which iterator is further toward the track beginning.

Note
The target track and the step size are ignored. This allows for potentially non-sensensical comparison.
Parameters
RightThe value on the right of the >=.
Returns
true if the other iterator is closer to the start of its track than right one(or they are equidistant), false otherwise.

Definition at line 290 of file trackiterator.h.

template<typename InterpolatorType>
const ThisType Mezzanine::SmoothTrackIterator< InterpolatorType >::operator[] ( Integer  Steps)
inline

Get an iterator an arbitrary number of steps forward or backwards.

Note
Even though the results of this could be assignable doing so is useless without storing the results in a new iterator so this is made const.
Parameters
StepsHow many times to increment or decrement the iterator.

Definition at line 296 of file trackiterator.h.


The documentation for this class was generated from the following file: