Timer Class Reference

Provides an interface to control events based on timers. More...

#include <timer.hpp>

List of all members.

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.


Detailed Description

Provides an interface to control events based on timers.

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.


Constructor & Destructor Documentation

Timer::Timer ( NodePtr  owner,
EventPtr  eventOnFire 
) [protected]

A constructor.

Parameters:
owner the node that owns this timer.
eventOnFire the event that will be executed whenever this timer fires.

Definition at line 4 of file timer.cpp.

Referenced by create().


Member Function Documentation

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.

Parameters:
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.

Returns:
true if the timer's event is in an event queue.
See also:
start()

stop()

reschedule()

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.

Returns:
true if a running timer was sucessfully stopped and and then started with the new delay or a non-running timer was started with the new delay.
See also:
start()

stop()

isRunning()

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.

Parameters:
eventOnFire the event that will be executed whenever the timer fires.
See also:
start()

stop()

reschedule()

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.

Parameters:
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.
Returns:
true if the timer is not already running and the event was successfully scheduled.
See also:
stop()

reschedule()

isRunning()

setEvent()

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.

Returns:
true if the timer is running and the event is successfully cancelled.
See also:
start()

reschedule()

isRunning()

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.

Returns:
the time left until the event is executed or zero if the timer is not running.
See also:
start()

stop()

reschedule()

isRunning()

Definition at line 183 of file timer.hpp.

References isRunning(), and SimTime::isValid().


The documentation for this class was generated from the following files:
Generated on Tue Dec 12 17:04:42 2006 for rfidsim by  doxygen 1.4.7