Spinning Topp Logo BlackTopp Studios
inc
trackiterator.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _trackiterator_h
41 #define _trackiterator_h
42 
43 #include "countedptr.h"
44 
45 #ifndef SWIG // STD headers are bad for Swig
46  #include <cmath>
47  #include <limits>
48 
49  #include "crossplatform.h"
50 #endif
51 
52 
53 namespace Mezzanine
54 {
55  // Forward declation
56  template <typename InterpolatableType> class Track;
57 
58  /// @brief An Iterator that can take an arbitrary amount of steps through a track.
59  /// @details This stores a value between 0.0 and 1.0 as the current location on a
60  /// track, and another value between 0.0 an 1.0 as how muc to move when
61  /// incremented. Everytime this is dereferenced it makes a call against the
62  /// track it targets and gets the point on the track that corresponds with is current
63  /// location. For example, presume SomeTrack is a valid track instance:
64  /// @code
65  /// SmoothTrackIterator< LinearInterpolator<Vector3> > Iter(&SomeTrack,0.0,1.0/200.0);
66  ///
67  /// for(Whole Counter = 0; Counter<200; Counter++
68  /// {
69  /// std::cout << *Iter << std::endl;
70  /// }
71  /// @endcode
72  /// This code will output 200 Vector3's lying on the path define by the track, which
73  /// are each separated b approximately 0.5% ofthe tracks full length. If the track is
74  /// small this could look pretty smooth
75  template<typename InterpolatorType>
77  {
78  public:
79  /// @brief The type the interpolator this works with uses.
80  typedef typename InterpolatorType::InterpolatableType InterpolatableType;
81  /// @brief What type is this iterator working with.
82  typedef InterpolatableType value_type;
83  /// @brief When doing iterator math what is the type of math results
85  /// @brief The type of a pointer to the iterated type
86  typedef InterpolatableType* pointer;
87  /// @brief The type of a reference to the iterated type
88  typedef InterpolatableType& reference;
89  /// @brief This almost supports random access iteration, it does not support any kind of writing to the container
90  typedef std::random_access_iterator_tag iterator_category;
91  /// @brief What kind of track with this iterate over
93  /// @brief The kind of this iterator.
95 
96  protected:
97  /// @brief The track this works against.
98  const TargetTrackType* const TargetTrack;
99  /// @brief Where on the track are we?
101  /// @brief How far should this
103 
104  /// @brief Move the iterator in the direction of the step.
105  void Increment()
106  { Location += Step; }
107  /// @brief Move the iterator in the opposite direction from the step.
108  void Decrement()
109  { Location -= Step; }
110  /// @brief Move the iterator a multiple (including negative multiples) of the step.
111  void StepAdjust(Integer Steps)
112  { Location += Step * PreciseReal(Steps); }
113 
114  public:
115  /// @brief The constructor for an iterator that can take an arbitrary amount steps through a series of data points
116  /// @details If default constructed this cannot be dereferenced and is only useful for comparisons
117  /// @param TrackToIterate Which track with this work against.
118  /// @param WhereToStart Where on the track (range 0 to 1) Should iteration start.
119  /// @param Increment When incremented how much should the location change? Defaults to .01 to create 100 steps.
120  SmoothTrackIterator(const TargetTrackType* const TrackToIterate = 0, Real WhereToStart = 0.0, Real Increment = 0.01)
121  : TargetTrack(TrackToIterate), Location(WhereToStart), Step(Increment)
122  {}
123  /// @brief Create a copy of an SmoothTrackIterator.
124  /// @param Copy The SmoothTrackIterator to copy.
125  SmoothTrackIterator(const ThisType& Copy)
126  : TargetTrack(Copy.TargetTrack), Location(Copy.Location), Step(Copy.Step)
127  {}
128 
129  /// @brief Change this SmoothTrackIterator to match another (Except for Track)
130  /// @param Other The SmoothTrackIterator to copy, except for its target track
131  /// @return A SmoothTrackIterator<InterpolatableType>
133  {
134  Location=Other.Location;
135  Step=Other.Step;
136  return *this;
137  }
138 
139  /// @brief Is this SmoothTrackIterator on the same track and in the same place as another.
140  /// @param Other The Other SmoothTrackIterator to compare this one too.
141  /// @return True if the track is the same and the location on the track is close enough to be within 1 epsilon.
142  Boole operator==(const ThisType& Other) const
143  {
144  return //TargetTrack==Other.TargetTrack &&
145  (Other.Location-std::numeric_limits<Real>::epsilon())<=Location &&
146  Location<=(Other.Location+std::numeric_limits<Real>::epsilon());
147  }
148  /// @brief Is this SmoothTrackIterator not on the same track and in the same place as another.
149  /// @param Other The Other SmoothTrackIterator to compare this one too.
150  /// @return False if the track is the same and the location on the track is close enough to be within 1 epsilon.
151  Boole operator!=(const ThisType& Other) const
152  { return !operator==(Other); }
153 
154  /// @brief Get the current location on the SmoothTrackIterator
155  /// @return An instance of InterpolatableType that is read only
156  /// @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.
157  /// @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.
158  virtual InterpolatableType operator*() const
159  { return TargetTrack->GetInterpolated(Location); }
160  /// @brief Derefernce this with the syntax for pointer member access.
161  /// @return A Counted pointer to a temporary InterpolatableType instance.
162  /// @warning This is read only because it is not stored anywhere.
163  /// @note Everytime this is called it calls the interpolator in the Target Track.
165  { return CountedPtr<InterpolatableType> (new InterpolatableType(TargetTrack->GetInterpolated(Location))); }
166 
167  /// @brief Move the SmoothTrackIterator backwards on the track by on step.
168  /// @details The iterator is moved to a new position by subtracting the
169  /// step from the current location.
170  /// @return A Reference to this iterator after the change has been made.
171  ThisType& operator--()
172  {
173  Decrement();
174  return *this;
175  }
176  /// @brief Move the SmoothTrackIterator backwards on the track and get a copy of its location before
177  /// @details Like the prefix -- this moves the iterator, but this returns a copy
178  /// of the iterator before being increment.
179  /// @return An iterator that is a copy of this one before the decrement.
180  /// @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.
181  const ThisType operator--(int)
182  {
183  ThisType Results(*this);
184  Decrement();
185  return Results;
186  }
187 
188  /// @brief Move the SmoothTrackIterator forwards on the track by on step.
189  /// @details The iterator is moved to a new position by adding the
190  /// step from the current location.
191  /// @return A Reference to this iterator after the change has been made.
192  ThisType& operator++()
193  {
194  Increment();
195  return *this;
196  }
197  /// @brief Move the SmoothTrackIterator forwards on the track and get a copy of its location before
198  /// @details Like the prefix ++ this moves the iterator, but this returns a copy
199  /// of the iterator before being incremented.
200  /// @return An iterator that is a copy of this one before the decrement.
201  /// @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.
202  const ThisType operator++(int)
203  {
204  ThisType Results(*this);
205  Increment();
206  return Results;
207  }
208 
209  /// @brief Is the Iterator inside the track?
210  /// @return This returns 0 if iterator is in the bounds of the track, -1 if before and 1 if after the bounds of the track.
212  {
213  if(1.0 < Location)
214  { return 1; }
215  if(0.0 > Location)
216  { return -1; }
217  return 0;
218  }
219  /// @brief If this is iterator is beyond the bounds of the track it target *wrap* it around to the other side
220  /// @details Since the location on the track is stored as a value between 0.0 and 1.0 as long asthe step is
221  /// less than ,subtracting or adding one will preserve the apparent offset from the last location on looped
222  /// tracks
223  /// @return True if the bounds where outside the track and false if they where not.
225  {
226  Real Original = Location;
227  while(1.0<Location)
228  { Location--; }
229  while(0.0>Location)
230  { Location++; }
231  return Original!=Location;
232  }
233 
234  /// @brief Move a copy of this iterator a multiple of steps relative to the amount added
235  /// @return A reference to this iterator to allow multiple math operations.
236  /// @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.
237  const ThisType operator+(Integer Steps)
238  {
239  ThisType Results(*this);
240  Results.StepAdjust(Steps);
241  return Results;
242  }
243  /// @brief Move a copy this iterator a negativemultiple of steps relative to the amount subtract
244  /// @return A reference to this iterator to allow multiple math operations.
245  /// @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.
246  const ThisType operator-(Integer Steps)
247  {
248  ThisType Results(*this);
249  Results.StepAdjust(-Steps);
250  return Results;
251  }
252 
253  /// @brief Move this iterator a given amount of steps forward
254  /// @return A reference to this iterator so it could be used in other operations
255  ThisType& operator+=(Integer Steps)
256  {
257  StepAdjust(Steps);
258  return *this;
259  }
260  /// @brief Move this iterator a given amount of steps backwards
261  /// @return A reference to this iterator so it could be used in other operations
262  ThisType& operator-=(Integer Steps)
263  {
264  StepAdjust(-Steps);
265  return *this;
266  }
267 
268  /// @brief Compare which iterator is further along the track
269  /// @note The target track and the step size are ignored. This allows for potentially non-sensensical comparison.
270  /// @param Right The value on the right of the <.
271  /// @return true if this iterator is closer to the start of its track than right one, false otherwise.
272  Boole operator<(const ThisType& Right)
273  { return Location < Right.Location; }
274  /// @brief Compare which iterator is further toward the track beginning.
275  /// @note The target track and the step size are ignored. This allows for potentially non-sensensical comparison.
276  /// @param Right The value on the right of the >.
277  /// @return true if the other iterator is closer to the start of its track than right one, false otherwise.
278  Boole operator>(const ThisType& Right)
279  { return Location > Right.Location; }
280  /// @brief Compare which iterator is further along the track
281  /// @note The target track and the step size are ignored. This allows for potentially non-sensensical comparison.
282  /// @param Right The value on the right of the <=.
283  /// @return true if this iterator is closer to the start of its track than right one(or they are equidistant), false otherwise.
284  Boole operator<=(const ThisType& Right)
285  { return Location <= Right.Location; }
286  /// @brief Compare which iterator is further toward the track beginning.
287  /// @note The target track and the step size are ignored. This allows for potentially non-sensensical comparison.
288  /// @param Right The value on the right of the >=.
289  /// @return true if the other iterator is closer to the start of its track than right one(or they are equidistant), false otherwise.
290  Boole operator>=(const ThisType& Right)
291  { return Location >= Right.Location; }
292 
293  /// @brief Get an iterator an arbitrary number of steps forward or backwards.
294  /// @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.
295  /// @param Steps How many times to increment or decrement the iterator.
296  const ThisType operator[](Integer Steps)
297  { return *this + Steps; }
298  };
299 
300  /// @brief This allows for addition with and an Integer on the Left hand side, such as: 2 + Iter
301  /// @param Steps The Integer on the left.
302  /// @param Iter The SmoothTrackIterator on the right.
303  template<typename InterpolatableType>
305  Integer Steps,
307  { return Iter + Steps; }
308  /// @brief This allows for subtraction with and an Integer on the Left hand side, such as:
309  /// 2 + Iter
310  /// @param Steps The Integer on the left.
311  /// @param Iter The SmoothTrackIterator on the right.
312  template<typename InterpolatableType>
314  Integer Steps,
316  { return Iter - Steps; }
317 
318 
319 
320 
321  /// @brief This will take the same amount of clock time to iterate over a range.
322  /// @details This will spread movement over a range of a track evenly throughout
323  /// a period of time. For example if you have a track of Real values ranging
324  /// from 0.0 to 10.0, interpolating the point at 0.0 will return 0.0 and the
325  /// point 1.0 will return 10.0. Continuing this example if we were to define an
326  /// iterator over this range that will take exactly 1,000 milliseconds to
327  /// complete its journey, if we increment and dereference this 500 milliseconds
328  /// after it was instantiated it will return 5.0. This is the point halfway
329  /// through the range of the track because the time is halfway consumed.
330  /// @n @n
331  /// This iterator must be bounds checked to be safe to use. If incremented before
332  /// its start time its current location is set to its start time, if incremented
333  /// past its end time its current location becoms its end time.
334  /// @n @n
335  /// Here is a code sample that takes 3/4 of a second to iterate over the first
336  /// quarter of the data in a track.
337  /// @code
338  /// TimedTrackIterator< LinearInterpolator<Vector3> > Iter(&SomeTrack,0.0,0.25,750);
339  ///
340  /// Boole SimulationIsStillRunning = true;
341  /// While(SimulationIsStillRunning)
342  /// {
343  /// // This does not increment the iterator like normal iterators, it
344  /// // just updates an internal record of time
345  /// Iter++;
346  ///
347  /// // When de-referencing the time is update
348  /// std::cout << *Iter << std::endl;
349  ///
350  /// // DoOtherSimulationStuff will return false when the simulation end, and
351  /// // presumably it does all the other stuff
352  /// SimulationIsStillRunning = DoOtherSimulationStuff();
353  /// }
354  /// @endcode
355  /// This code will emit to the standard output at least one Vector3 to the standard
356  /// output. All output will be between(inclusive) 0.0 and 0.25 with times closer to
357  /// the iterator creation time being near 0.0 and times closer to 750
358  template<typename InterpolatorType>
360  {
361  public:
362  /// @brief The type the interpolator this works with uses.
363  typedef typename InterpolatorType::InterpolatableType InterpolatableType;
364  /// @brief What type is this iterator working with.
365  typedef InterpolatableType value_type;
366  /// @brief The type of a pointer to the iterated type
367  typedef InterpolatableType* pointer;
368  /// @brief The type of a reference to the iterated type
369  typedef InterpolatableType& reference;
370  /// @brief This almost supports random access iteration, it does not support any kind of writing to the container
371  typedef std::input_iterator_tag iterator_category;
372  /// @brief What kind of track with this iterate over
374  /// @brief The kind of this iterator.
376 
377  protected:
378  /// @brief What Time does iteration start at
380  /// Where is this iterator now.
382  /// @brief What Time does iteration ed at
384 
385  /// @brief The track this works against.
386  const TargetTrackType* const TargetTrack;
387 
388  /// @brief Where Should Iteration Start
390  /// @brief Where should iteration stop
392 
393  /// @brief Update the current location of this iterator based on the current time
395  {
396  CurrentTime=Now;
397  if(Now<StartTime)
398  { CurrentTime = StartTime; }
399  if(EndTime<Now)
400  { CurrentTime = EndTime; }
401  }
402 
403  /// @brief Do the math for determining where/when the iterator is.
404  /// @return A value on the track corresponding to how far through time
405  InterpolatableType GetDereferenced() const
406  {
407  MaxInt Length(EndTime - StartTime);
408  MaxInt Progress(CurrentTime - StartTime);
409  Real RangeLength(EndRange - StartRange);
410 
411  Real AdjustedProgress( PreciseReal((Progress)/PreciseReal(Length)) * PreciseReal(RangeLength) + PreciseReal(StartRange) );
412  return TargetTrack->GetInterpolated(AdjustedProgress);
413  }
414 
415  public:
416  /// @brief The constructor for and iterator
417  /// @details Tracks
418  /// @param TrackToIterate Which track with this work against.
419  /// @param StartOnTrack In the range of 0.0 to 1.0 Where on the track should iteration start. Defaults to 0.0.
420  /// @param EndOnTrack In the range of 0.0 to 1.0 Where on the track should iteration end. Defaults to 1.0.
421  /// @param Duration In microseconds how long should traversing the range of the track take. Defaults to 1 second.
422  /// @param WhenToStart The time iteration should start. Defaults to now.
423  TimedTrackIterator(const TargetTrackType* const TrackToIterate = 0,
424  Real StartOnTrack = 0.0,
425  Real EndOnTrack = 1.0,
426  MaxInt Duration = 1000000,
427  MaxInt WhenToStart = crossplatform::GetTimeStamp())
428  : StartTime(WhenToStart),
429  EndTime(Duration+WhenToStart),
430  TargetTrack(TrackToIterate),
431  StartRange(StartOnTrack),
432  EndRange(EndOnTrack)
433  { Update(WhenToStart); }
434  /// @brief Create a copy of an TimedTrackIterator.
435  /// @param Copy The TimedTrackIterator to copy.
436  TimedTrackIterator(const ThisType& Copy)
437  : StartTime(Copy.StartTime),
438  CurrentTime(Copy.CurrentTime),
439  EndTime(Copy.EndTime),
440  TargetTrack(Copy.TargetTrack),
441  StartRange(Copy.StartRange),
442  EndRange(Copy.EndRange)
443  { }
444  /// @brief Change this TimedTrackIterator to match another (Except for Track)
445  /// @param Other The TimedTrackIterator to copy, except for its target track
446  /// @return A TimedTrackIterator<InterpolatableType>
448  {
449  StartRange=Other.StartRange;
450  EndRange=Other.EndRange;
451  StartTime=Other.StartTime;
452  CurrentTime=Other.CurrentTime;
453  EndTime=Other.EndTime;
454  return *this;
455  }
456 
457  /// @brief Is this TimedTrackIterator on the same track and in the same place as another.
458  /// @param Other The Other TimedTrackIterator to compare this one too.
459  /// @return True if the track is the same and the location on the same track.
460  Boole operator== (const ThisType& Other) const
461  {
462  return TargetTrack==Other.TargetTrack &&
463  StartRange==Other.StartRange &&
464  EndRange==Other.EndRange &&
465  StartTime==Other.StartTime &&
466  CurrentTime==Other.CurrentTime &&
467  EndTime==Other.EndTime;
468  }
469  /// @brief Is this TimedTrackIterator not on the same track and in the same place as another.
470  /// @param Other The Other TimedTrackIterator to compare this one too.
471  /// @return False if the track is the same and the location on the same track.
472  Boole operator!= (const ThisType& Other) const
473  { return !operator==(Other); }
474 
475  /// @brief Get the location on track from the last time it was incremented
476  /// @return An instance of InterpolatableType that is read only
477  /// @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.
478  /// @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.
479  virtual InterpolatableType operator*() const
480  { return GetDereferenced(); }
481  /// @brief Dereference this with the syntax for pointer member access.
482  /// @return A Counted pointer to a temporary InterpolatableType instance.
483  /// @warning This is read only because it is not stored anywhere.
484  /// @note Everytime this is called it calls the interpolator in the Target Track.
487 
488  /// @brief Move the TimedTrackIterator forwards on the track by an amount proportionate to time elapsed.
489  /// @return A Reference to this iterator after the change has been made.
490  ThisType& operator++()
491  {
492  Update();
493  return *this;
494  }
495  /// @brief Move the TimedTrackIterator forwards on the track by an amount proportionate to time elapsed.
496  /// @details Like the prefix ++ this moves the iterator, but this returns a copy
497  /// of the iterator before being incremented.
498  /// @return An iterator that is a copy of this one before the decrement.
499  /// @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.
500  const ThisType operator++(int)
501  {
502  ThisType Results(*this);
503  Update();
504  return Results;
505  }
506 
507  /// @brief Is this iterator at the end of its range on the track
508  /// @return True if the iterator has been incremented to its bounds
509  Boole AtEnd() const
510  { return EndTime == CurrentTime; }
511 
512  /// @brief Is this iterator at the beginning of its range on the track
513  /// @return True if the iterator has not been incremented or its time has not yet come.
514  Boole AtStart() const
515  { return StartTime == CurrentTime; }
516  };
517 
518 
519 
520 
521 }//Mezzanine
522 
523 #endif
524 
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.
Definition: datatypes.h:173
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.
Definition: trackiterator.h:98
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.
Definition: datatypes.h:154
A simple reference counting pointer.
Definition: countedptr.h:70
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.
Definition: trackiterator.h:80
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.
Definition: trackiterator.h:82
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.
Definition: datatypes.h:141
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...
Definition: track.h:179
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.
Definition: trackiterator.h:88
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.
Definition: trackiterator.h:76
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...
Definition: trackiterator.h:90
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...
Definition: datatypes.h:190
Track< InterpolatorType > TargetTrackType
What kind of track with this iterate over.
Definition: trackiterator.h:92
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.
Definition: actor.cpp:56
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.
Definition: datatypes.h:146
Integer BoundsCheck() const
Is the Iterator inside the track?
MaxInt GetTimeStamp()
Get a timestamp.
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.
Definition: trackiterator.h:84
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.
Definition: track.h:65
SmoothTrackIterator< InterpolatorType > ThisType
The kind of this iterator.
Definition: trackiterator.h:94
Real EndRange
Where should iteration stop.
InterpolatableType * pointer
The type of a pointer to the iterated type.
Definition: trackiterator.h:86