BUGFIX: Elevators did not handle Requests in the correct order
[cs356-p1-elevator.git] / elevatorgui.hpp
1 #ifndef ELEVATORGUI_HPP
2 #define ELEVATORGUI_HPP
3
4 #include <gtkmm.h>
5 #include <iostream>
6 #include <iomanip>
7 #include <vector>
8 #include <sstream>
9
10 #include "elevatorcontroller.hpp"
11
12 #include "elevatordoor.hpp"
13 #include "callbutton.hpp"
14 #include "positionlabel.hpp"
15 #include "requestbutton.hpp"
16
17
18 typedef std::vector<CallButton*> CallButtonVector;
19 typedef std::vector<PositionLabel*> PositionLabelVector;
20 typedef std::vector<RequestButton*> RequestButtonVector;
21 typedef std::vector<ElevatorDoor*> ElevatorDoorVector;
22
23
24 class ElevatorGUI : public Gtk::Window
25 {
26         public:
27                 ElevatorGUI (int floors, int elevators);
28
29                 /* Functions to be called from Elevator to change GUI status */
30                 void gui_update_position_label (int elevator, float new_position, Direction direction);
31                 void gui_unpress_call_button (int floor, Direction direction);
32                 void gui_unpress_request_button (int elevator, int floor);
33                 void gui_open_door (int elevator, int floor);
34                 void gui_close_door (int elevator, int floor);
35
36         private:
37                 /* Callbacks from button presses */
38                 void on_call_button_toggled (CallButton *button);
39                 void on_request_button_toggled (RequestButton *button);
40                 void on_playpause_button_clicked ();
41                 void on_quit_button_clicked ();
42
43                 /* Timer Function */
44                 bool on_timer_tick ();
45                 sigc::connection timer_;
46                 static const int timer_tick_ms_ = 500;
47
48                 int number_of_floors_;
49                 int number_of_elevators_;
50
51                 enum { RUNNING, PAUSED } simulation_status_;
52                 
53                 ElevatorController ec_;
54
55                 // holds custom CallButton which knows it's direction and floor#
56                 CallButtonVector call_buttons_;
57
58                 // holds custom position label which knows it's elevator#
59                 PositionLabelVector position_labels_;
60
61                 // holds custom RequestButton which knows it's elevator# and floor#
62                 RequestButtonVector request_buttons_;
63
64                 // holds custom ElevatorDoor which knows it's elevator# and floor#
65                 ElevatorDoorVector elevator_doors_;
66
67                 // Holds the Play / Pause button and Quit button
68                 Gtk::Button button_playpause_, button_quit_;
69
70                 // Holds the Table which holds everything
71                 Gtk::Table table_;
72 };
73
74 #endif /* ELEVATORGUI_HPP */
75
76 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */