Public Member Functions | |
virtual void | init (cModule *parent) |
void | setTimer (unsigned int index, simtime_t when) |
unsigned int | setTimer (simtime_t when) |
void | cancelTimer (unsigned int index) |
float | remainingTimer (unsigned int index) |
virtual void | handleTimer (unsigned int index)=0 |
void | setContextPointer (unsigned int index, void *data) |
void * | contextPointer (unsigned int index) |
void | setContextDestructor (unsigned int index, void(*func)(void *data)) |
void | allocateTimers (unsigned int count) |
void | deleteTimer (unsigned int index) |
Protected Attributes | |
TimerCore * | ct |
cModule * | owner |
Private Member Functions | |
void | checkCT () |
Friends | |
class | TimerCore |
Definition at line 39 of file Timer.h.
void Timer::cancelTimer | ( | unsigned int | index | ) | [inline] |
Cancel an existing timer set by setTimer() If the timer has not been set, or has already fires, this does nothing Must call initTimers() before using.
index | Timer to cancel. Must be between 0 and the value given to initTimers() |
Definition at line 76 of file Timer.h.
References TimerCore::cancelTimer().
{checkCT();ct->cancelTimer(index);}
void* Timer::contextPointer | ( | unsigned int | index | ) | [inline] |
Retreive a "context pointer" refering to some piece of opaque useful data
index | Timer number |
Definition at line 99 of file Timer.h.
References TimerCore::contextPointer().
{checkCT();return ct->contextPointer(index);}
void Timer::init | ( | cModule * | parent | ) | [virtual] |
Modules using Timer should call init() with their "this" pointer, as otherwise other Timer functions will fail.
parent | Timer-using module's "this" pointer |
Definition at line 4 of file Timer.cc.
{ owner = parent; if (ct==NULL) { ct = dynamic_cast<TimerCore*>(cModuleType::get("TimerCore")->createScheduleInit("TimerCore",owner)); ct->init(this); } }
float Timer::remainingTimer | ( | unsigned int | index | ) | [inline] |
Fires on expiration of a timer. Fires after a call to setTimer(). Subclasses should override this.
index | Timer number that fired. Will be between 0 and the value given to initTimers() |
Definition at line 82 of file Timer.h.
References TimerCore::remainingTimer().
{checkCT();return ct->remainingTimer(index);}
void Timer::setContextDestructor | ( | unsigned int | index, | |
void(*)(void *data) | func | |||
) | [inline] |
Provide a destructor function for a "context pointer" such that we can do complete cleanup even if there are still timers remaining at the end of a simulation. Called on end of sim for still scheduled timers.
index | Timer number |
Definition at line 106 of file Timer.h.
References TimerCore::setContextDestructor().
{checkCT();ct->setContextDestructor(index,func);}
void Timer::setContextPointer | ( | unsigned int | index, | |
void * | data | |||
) | [inline] |
Set a "context pointer" refering to some piece of opaque useful data
index | Timer number | |
data | Opaque pointer. Never free'd or dereferenced |
Definition at line 93 of file Timer.h.
References TimerCore::setContextPointer().
{checkCT();ct->setContextPointer(index,data);}
unsigned int Timer::setTimer | ( | simtime_t | when | ) | [inline] |
Set a timer to fire at a point in the future. Auto-generates a timer id. This will not be an id allocated to any other existing timer (either running or finished) but may be an id from a timer deleted by deleteTimer.
when | Time in seconds in the future to fire the timer |
Definition at line 69 of file Timer.h.
References TimerCore::setTimer().
{checkCT();return ct->setTimer(when);}
void Timer::setTimer | ( | unsigned int | index, | |
simtime_t | when | |||
) | [inline] |
Set a timer to fire at a point in the future. If the timer with that id has already been set then this discards the old information.
index | Timer number to set. | |
when | Time in seconds in the future to fire the timer |
Definition at line 61 of file Timer.h.
References TimerCore::setTimer().
{checkCT();ct->setTimer(index,when);}