Documentation


animal::History< Position, Velocity > Class Template Reference

#include <history.h>

Inheritance diagram for animal::History< Position, Velocity >:

animal::HistoryS< Position, Velocity > animal::HistoryV< Position, Velocity > List of all members.

Detailed Description

template<class Position, class Velocity>
class animal::History< Position, Velocity >

Base class for histories (single values or stl containers).

History is an auxiliary class for the animal::Anim class. Used to record/replay animation, much like a tape recorder would do. The API implements a state machine which consists of a sequence of states and a cursor. Additional state variables represent recording and replaying. The history can not be empty. It has to be initialized with a given state. In record mode, a given pair <time,state> can be appended to the history using function push_back(). In replay mode, one can navigate through the history using ++ and --, and extract time and state using time() and copyStateTo(). The history can be saved to/loaded from a gnuplot-compatible file with no comments.

Definition at line 22 of file history.h.

Public Member Functions

 History (double t, Position p, Velocity v, bool record=false)
 Constructor uses initial state, so that the history can not be empty. This initial state is used for reset.

virtual ~History ()
 Base destructor does nothing.

void push_back (double t, Position p, Velocity v)
 Append current state and time to the history.

void reset ()
 Sets the cursor to initial state.

void operator++ ()
 Go to next state, except if the current state is the last state.

void operator-- ()
 Go to previous state, except if current state is the first state.

double t () const
 Time associated with current state.

void copyStateTo (Position *p, Velocity *v) const
 Copy current state to the parameter.

void toggleRecord (bool b)
 Toggle record on/off.

bool isRecording () const
 True iff record is on.

void toggleReplay (bool b)
 Toggle replay on/off.

bool isReplaying () const
 True iff replay is on.

virtual void write (std::ostream &out) const=0
 Write the whole history to the given output stream.

virtual void read (std::istream &in)=0
 Read the whole history from the given input stream. No comments are allowed.


Protected Attributes

List state_list
 Store the keys.


Private Types

typedef std::list< KeyList
 Store the keys for replay.


Private Attributes

List::iterator cursor
 Points to the current key.

bool record
 true iff recording

bool replay
 true iff replaying


Member Typedef Documentation

template<class Position, class Velocity>
typedef std::list< Key > animal::History< Position, Velocity >::List [private]
 

Store the keys for replay.

Reimplemented in animal::HistoryS< Position, Velocity >, and animal::HistoryV< Position, Velocity >.

Definition at line 41 of file history.h.


Constructor & Destructor Documentation

template<class Position, class Velocity>
animal::History< Position, Velocity >::History double  t,
Position  p,
Velocity  v,
bool  record = false
[inline]
 

Constructor uses initial state, so that the history can not be empty. This initial state is used for reset.

Definition at line 48 of file history.h.

References animal::History< Position, Velocity >::cursor, animal::History< Position, Velocity >::record, animal::History< Position, Velocity >::replay, and animal::History< Position, Velocity >::state_list.

template<class Position, class Velocity>
virtual animal::History< Position, Velocity >::~History  )  [inline, virtual]
 

Base destructor does nothing.

Definition at line 57 of file history.h.


Member Function Documentation

template<class Position, class Velocity>
void animal::History< Position, Velocity >::copyStateTo Position *  p,
Velocity *  v
const [inline]
 

Copy current state to the parameter.

Definition at line 99 of file history.h.

References animal::History< Position, Velocity >::cursor.

template<class Position, class Velocity>
bool animal::History< Position, Velocity >::isRecording  )  const [inline]
 

True iff record is on.

Definition at line 111 of file history.h.

References animal::History< Position, Velocity >::record.

Referenced by animal::History< Position, Velocity >::push_back().

template<class Position, class Velocity>
bool animal::History< Position, Velocity >::isReplaying  )  const [inline]
 

True iff replay is on.

Definition at line 121 of file history.h.

References animal::History< Position, Velocity >::replay.

Referenced by animal::History< Position, Velocity >::operator++(), and animal::History< Position, Velocity >::operator--().

template<class Position, class Velocity>
void animal::History< Position, Velocity >::operator++  )  [inline]
 

Go to next state, except if the current state is the last state.

Definition at line 74 of file history.h.

References animal::History< Position, Velocity >::cursor, animal::History< Position, Velocity >::isReplaying(), and animal::History< Position, Velocity >::state_list.

template<class Position, class Velocity>
void animal::History< Position, Velocity >::operator--  )  [inline]
 

Go to previous state, except if current state is the first state.

Definition at line 87 of file history.h.

References animal::History< Position, Velocity >::cursor, animal::History< Position, Velocity >::isReplaying(), and animal::History< Position, Velocity >::state_list.

template<class Position, class Velocity>
void animal::History< Position, Velocity >::push_back double  t,
Position  p,
Velocity  v
[inline]
 

Append current state and time to the history.

Definition at line 60 of file history.h.

References animal::History< Position, Velocity >::cursor, animal::History< Position, Velocity >::isRecording(), and animal::History< Position, Velocity >::state_list.

Referenced by animal::HistoryV< Position, Velocity >::read(), and animal::HistoryS< Position, Velocity >::read().

template<class Position, class Velocity>
virtual void animal::History< Position, Velocity >::read std::istream &  in  )  [pure virtual]
 

Read the whole history from the given input stream. No comments are allowed.

Implemented in animal::HistoryS< Position, Velocity >, and animal::HistoryV< Position, Velocity >.

template<class Position, class Velocity>
void animal::History< Position, Velocity >::reset  )  [inline]
 

Sets the cursor to initial state.

Definition at line 71 of file history.h.

References animal::History< Position, Velocity >::cursor, and animal::History< Position, Velocity >::state_list.

Referenced by animal::HistoryV< Position, Velocity >::read(), and animal::HistoryS< Position, Velocity >::read().

template<class Position, class Velocity>
double animal::History< Position, Velocity >::t  )  const [inline]
 

Time associated with current state.

Definition at line 96 of file history.h.

References animal::History< Position, Velocity >::cursor.

template<class Position, class Velocity>
void animal::History< Position, Velocity >::toggleRecord bool  b  )  [inline]
 

Toggle record on/off.

Definition at line 105 of file history.h.

References animal::History< Position, Velocity >::record, and animal::History< Position, Velocity >::replay.

Referenced by animal::HistoryV< Position, Velocity >::read(), and animal::HistoryS< Position, Velocity >::read().

template<class Position, class Velocity>
void animal::History< Position, Velocity >::toggleReplay bool  b  )  [inline]
 

Toggle replay on/off.

Definition at line 114 of file history.h.

References animal::History< Position, Velocity >::record, and animal::History< Position, Velocity >::replay.

template<class Position, class Velocity>
virtual void animal::History< Position, Velocity >::write std::ostream &  out  )  const [pure virtual]
 

Write the whole history to the given output stream.

Implemented in animal::HistoryS< Position, Velocity >, and animal::HistoryV< Position, Velocity >.


Member Data Documentation

template<class Position, class Velocity>
List::iterator animal::History< Position, Velocity >::cursor [private]
 

Points to the current key.

Definition at line 42 of file history.h.

Referenced by animal::History< Position, Velocity >::copyStateTo(), animal::History< Position, Velocity >::History(), animal::History< Position, Velocity >::operator++(), animal::History< Position, Velocity >::operator--(), animal::History< Position, Velocity >::push_back(), animal::History< Position, Velocity >::reset(), and animal::History< Position, Velocity >::t().

template<class Position, class Velocity>
bool animal::History< Position, Velocity >::record [private]
 

true iff recording

Definition at line 43 of file history.h.

Referenced by animal::History< Position, Velocity >::History(), animal::History< Position, Velocity >::isRecording(), animal::History< Position, Velocity >::toggleRecord(), and animal::History< Position, Velocity >::toggleReplay().

template<class Position, class Velocity>
bool animal::History< Position, Velocity >::replay [private]
 

true iff replaying

Definition at line 44 of file history.h.

Referenced by animal::History< Position, Velocity >::History(), animal::History< Position, Velocity >::isReplaying(), animal::History< Position, Velocity >::toggleRecord(), and animal::History< Position, Velocity >::toggleReplay().

template<class Position, class Velocity>
List animal::History< Position, Velocity >::state_list [protected]
 

Store the keys.

Definition at line 130 of file history.h.

Referenced by animal::History< Position, Velocity >::History(), animal::History< Position, Velocity >::operator++(), animal::History< Position, Velocity >::operator--(), animal::History< Position, Velocity >::push_back(), and animal::History< Position, Velocity >::reset().


The documentation for this class was generated from the following file:
Generated on Thu Dec 23 13:52:29 2004 by doxygen 1.3.6