/* controller.h
 */

#ifndef CONTROLLER_H
#define CONTROLLER_H

#include "main.H"

class Elevator;
class Floor;

typedef enum { UP, DOWN, IDLE }	Dir;// an elevator direction


class Controller {

public:

    int is_a_destination( Elevator *elev, Floor *floor );
    void request_elevator( Floor *source, Floor *dest );
    void update_destinations( Elevator *elev, Floor *floor );
    void schedule_next_departure( Elevator *elev );
    void schedule_next_arrival( Elevator *elev, Floor *floor );
    void debug();

    Controller( int num_floors, int num_elevators );

    // requests[ source ][ dest ] = i if there have been
    // i requests to go from floor source to floor dest.
    int requests[MAX_FLOORS][MAX_FLOORS];
    
    // location[ i ] = j if elevator i last stopped on
    // floor j.  It might have left since then.
    int locations[MAX_ELEVS];
    
    // destinations[ i ][ j ] = 1 if elevator i is on
    // its way to floor j; = 0 otherwise.
    int destinations[MAX_ELEVS][MAX_FLOORS];
    
    // directions[ i ] = UP or DOWN or IDLE and is the
    // most recently known travel direction of elevator i.
    Dir directions[MAX_ELEVS];	
};


#endif
