Simulator Class Reference

The main Simulator which class contains the event queues, nodes, and channels. More...

#include <simulator.hpp>

List of all members.

Public Types

typedef SimulatorSimulatorPtr
 Pointer that clients should use.

Public Member Functions

void addNode (NodePtr nodeToAdd)
 Associate a node with this simulator object.
void runSimulation (const SimTime &stopTime)
 Execute events on the event queue.
SimTime currentTime () const
 Get the current time in the simulator.
bool scheduleEvent (EventPtr eventToSchedule, const SimTime &eventDelay)
 Add an event to the event queue.
bool cancelEvent (EventPtr eventToCancel)
 Cancel an event from the event queue.
void setLogStreamManager (LogStreamManagerPtr logStreamManager) const
 Set the simulator's log stream manager.
LogStreamManagerPtr getLogStreamManager () const
 Get a pointer to the simulator's log stream manager.
void seedRandNumGenerator (const t_uint seed) const
 Seed the random number generator.
RandNumGeneratorPtr getRandNumGenerator () const
 Get a pointer to the simulator's random number generator.
void reset ()
 Reset the state of the simulator to its initial state.
void addSimulationEndListener (SimulationEndListenerPtr listener)
 Add a listener that will be notified when the simulation ends.

Static Public Member Functions

static SimulatorPtr instance ()
 The class uses the Singleton design pattern.


Detailed Description

The main Simulator which class contains the event queues, nodes, and channels.

Definition at line 244 of file simulator.hpp.


Member Function Documentation

void Simulator::addNode ( NodePtr  nodeToAdd  )  [inline]

Associate a node with this simulator object.

Parameters:
nodeToAdd the node that will be associated.

Definition at line 422 of file simulator.hpp.

void Simulator::addSimulationEndListener ( SimulationEndListenerPtr  listener  )  [inline]

Add a listener that will be notified when the simulation ends.

Parameters:
listener a pointer to the object to be notified.

Definition at line 513 of file simulator.hpp.

Referenced by RfidTagPhy::create(), RfidTagMac::create(), RfidTagApp::create(), RfidReaderPhy::create(), RfidReaderMac::create(), RfidReaderApp::create(), and LinkLayer::create().

bool Simulator::cancelEvent ( EventPtr  eventToCancel  )  [inline]

Cancel an event from the event queue.

If the event pointer exists in the queue, it is removed.

Parameters:
eventToCancel a pointer to the event being cancelled.
Returns:
true if the event was found and erased.
See also:
scheduleEvent()

currentTime()

runSimulation()

Definition at line 446 of file simulator.hpp.

Referenced by Node::cancelEvent().

SimTime Simulator::currentTime (  )  const [inline]

Get the current time in the simulator.

Returns:
The current time in the simulator.

Definition at line 417 of file simulator.hpp.

Referenced by Node::currentTime(), RfidReaderApp::doReadProcess(), Ricean::fadingFactor(), RfidReaderApp::getNextReadTime(), RfidReaderApp::handleRecvdPacket(), scheduleEvent(), ApplicationLayer::start(), and ApplicationLayer::stop().

LogStreamManagerPtr Simulator::getLogStreamManager (  )  const [inline]

Get a pointer to the simulator's log stream manager.

Returns:
pointer to the simulator's log stream manager.

Definition at line 480 of file simulator.hpp.

RandNumGeneratorPtr Simulator::getRandNumGenerator (  )  const [inline]

Get a pointer to the simulator's random number generator.

Returns:
pointer to the simulator's random number generator.

Definition at line 474 of file simulator.hpp.

Referenced by Ricean::fadingFactor(), and RfidTagMac::handleRequestPacket().

SimulatorPtr Simulator::instance (  )  [inline, static]

The class uses the Singleton design pattern.

Returns:
Pointer to single instance of Simulator

Definition at line 486 of file simulator.hpp.

Referenced by Node::cancelEvent(), RfidTagPhy::create(), RfidTagMac::create(), RfidTagApp::create(), RfidReaderPhy::create(), RfidReaderMac::create(), RfidReaderApp::create(), LinkLayer::create(), Node::currentTime(), RfidReaderApp::doReadProcess(), Ricean::fadingFactor(), RfidReaderApp::getNextReadTime(), RfidReaderApp::handleRecvdPacket(), RfidTagMac::handleRequestPacket(), Node::scheduleEvent(), ApplicationLayer::start(), and ApplicationLayer::stop().

void Simulator::reset (  ) 

Reset the state of the simulator to its initial state.

This clears the event queue and resets the clock to the original start time.

Definition at line 40 of file simulator.cpp.

References SimTime::setTime().

void Simulator::runSimulation ( const SimTime stopTime  ) 

Execute events on the event queue.

While the event queue is not empty, this will continue to pop and execute events. After the simulation object is set up, this is called to start executing the events. The event queue is in ascending order by the execution time of events.

Parameters:
stopTime the time at which the simulation should stop.
See also:
scheduleEvent()

Definition at line 19 of file simulator.cpp.

bool Simulator::scheduleEvent ( EventPtr  eventToSchedule,
const SimTime eventDelay 
) [inline]

Add an event to the event queue.

The event is pushed onto the event queue and scheduled to fire after eventDelay in the future.

Parameters:
eventToSchedule a pointer to the event being scheduled.
eventDelay how far in the future the event should be scheduled. eventDelay is added to the currentTime to schedule the time at which the event will fire.
Returns:
true if event was scheduled succesfully.
See also:
cancelEvent()

currentTime()

runSimulation()

Definition at line 427 of file simulator.hpp.

References currentTime().

Referenced by Node::scheduleEvent(), ApplicationLayer::start(), and ApplicationLayer::stop().

void Simulator::seedRandNumGenerator ( const t_uint  seed  )  const

Seed the random number generator.

Parameters:
seed the new seed.
See also:
getRandNumGenerator()

Definition at line 34 of file simulator.cpp.

void Simulator::setLogStreamManager ( LogStreamManagerPtr  logStreamManager  )  const [inline]

Set the simulator's log stream manager.

Parameters:
logStreamManager a pointer to the simulator's log stream manager.


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