#include <simlpy/Clock.h>

Public Types | |
|
typedef std::multiset< Event *, EventCmp > | EventList |
| The type of the Event queue. | |
Static Public Member Functions | |
| static bool | 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 Time & | time () |
| |
| static void | setRunning (bool b) |
| Explicitly set the run state of the simulator. | |
| static unsigned int | numEvents () |
| |
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.
| 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.
| 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.
| 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.
| b | The new run state. |
Definition at line 126 of file Clock.h.
Referenced by Terminator::handler(), and sim_run().
1.5.4