// event.h: the Event class, representing representing events within the // simulation model. // // Remember that events are not entities in the same sense as cars and pumps // are, and the event queue does not have the same reality as the car queue. // The event queue is a data structure without a real-world equivalent, while // the car queue is real and you can see it. Events are not quite so imaginary, // but they are certainly less visible than cars. // All the functions of this class are defined right here, so no .cc // file is needed. All the same, you do have to make sure there are // definitions for all the functions that might be needed. In particular, // if you have a class like this one, and leave some function undefined // (other than the pure virtual functions), then even if you only instantiate // child classes, the compiler may be displeased. class Event { private: double time; // the time when the event happens public: // Constructor. Event (double t) : time (t) { } // getTime: return the time of the event. double getTime () { return time; } // makeItHappen: the event routine. // This is a pure virtual function -- notice the "virtual" at the // beginning and the "=0" at the end. Like an abstract method in // Java, a pure virtual function must be implemented by any child // class that is to be instantiated. virtual void makeItHappen () = 0; // setTime: set the time of the event. void setTime (double time) { this->time = time; } };