Introduction to OOP Chapter 21: Software Frameworks : next previous audio real text

The Simulation Class

class Simulation {
public:
	Simulation () : eventQueue(), currentTime(0) { }

	void scheduleEvent (event * newEvent) { eventQueue.push (newEvent); }
	void run();
	unsigned int currentTime;
protected:
	priority_queue<vector, eventComparison> eventQueue;
};

void Simulation::run() {
	// execute events until event queue becomes empty
	while (! eventQueue.empty()) {
		event * nextEvent = eventQueue.top();
		eventQueue.pop();
		time = nextEvent->time;
		nextEvent->processEvent();
		delete nextEvent;
	}
}
The book continues with the development of a simulation based on this framework.
Intro OOP, Chapter 21, Slide 17