Marsyas  0.5.0-beta1
Public Member Functions
TmTimer Class Reference

Base timer class must be overriden to create new concrete timers. More...

#include <TmTimer.h>

Inherited by TmRealTime, TmSampleCount, and TmVirtualTime.

Public Member Functions

void dispatch ()
 dispatch any events that have become due
bool eventPending ()
 determine if an event has become due for dispatch
std::string getName ()
 get the timer identifier, ie "foo"
std::string getPrefix ()
 get the timer prefix, the combination "type/name"
mrs_natural getTime ()
 the current count of this timer
std::string getType ()
 get the timer type name, ie "TmSampleCount"
virtual mrs_natural intervalsize (std::string interval)=0
 calculate the size of the given time interval.
void post (std::string event_time, Repeat rep, EvEvent *me)
 post an event to be scheduled by the timer
void post (std::string event_time, EvEvent *me)
 post an event to be scheduled by the timer with no repetition
void post (EvEvent *e)
 post an event to be scheduled by the timer. The event should have correct time information otherwise dispatch is unpredictable but probably immediate.
virtual mrs_natural readTimeSrc ()=0
 calculate the time that has passed since last being read.
void tick ()
 called on each buffer passing through the network
 TmTimer (std::string type, std::string name)
 the constructor requires the type and name
 TmTimer (const TmTimer &t)
 copy constructor
virtual void trigger ()
 trigger the timer action.
virtual void updtime ()
 called by tick() prior to events being triggered. This method calls readTimeSrc() and adds the difference since the last tick.
virtual void updtimer (std::string cname, TmControlValue value)
 set a particular parameter value in the timer.
void updtimer (TmParam &param)
 set a particular parameter value in the timer.
void updtimer (std::vector< TmParam > params)
 set a number of parameter values in the timer.
virtual ~TmTimer ()

Detailed Description

Base timer class must be overriden to create new concrete timers.

Author:
inb@cs.uvic.ca

Definition at line 42 of file TmTimer.h.


Constructor & Destructor Documentation

TmTimer ( std::string  type,
std::string  name 
)

the constructor requires the type and name

Definition at line 35 of file TmTimer.cpp.

TmTimer ( const TmTimer t)

copy constructor

Parameters:
ttimer to copy

Definition at line 42 of file TmTimer.cpp.

~TmTimer ( ) [virtual]

Definition at line 53 of file TmTimer.cpp.


Member Function Documentation

void dispatch ( )

dispatch any events that have become due

Events are due for dispatch if their dispatch time is less than or equal to the current time. For each event this method will call the event's dispatch method, check to see if it is to be repeated and, if so, will ensure the necessary bookeeping and repost the event.

Definition at line 172 of file TmTimer.cpp.

bool eventPending ( )

determine if an event has become due for dispatch

Returns:
true if an event is due

Definition at line 166 of file TmTimer.cpp.

mrs_string getName ( )

get the timer identifier, ie "foo"

Returns:
the type name

Definition at line 64 of file TmTimer.cpp.

mrs_string getPrefix ( )

get the timer prefix, the combination "type/name"

Returns:
the prefix name

Definition at line 76 of file TmTimer.cpp.

mrs_natural getTime ( )

the current count of this timer

Returns:
the current timer count

Definition at line 82 of file TmTimer.cpp.

mrs_string getType ( void  )

get the timer type name, ie "TmSampleCount"

Returns:
the type name

Definition at line 70 of file TmTimer.cpp.

virtual mrs_natural intervalsize ( std::string  interval) [pure virtual]

calculate the size of the given time interval.

A concrete timer may wish to support units for the time reference it defines. This method will define these units by recognizing them in the string and calculating the interval width appropriately.

Parameters:
intervala string representation of the interval.
Returns:
a count relating to the interval width.

Implemented in TmSampleCount, TmVirtualTime, and TmRealTime.

void post ( std::string  event_time,
Repeat  rep,
EvEvent me 
)

post an event to be scheduled by the timer

Parameters:
event_timeevent dispatch time. Must be meaningful to the concrete timer.
reprepetition information
methe event

Definition at line 136 of file TmTimer.cpp.

void post ( std::string  event_time,
EvEvent me 
)

post an event to be scheduled by the timer with no repetition

Parameters:
event_timeevent dispatch time. Must be meaningful to the concrete timer.
methe event

Definition at line 147 of file TmTimer.cpp.

void post ( EvEvent e)

post an event to be scheduled by the timer. The event should have correct time information otherwise dispatch is unpredictable but probably immediate.

Parameters:
ean event with scheduling information

Definition at line 156 of file TmTimer.cpp.

virtual mrs_natural readTimeSrc ( ) [pure virtual]

calculate the time that has passed since last being read.

This method is overriden by concrete timers to calculate the amount of time that has passed between timer ticks, or buffers of data.

Returns:
unit count of time passed since last being read.

Implemented in TmSampleCount, TmVirtualTime, and TmRealTime.

void tick ( )

called on each buffer passing through the network

Tick calls readTimeSrc to adjust the current timer count. It then calls the trigger method.

Definition at line 88 of file TmTimer.cpp.

void trigger ( ) [virtual]

trigger the timer action.

Can be overriden to define a custom action of the timer. Normally trigger simply calls the dispatch method, although overriding trigger may be helpful to define pre or post actions around calling the dispatch method.

Definition at line 104 of file TmTimer.cpp.

void updtime ( ) [virtual]

called by tick() prior to events being triggered. This method calls readTimeSrc() and adds the difference since the last tick.

Reimplemented in TmRealTime.

Definition at line 95 of file TmTimer.cpp.

void updtimer ( std::string  cname,
TmControlValue  value 
) [virtual]

set a particular parameter value in the timer.

Parameters:
cnamethe control path to set
valuethe value to set cname with

Reimplemented in TmSampleCount, and TmVirtualTime.

Definition at line 110 of file TmTimer.cpp.

void updtimer ( TmParam param)

set a particular parameter value in the timer.

Parameters:
parama parameter to update this timer with

Definition at line 119 of file TmTimer.cpp.

void updtimer ( std::vector< TmParam params)

set a number of parameter values in the timer.

Parameters:
paramsa vector containing parameters to update the timer with.

Definition at line 125 of file TmTimer.cpp.


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