/* events.h
 */


#ifndef EVENTS_H
#define EVENTS_H

#include <iostream.h>
#include "floor.H"
#include "elevator.H"
#include "control.H"
//#include "person.H"

class Scheduler;
class ImpatientPerson;


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

class Event {

    friend class Scheduler;

protected:

    float time;			 // time of event
    virtual void handle_event() {} // function to handle the event
    
public:
    
    virtual void print() {};
    int static compare(Event *e1, Event *e2);
};



/* Event: A person appears at the elevator.  The person wants to go
 * from a source_floor to a dest_floor.  
 */

class PersonAppearance : public Event {

public:
  
    void handle_event();

    PersonAppearance( float event_time, Floor *source, Floor *dest ) {
	time = event_time;
	source_floor = source;
	dest_floor = dest;
    }

private:

    Floor  *source_floor;
    Floor  *dest_floor;
};

/* Event: A person leaves because they are impatient and have given up
 * waiting for an elevator.
 */

class PersonLeave : public Event {
public:
    void handle_event();

    PersonLeave(float event_time, Floor *source, ImpatientPerson *i_person) {
	time = event_time;
	floor = source;
	person = i_person;
    }

private:
    Floor *floor;
    ImpatientPerson *person;
};

/* Event: an elevator arrives at a floor
 */


class ElevatorArrival : public Event {

public:

    void handle_event();

    ElevatorArrival( float event_time, Elevator *elev, Floor *flr ) {
	time = event_time;
	elevator = elev;
	floor = flr;
    }

private:

    Elevator *elevator;
    Floor    *floor;
};


/* Event: an elevator leaves a floor
 */

class ElevatorDeparture : public Event {

public:

    void handle_event();

    ElevatorDeparture( float event_time, Elevator *elev, Floor *dest ) {
	time = event_time;
	elevator = elev;
	dest_floor = dest;
    }

    Elevator *elevator;
    Floor    *dest_floor;
};


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

class ReportEvent : public Event {

public:

    void handle_event();

    ReportEvent( float event_time ) { time = event_time; }
};

#endif
