TmTimer Class Reference
[Scheduler]

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 (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.
void post (std::string event_time, EvEvent *me)
 post an event to be scheduled by the timer with no repetition
void post (std::string event_time, Repeat rep, EvEvent *me)
 post an event to be scheduled by the timer
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 (const TmTimer &t)
 copy constructor
 TmTimer (std::string type, std::string name)
 the constructor requires the type and name
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.
void updtimer (std::vector< TmParam > params)
 set a number of parameter values in the timer.
void updtimer (TmParam &param)
 set a particular parameter value in the timer.
virtual void updtimer (std::string cname, TmControlValue value)
 set a particular parameter value in the timer.

Protected Member Functions

void init ()
 post constructor initialization

Protected Attributes

unsigned long cur_time_
 the current time count
std::string name_
 given name identifier of the timer
std::string type_
 type of the timer or class name

Private Attributes

std::map< std::string, EvEvent * > events_
 map for events to allow modifying events while in the heap
Heap< EvEvent,
EvEventDispatchComparator
pq_
 heap containing the scheduled events


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 ( const TmTimer t  ) 

copy constructor

Parameters:
t timer to copy

Definition at line 42 of file TmTimer.cpp.

References TmTimer::cur_time_, TmTimer::name_, and TmTimer::type_.


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.

References EvEvent::dispatch(), EvEvent::doRepeat(), TmTimer::eventPending(), TmTimer::events_, EvEvent::getPrefix(), TmTimer::post(), TmTimer::pq_, and EvEvent::repeat().

Referenced by TmTimer::trigger().

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.

References TmTimer::getTime(), and TmTimer::pq_.

Referenced by TmTimer::dispatch().

mrs_string getName (  ) 

get the timer identifier, ie "foo"

Returns:
the type name

Definition at line 64 of file TmTimer.cpp.

References TmTimer::name_.

mrs_string getPrefix (  ) 

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

Returns:
the prefix name

Definition at line 76 of file TmTimer.cpp.

References TmTimer::name_, and TmTimer::type_.

mrs_natural getTime (  ) 

the current count of this timer

Returns:
the current timer count

Definition at line 82 of file TmTimer.cpp.

References TmTimer::cur_time_.

Referenced by TmTimer::eventPending(), and TmTimer::post().

mrs_string getType ( void   ) 

get the timer type name, ie "TmSampleCount"

Returns:
the type name

Definition at line 70 of file TmTimer.cpp.

References TmTimer::type_.

void init (  )  [protected]

post constructor initialization

this method is called after the constructor in TmTimer is called. This method is empty and may be overriden without a super.init() call.

Definition at line 56 of file TmTimer.cpp.

Referenced by TmTimer::TmTimer().

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:
interval a string representation of the interval.
Returns:
a count relating to the interval width.

Implemented in TmRealTime, TmSampleCount, and TmVirtualTime.

Referenced by EvEvent::doRepeat(), and TmTimer::post().

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:
e an event with scheduling information

Definition at line 156 of file TmTimer.cpp.

References TmTimer::events_, EvEvent::getPrefix(), TmTimer::pq_, and EvEvent::setTimer().

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

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

Parameters:
event_time event dispatch time. Must be meaningful to the concrete timer.
me the event

Definition at line 147 of file TmTimer.cpp.

References TmTimer::getTime(), TmTimer::intervalsize(), TmTimer::post(), EvEvent::setRepeat(), and EvEvent::setTime().

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

post an event to be scheduled by the timer

Parameters:
event_time event dispatch time. Must be meaningful to the concrete timer.
rep repetition information
me the event

Definition at line 136 of file TmTimer.cpp.

References TmTimer::getTime(), TmTimer::intervalsize(), EvEvent::setRepeat(), and EvEvent::setTime().

Referenced by TmTimer::dispatch(), and TmTimer::post().

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 TmRealTime, TmSampleCount, and TmVirtualTime.

Referenced by TmTimer::updtime().

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.

References TmTimer::trigger(), and TmTimer::updtime().

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.

References TmTimer::dispatch().

Referenced by TmTimer::tick().

void updtimer ( std::vector< TmParam params  ) 

set a number of parameter values in the timer.

Parameters:
params a vector containing parameters to update the timer with.

Definition at line 125 of file TmTimer.cpp.

References TmTimer::updtimer().

void updtimer ( TmParam param  ) 

set a particular parameter value in the timer.

Parameters:
param a parameter to update this timer with

Definition at line 119 of file TmTimer.cpp.

References TmParam::cname(), TmTimer::updtimer(), and TmParam::value().

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

set a particular parameter value in the timer.

Parameters:
cname the control path to set
value the value to set cname with

Reimplemented in TmSampleCount, and TmVirtualTime.

Definition at line 110 of file TmTimer.cpp.

References TmControlValue::getSType().

Referenced by TmTimer::updtimer().


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

Generated on Wed May 23 00:02:23 2012 for Marsyas by  doxygen 1.5.6