AnimaL |
Tutorial |
Documentation |
#include <history.h>
Inheritance diagram for animal::History< Position, Velocity >:
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< Key > | List |
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 |
|
Store the keys for replay.
Reimplemented in animal::HistoryS< Position, Velocity >, and animal::HistoryV< Position, Velocity >. |
|
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. |
|
Base destructor does nothing.
|
|
Copy current state to the parameter.
Definition at line 99 of file history.h. References animal::History< Position, Velocity >::cursor. |
|
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(). |
|
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--(). |
|
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. |
|
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. |
|
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(). |
|
Read the whole history from the given input stream. No comments are allowed.
Implemented in animal::HistoryS< Position, Velocity >, and animal::HistoryV< Position, Velocity >. |
|
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(). |
|
Time associated with current state.
Definition at line 96 of file history.h. References animal::History< Position, Velocity >::cursor. |
|
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(). |
|
Toggle replay on/off.
Definition at line 114 of file history.h. References animal::History< Position, Velocity >::record, and animal::History< Position, Velocity >::replay. |
|
Write the whole history to the given output stream.
Implemented in animal::HistoryS< Position, Velocity >, and animal::HistoryV< Position, Velocity >. |
|
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(). |
|
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(). |
|
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(). |
|
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(). |