#include <timer.hpp>
Public Types | |
typedef boost::shared_ptr< Timer > | TimerPtr |
Smart pointer that clients should use. | |
Public Member Functions | |
bool | start (const SimTime &delay) const |
Starts the timer running. | |
bool | stop () const |
Stops the timer. | |
bool | reschedule (const SimTime &delay) const |
Reschedules the timer for the new delay. | |
bool | isRunning () const |
Check if the timer is currently running. | |
SimTime | timeRemaining () const |
Get the time remaining on the timer. | |
void | setEvent (const EventPtr eventOnFire) |
Change the event executed when the timer fires. | |
Static Public Member Functions | |
static TimerPtr | create (NodePtr owner, EventPtr eventOnFire) |
A factory method to ensure that all objects are created via new since we are using smart pointers. | |
Protected Member Functions | |
Timer (NodePtr owner, EventPtr eventOnFire) | |
A constructor. |
An event is set for the timer and then the functions control the timer's operation for when the event is executed.
Definition at line 19 of file timer.hpp.
Timer::Timer | ( | NodePtr | owner, | |
EventPtr | eventOnFire | |||
) | [protected] |
TimerPtr Timer::create | ( | NodePtr | owner, | |
EventPtr | eventOnFire | |||
) | [inline, static] |
A factory method to ensure that all objects are created via new
since we are using smart pointers.
owner | the node that owns this timer. | |
eventOnFire | the event that will be executed whenever this timer fires. |
Definition at line 135 of file timer.hpp.
References Timer().
Referenced by RfidTagMac::create(), RfidReaderMac::create(), RfidReaderApp::create(), PhysicalLayer::PhysicalLayer(), and MacProtocol::startSendTimer().
bool Timer::isRunning | ( | ) | const [inline] |
Check if the timer is currently running.
The timer is considered to be running if the timer's event is currently in an event queue.
Definition at line 177 of file timer.hpp.
Referenced by reschedule(), setEvent(), start(), stop(), and timeRemaining().
bool Timer::reschedule | ( | const SimTime & | delay | ) | const [inline] |
Reschedules the timer for the new delay.
The new value is scheduled regardless of whether the timer is running. If it is running, the timer is stopped and then started with the new value.
Definition at line 165 of file timer.hpp.
References isRunning(), start(), and stop().
void Timer::setEvent | ( | const EventPtr | eventOnFire | ) |
Change the event executed when the timer fires.
If the timer is currently running, it will be stopped and then the new event added to the timer. If the new event needs to be scheduled, start() must be called separately.
eventOnFire | the event that will be executed whenever the timer fires. |
Definition at line 14 of file timer.cpp.
References isRunning(), and stop().
bool Timer::start | ( | const SimTime & | delay | ) | const [inline] |
Starts the timer running.
The event is not scheduled if the timer is already running. In this case, reschedule() should be used instead.
delay | the time in the future when the event will be executed. If the current clock value for the node is currentTime(), the event will be executed at currentTime() + delay. |
Definition at line 141 of file timer.hpp.
References isRunning().
Referenced by reschedule().
bool Timer::stop | ( | ) | const [inline] |
Stops the timer.
The timer is stopped if it is currently running.
Definition at line 153 of file timer.hpp.
References isRunning().
Referenced by reschedule(), and setEvent().
SimTime Timer::timeRemaining | ( | ) | const [inline] |
Get the time remaining on the timer.
Definition at line 183 of file timer.hpp.
References isRunning(), and SimTime::isValid().