MIRA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TapePlayer Class Reference

Class for playing back tape files. More...

#include <fw/TapePlayer.h>

Public Member Functions

 TapePlayer ()
 
virtual ~TapePlayer ()
 
template<typename Reflector >
void reflect (Reflector &r)
 
void pause ()
 Pauses the play back. More...
 
bool isPaused () const
 Is the playback paused. More...
 
bool inStepTo () const
 return if we are currently in stepTo mode More...
 
void step ()
 Do a single step. More...
 
void stepTo (Duration time)
 Do a step by playing back all messages between current message time and time. More...
 
bool stepTo (const std::string &channelID)
 Do a step by playing back all messages between current message time and the time of the next message in channel channelID. More...
 
bool stepToAnyOf (const std::vector< std::string > &channelIDs)
 Do a step by playing back all messages between current message time and the time of the next message in any of the channels in channelIDs. More...
 
void stop ()
 Stops play back. More...
 
void setLoop (bool loop, int32 count=-1)
 Turn the loop mode on/off. More...
 
void setTimeScaler (float scaler)
 Set the time scaling factor for play back. More...
 
float getTimeScaler () const
 Get the time scaling factor. More...
 
void load (TapeVisitor *iVisitor, Time startTime=Time::now(), const std::string &prefix="")
 Prepares playing back data from the visitor. More...
 
void play ()
 Starts playing back the messages. More...
 
bool isPlaying () const
 Are we currently in playback mode (i.e. More...
 
bool hasError () const
 When an error occurs during play back this method will return true. More...
 
std::string getErrorMessage () const
 Returns the error message of an error that occurred during play back. More...
 
Duration getCurrentMessageTimeOffset () const
 Get the recorded time offset of the currently played or to be played message (if currently paused the current message will be the one that is played after resume) More...
 
Time getRelativeStartTime () const
 Returns the relative time the player plays back messages to. More...
 
void jumpTo (Duration time)
 Jump to a given message at recorded time offset. More...
 
AuthoritygetAuthority ()
 Return the authority of the player. More...
 

Protected Member Functions

void stepTo (const TapeVisitor::iterator &i)
 
void doPlay ()
 

Protected Attributes

Authority mAuthority
 
boost::thread mThread
 
int32 mLoopCount
 
bool mLoop
 
bool mPause
 
bool mPlayImmediately
 
bool mIsPlaying
 
float mTimeScaler
 
Time mStartTime
 
boost::optional< DurationmJumpTo
 
boost::optional< DurationmStepTo
 
boost::optional
< TapeVisitor::iterator
mStepToChannel
 
boost::optional< std::string > mErrorMessage
 
TapeVisitormVisitor
 
TapeVisitor::iterator mMessage
 
boost::mutex mConditionMutex
 
boost::condition_variable mCondition
 
std::string mNamespacePrefix
 

Detailed Description

Class for playing back tape files.

Constructor & Destructor Documentation

virtual ~TapePlayer ( )
inlinevirtual

Member Function Documentation

void reflect ( Reflector &  r)
inline
void pause ( )
inline

Pauses the play back.

bool isPaused ( ) const
inline

Is the playback paused.

Returns
true if paused
bool inStepTo ( ) const
inline

return if we are currently in stepTo mode

void step ( )
inline

Do a single step.

Will set pause mode. Jumps to the next chronological message to visit

void stepTo ( Duration  time)

Do a step by playing back all messages between current message time and time.

Stopping again at time, setting pause mode. If time is above last message time in tape, this will just start/resume normal playback (same as play()).

bool stepTo ( const std::string &  channelID)

Do a step by playing back all messages between current message time and the time of the next message in channel channelID.

Stopping again at next message time in channel channelID, setting pause mode. By default, returns true; If no such channel or no more messages for it exist, this will just go to the next message immediately and start/resume normal playback (same as play()), then return false.

bool stepToAnyOf ( const std::vector< std::string > &  channelIDs)

Do a step by playing back all messages between current message time and the time of the next message in any of the channels in channelIDs.

Stopping again at next message time in any of the specified channels, setting pause mode. By default, return true. If no such channel or no more messages for any of them exist, this will just just go to the next message immediately and start/resume normal playback (same as play()), then return false;

void stop ( )
inline

Stops play back.

void setLoop ( bool  loop,
int32  count = -1 
)
inline

Turn the loop mode on/off.

Parameters
[in]loopShould the tape be played in loop mode
[in]countHow often should the tape be played back in loop mode (values < 0 = infinite loops (default))
void setTimeScaler ( float  scaler)
inline

Set the time scaling factor for play back.

Parameters
[in]scalerThe scale factor
  • 1 means normal play back,
  • 2 means double speed,
  • 0.5 means half speed
float getTimeScaler ( ) const
inline

Get the time scaling factor.

Returns
Time scaling factor used for playback
void load ( TapeVisitor iVisitor,
Time  startTime = Time::now(),
const std::string &  prefix = "" 
)

Prepares playing back data from the visitor.

Parameters
[in]iVisitorThe visitor used for visiting the messages.
[in]startTimeThe tape is played back relatively to this time.
[in]prefixA namespace prefix. This prefix will be appeded to all channel names.
void play ( )

Starts playing back the messages.

bool isPlaying ( ) const
inline

Are we currently in playback mode (i.e.

a file is opened for playback)

Returns
true if playing
bool hasError ( ) const
inline

When an error occurs during play back this method will return true.

In case of an error the play back is stopped automatically and the isPlaying() method will return false. In this case the error message can be obtained via getErrorMessage()

std::string getErrorMessage ( ) const
inline

Returns the error message of an error that occurred during play back.

Duration getCurrentMessageTimeOffset ( ) const
inline

Get the recorded time offset of the currently played or to be played message (if currently paused the current message will be the one that is played after resume)

Returns
Recorded time offset of the current message in microseconds
Time getRelativeStartTime ( ) const
inline

Returns the relative time the player plays back messages to.

The real message time is defined as relative start time + message time offset.

void jumpTo ( Duration  time)

Jump to a given message at recorded time offset.

Jumps to the message with an offset closest to time.

Parameters
[in]timeThe time offset of the message in microseconds we like to jump to.
Authority* getAuthority ( )
inline

Return the authority of the player.

void stepTo ( const TapeVisitor::iterator i)
protected
void doPlay ( )
protected

Member Data Documentation

Authority mAuthority
protected
boost::thread mThread
protected
int32 mLoopCount
protected
bool mLoop
protected
bool mPause
protected
bool mPlayImmediately
protected
bool mIsPlaying
protected
float mTimeScaler
protected
Time mStartTime
protected
boost::optional<Duration> mJumpTo
protected
boost::optional<Duration> mStepTo
protected
boost::optional<TapeVisitor::iterator> mStepToChannel
protected
boost::optional<std::string> mErrorMessage
protected
TapeVisitor* mVisitor
protected
TapeVisitor::iterator mMessage
protected
boost::mutex mConditionMutex
protected
boost::condition_variable mCondition
protected
std::string mNamespacePrefix
protected

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