Subversion Repositories programming

Rev

Rev 338 | Rev 344 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
338 ira 1
/*******************************************************************************
2
 * controller.h
3
 *
4
 * Header file for the Controller class.
5
 *
6
 * Copyright 2006, Ira W. Snyder (devel@irasnyder.com)
7
 ******************************************************************************/
321 ira 8
 
9
#ifndef CONTROLLER_H
10
#define CONTROLLER_H
11
 
12
#include <assert.h>
13
#include <vector>
328 ira 14
#include <limits.h>
15
#include <math.h>
332 ira 16
#include <cstdio>
340 ira 17
 
321 ira 18
#include "elevator.h"
340 ira 19
#include "elevator_window.h"
321 ira 20
 
331 ira 21
class Elevator;
340 ira 22
class Elevator_Window;
331 ira 23
 
321 ira 24
class Controller
25
{
26
    public:
27
        Controller (int num_floors, int num_elevators);
28
        ~Controller ();
29
 
331 ira 30
        void start_all_elevators ();
31
        void stop_all_elevators ();
32
        void pause_all_elevators ();
33
        void unpause_all_elevators ();
34
 
329 ira 35
        void request_elevator (int on_floor, int direction);
36
        void disable_elevator (int elevator_number);
37
        void enable_elevator (int elevator_number);
321 ira 38
 
340 ira 39
        void stop_at_floor (Elevator *e, int on_floor);
40
        void update_elevator_position (Elevator *e);
41
 
42
        void set_gui (Elevator_Window *gui);
43
 
321 ira 44
    private:
328 ira 45
        bool floor_already_requested (int on_floor);
332 ira 46
        int find_closest_elevator (int to_floor, int in_direction);
340 ira 47
        int which_elevator_is (Elevator *e);
328 ira 48
 
334 ira 49
        std::vector<Elevator*> elevator;
321 ira 50
        int num_floors;
51
        int num_elevators;
340 ira 52
 
53
        Elevator_Window *gui;
321 ira 54
};
55
 
56
#endif // CONTROLLER_H
57