Introduction to OOP | Chapter 21: Software Frameworks : | next | previous | audio | real | text |
class Simulation { public: Simulation () : eventQueue(), currentTime(0) { } void scheduleEvent (event * newEvent) { eventQueue.push (newEvent); } void run(); unsigned int currentTime; protected: priority_queue<vectorThe book continues with the development of a simulation based on this framework., 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; } }