47 #include "trackiterator.h"
49 #ifndef SWIG // STD headers are bad for Swig
64 template <
typename InterpolatorType>
103 DataIteratorType
End)
104 : DataPoints(Begin,End)
108 Track(
const DataContainerType& DataSet) : DataPoints(DataSet)
122 {
return DataPoints.size(); }
133 virtual void push_back(
const InterpolatableType& AddedValue)
134 { DataPoints.push_back(AddedValue); }
138 virtual void Add(
const InterpolatableType& AddedValue)
143 { DataPoints.clear(); }
160 {
return begin(Steps); }
174 {
return end(Steps); }
181 return InterpolatorType::Interpolate(
182 this->DataPoints.begin(),
183 this->DataPoints.end(),
194 if( Index <= this->
Size() - 2 ) {
195 ConstDataIteratorType RangeBegin = this->DataPoints.begin(), RangeEnd = this->DataPoints.begin();
196 std::advance( RangeBegin, Index );
197 std::advance( RangeEnd, Index + 2 );
198 return InterpolatorType::Interpolate(RangeBegin,RangeEnd,Percentage);
217 if(Name.size() && 0==ConvertTo<ConvertiblePointer>(Name))
278 InterpolatorType::ProtoSerialize(InterpolatorNode);
286 for(
typename DataContainerType::const_iterator Iter = DataPoints.begin();
287 DataPoints.end()!=Iter;
289 { Iter->ProtoSerialize(DataNode);}
309 if(InterpolatorNode.
Name() == InterpolatorType::GetSerializableName())
311 InterpolatorType::ProtoDeSerialize(InterpolatorNode);
324 InterpolatableType Scratch;
325 Scratch.ProtoDeSerialize(Iter);
326 DataPoints.push_back(Scratch);
347 {
return String(
"Track"); }
356 template <
typename InterpolatorType>
377 DataIteratorType
End)
378 : BaseType(Begin,End)
402 virtual void push_back(
const InterpolatableType& AddedValue)
424 {
return String(
"TrackLooped"); }
437 std::ostream& operator << (std::ostream& stream, const Mezzanine::Track<T>& Lint)
457 std::ostream& operator << (std::ostream& stream, const Mezzanine::TrackLooped<T>& Lint)
virtual InterpolatableType GetInterpolated(size_t Index, Real Percentage) const
Get a value between two points on the track with 0.0 being a specified datapoint and 1...
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
String GetTrackName() const
Get the given name or generate a default name.
A track that keeps an extra data point in the track to make sure it loops.
String ToString(const T &Datum)
Converts whatever to a String as long as a streaming operator is available for it.
void EnforceLoop()
If this track has more than one datapoint, does the first match the last, if not fix it...
TrackLooped(DataIteratorType Begin, DataIteratorType End)
Create a Track from a range of data points, and enforce its being a loop.
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
All the definitions for datatypes as well as some basic conversion functions are defined here...
std::ostream & Serialize(std::ostream &Stream, const T &Converted, const String &Indent=String(""))
Convert any class that supports serialization or has a serializer to a string of chars in a stream...
virtual void push_back(const InterpolatableType &AddedValue)
Add another data point, and preserve the track's loopwhile doing so.
int Integer
A datatype used to represent any integer close to.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
std::vector< InterpolatableType > DataContainerType
The type of the Container storing the interpolatable data. This is a single point to change all the t...
void clear()
Remove all the points from the track.
Any global enumerations shared between multiple classes is to be declared here.
size_t size() const
Get the amount of stored DataPoints.
virtual SmoothIteratorType begin(Integer Steps=100) const
Get an Smooth iterator to the beginning of the track.
Track< InterpolatorType > BaseType
The base most class of this type.
This implements the exception hiearchy for Mezzanine.
Track(const DataContainerType &DataSet)
Create a track from a DataContainerType instance, likely a vector and copthe data from it...
DataContainerType::const_iterator ConstDataIteratorType
A const iterator type for the elements stored and interpolated within this track. ...
SmoothTrackIterator< InterpolatableType > SmoothIteratorType
An iterator than can take an arbitrary amount of steps by interpolation.
InterpolatorType::Storage DataContainerType
The type of the internal container storing the interpolatable data. This is a single point to change ...
Node GetNextSibling() const
Attempt to retrieve the next sibling of this Node.
TrackLooped()
Create a default empty looped track.
void SetTrackName(String Name)
Set the name for serialization.
SmoothTrackIterator< InterpolatorType > SmoothIteratorType
An iterator than can take an arbitrary amount of steps by interpolation.
float Real
A Datatype used to represent a real floating point number.
virtual void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this to a node on an XML graph.
bool SetValue(const Char8 *rhs)
Set the value of this.
TrackLooped(const DataContainerType &DataSet)
Create a track from a DataContainerType instance, likely a vector and copy the data from it...
String RawName
Name of the track, primarily for serialization.
A light-weight handle for manipulating nodes in DOM tree.
InterpolatorType::InterpolatableType InterpolatableType
The type this class and the interpolator it uses works with.
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...
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
DataContainerType::iterator DataIteratorType
The iterator type for the interpolated data stored in this track.
Thrown when a passed parameter is checked at runtime and not in the expected range.
InterpolatorType::InterpolatableType InterpolatableType
The type this class and the interpolator it uses works with.
void Clear()
Remove all the points from the track.
virtual ~Track()
Virtual Deconstructor.
An Iterator that can take an arbitrary amount of steps through a track.
std::istream & DeSerialize(std::istream &Stream, T &Converted)
Deserialize the next xml tag in the stream into a specific in memory class instance.
DataContainerType DataPoints
The underlying container of Discrete datapoints.
size_t Size() const
Get the amount of stored DataPoints.
virtual SmoothIteratorType end(Integer Steps=0) const
Get an Smooth iterator to the end (not one past) of the track.
DataContainerType::iterator DataIteratorType
An iterator type for the elements stored and interpolated within this track.
static String GetSerializableName()
Get the name of this class "Track".
virtual void push_back(const InterpolatableType &AddedValue)
Add another data point to the end of the track.
static String GetSerializableName()
Get the name of this class "TrackLooped".
Track(DataIteratorType Begin, DataIteratorType End)
Create a Track from a range of data points.
Thrown when the identity string wasn't valid at all.
The bulk of the engine components go in this namspace.
virtual ~TrackLooped()
Virtual Deconstructor.
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.
std::istream & operator>>(std::istream &stream, Mezzanine::LinearInterpolator< T > &Lint)
Used to de-serialize an Mezzanine::LinearInterpolator from a stream.
intptr_t ConvertiblePointer
A type that any pointer can be converted to and back from, and insures after the conversion back it w...
virtual void Add(const InterpolatableType &AddedValue)
Add another data point to the end of the track.
virtual void ProtoDeSerialize(const XML::Node &OneNode)
Convert a node on an XML into a track.
const String & GetTrackName()
This is just like the const version of the function but it will set the name if unset and retrieve it...
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
virtual SmoothIteratorType Begin(Integer Steps=100) const
Get an Smooth iterator to the beginning of the track.
String SetTrackNameUnique(String Name="")
Set the name to something that serialization definitely will not duplicate.
Track()
Create a default empty track.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
Helper classes to assist in generating data points between two other data points. ...
std::string String
A datatype used to a series of characters.
virtual String DerivedSerializableName() const
A base type that provides container features for different tracks.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual SmoothIteratorType End(Integer Steps=0) const
Get an Smooth iterator to the end (not one past) of the track.
virtual String DerivedSerializableName() const
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.