Clock Class Reference
[sim]

Main simulator engine. More...

#include <simlpy/Clock.h>

Collaboration diagram for Clock:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::multiset< Event *,
EventCmp
EventList
 The type of the Event queue.

Static Public Member Functions

static bool running ()
 
Returns:
whether the simulator is currently running

static void schedule (Event *e)
 Add an Event to the queue, taking ownership of the memory.
static void tentative (Event *e)
 Add an Event to the tentative queue, taking ownership of the memory.
static void tick ()
 Consume the Event queue.
static const Timetime ()
 
Returns:
the current simulator time

static void setRunning (bool b)
 Explicitly set the run state of the simulator.
static unsigned int numEvents ()
 
Returns:
the number of Events enqueued


Detailed Description

Main simulator engine.

This class keeps track of time and the Event queue. The clock "ticks" by going to the chronologically next Event, which is then processed and deleted. All data and methods are static, since there is only one global clock.

Clock is running as long as there are Events in its queue to process and it hasn't been told not to run.

Definition at line 76 of file Clock.h.


Member Function Documentation

void Clock::schedule ( Event e  )  [static]

Add an Event to the queue, taking ownership of the memory.

If the event e is in the past, it is immediately deleted without being added to the queue. Otherwise, it is added at the appropriate place in the queue based on its schedule time.

Parameters:
e An Event to schedule.

Definition at line 56 of file Clock.cc.

References Event::time().

Referenced by dtn_stats(), WrapNode::emit(), WrapLink::emit(), TrafficGenerator::emit(), Mobility::MobileNode::emit(), UniformBundleMaker::generate(), HeavyTailBundleMaker::generate(), RF::RFLink::handler(), WrapNode::handler(), WrapLink::handler(), GStatDump::handler(), NamTracer::link(), NamTracer::node(), SampleAppNS::SampleApp::send(), SimLink::send(), sim_schedule(), and Terminator::stopAt().

void Clock::tentative ( Event e  )  [static]

Add an Event to the tentative queue, taking ownership of the memory.

If the event e is in the past, it is immediately deleted without being added to the queue. Otherwise, it is added at the appropriate place in the queue based on its schedule time. This queue is for Events that should only be run if the simulator is triggered again. That is, they should not, of themselves, cause simulation to continue.

Parameters:
e An Event to schedule.

Definition at line 75 of file Clock.cc.

References Event::time().

Referenced by TrafficGenerator::handler(), GStatDump::handler(), Mobility::MobileNode::handler(), Mobility::RandomWaypointNode::setWaypoint(), and Mobility::MobileNode::trigger().

void Clock::tick (  )  [static]

Consume the Event queue.

The head of the queue is popped, processed, and deleted. If the queue is empty, the run state is set to false.

Definition at line 94 of file Clock.cc.

References Event::handle(), and Event::time().

Referenced by sim_run().

static void Clock::setRunning ( bool  b  )  [inline, static]

Explicitly set the run state of the simulator.

Parameters:
b The new run state.

Definition at line 126 of file Clock.h.

Referenced by Terminator::handler(), and sim_run().


The documentation for this class was generated from the following files:
Generated on Mon Mar 24 11:15:47 2008 for Pydtn Simulator by  doxygen 1.5.4