/* events.h
 * 
 * The event class.  Every event has a `time' at which it occurs and
 * a function, handleEvent(), that gets executed at that time.
 *
 * Each specific event is derived from the Event class.  Currently,
 * there are these events:
 *
 *   PassengerAppearance  a passenger appears at a station to take a trip
 *   TrainDeparture       a train leaves a station
 *   Report               a periodic report is generated (screen output)
 *
 * YOU ARE RESPONSIBLE FOR CREATING AN Accident EVENT.
 */


#ifndef EVENTS_H
#define EVENTS_H

#include <iostream.h>


class Scheduler;
class Passenger;
class Station;
class Train;
class Platform;


/* A basic event has a time and a method to handle it.  The
 * handleEvent() method should be defined for each event (see
 * events.C).
 */


class Event {

 friend class Scheduler;

 protected:

  float time;			// time of event
  virtual void handleEvent() = 0;  // function to handle the event
};



/* Event: A passenger appears at a station.
 */


class PassengerAppearanceEvent : public Event {

  Passenger *passenger;
  Station *sourceStation;
  Station *destinationStation;

public:
  
  PassengerAppearanceEvent( float eventTime, Passenger *p, Station *source, Station *dest ) {
    time = eventTime;
    passenger = p;
    sourceStation = source;
    destinationStation = dest;
  }

  void handleEvent();
};


/* Event: all trains advance a bit
 */


class TrainAdvanceEvent : public Event {

public:

  TrainAdvanceEvent( float eventTime ) {
    time = eventTime;
  }

  void handleEvent();
};


/* Event: a train departs from a station.
 */


class TrainDepartureEvent : public Event {

  Train *train;

public:

  TrainDepartureEvent( float eventTime, Train *t ) {
    time = eventTime;
    train = t;
  }

  void handleEvent();
};


/* Event: report by drawing the current scene.
 */


class ReportEvent : public Event {

public:

  ReportEvent( float eventTime ) {
    time = eventTime;
  }

  void handleEvent();
};

#endif
