MIRA
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...
 
Duration getCurrentMessageTZOffset () const
 Get the recorded time zone offset of the tape containing 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::iteratormStepToChannel
 
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

◆ TapePlayer()

◆ ~TapePlayer()

virtual ~TapePlayer ( )
inlinevirtual

Member Function Documentation

◆ reflect()

void reflect ( Reflector &  r)
inline

◆ pause()

void pause ( )
inline

Pauses the play back.

◆ isPaused()

bool isPaused ( ) const
inline

Is the playback paused.

Returns
true if paused

◆ inStepTo()

bool inStepTo ( ) const
inline

return if we are currently in stepTo mode

◆ step()

void step ( )
inline

Do a single step.

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

◆ stepTo() [1/3]

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()).

◆ stepTo() [2/3]

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.

◆ stepToAnyOf()

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;

◆ stop()

void stop ( )
inline

Stops play back.

◆ setLoop()

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))

◆ setTimeScaler()

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

◆ getTimeScaler()

float getTimeScaler ( ) const
inline

Get the time scaling factor.

Returns
Time scaling factor used for playback

◆ load()

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.

◆ play()

void play ( )

Starts playing back the messages.

◆ isPlaying()

bool isPlaying ( ) const
inline

Are we currently in playback mode (i.e.

a file is opened for playback)

Returns
true if playing

◆ hasError()

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()

◆ getErrorMessage()

std::string getErrorMessage ( ) const
inline

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

◆ getCurrentMessageTimeOffset()

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

◆ getCurrentMessageTZOffset()

Duration getCurrentMessageTZOffset ( ) const
inline

Get the recorded time zone offset of the tape containing 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 zone offset of the current message in microseconds

◆ getRelativeStartTime()

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.

◆ jumpTo()

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.

◆ getAuthority()

Authority* getAuthority ( )
inline

Return the authority of the player.

◆ stepTo() [3/3]

void stepTo ( const TapeVisitor::iterator i)
protected

◆ doPlay()

void doPlay ( )
protected

Member Data Documentation

◆ mAuthority

Authority mAuthority
protected

◆ mThread

boost::thread mThread
protected

◆ mLoopCount

int32 mLoopCount
protected

◆ mLoop

bool mLoop
protected

◆ mPause

bool mPause
protected

◆ mPlayImmediately

bool mPlayImmediately
protected

◆ mIsPlaying

bool mIsPlaying
protected

◆ mTimeScaler

float mTimeScaler
protected

◆ mStartTime

Time mStartTime
protected

◆ mJumpTo

boost::optional<Duration> mJumpTo
protected

◆ mStepTo

boost::optional<Duration> mStepTo
protected

◆ mStepToChannel

boost::optional<TapeVisitor::iterator> mStepToChannel
protected

◆ mErrorMessage

boost::optional<std::string> mErrorMessage
protected

◆ mVisitor

TapeVisitor* mVisitor
protected

◆ mMessage

TapeVisitor::iterator mMessage
protected

◆ mConditionMutex

boost::mutex mConditionMutex
protected

◆ mCondition

boost::condition_variable mCondition
protected

◆ mNamespacePrefix

std::string mNamespacePrefix
protected

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