Add the hacks to fix disabling of buttons
[cs356-p1-elevator.git] / stop.cpp
1 #include "stop.hpp"
2
3 Stop::Stop (const Position& position, const Direction& direction)
4         : position_(position)
5         , direction_(direction)
6 {
7         // Intentionally Left Empty
8 }
9
10 bool Stop::operator== (const Stop& rhs) const
11 {
12         if (rhs.position_ != position_)
13                 return false;
14
15 #if 0
16         if (direction_ == ALL || rhs.direction_ == ALL)
17                 return true;
18 #endif
19
20         return (rhs.direction_ == direction_);
21 }
22
23 bool Stop::operator< (const Stop& rhs) const
24 {
25         /* If we do not use the direction to help differentiate, then it is
26          * possible that an object can be neither less, greater, or equal */
27         return (position_ < rhs.position_);
28 }
29
30 bool Stop::operator> (const Stop& rhs) const
31 {
32         return (position_ > rhs.position_);
33 }
34
35 const Direction Stop::getDirection () const
36 {
37         return direction_;
38 }
39
40 const Position Stop::getPosition () const
41 {
42         return position_;
43 }
44
45 std::ostream& operator<< (std::ostream& os, const Stop& rhs)
46 {
47         os << "Stop(" << rhs.position_ << ", "; // << rhs.direction_ << ")";
48
49         switch (rhs.direction_)
50         {
51                 case IDLE:
52                         os << "IDLE";
53                         break;
54                 case UP:
55                         os << "UP";
56                         break;
57                 case DOWN:
58                         os << "DOWN";
59                         break;
60                 case ALL:
61                         os << "ALL";
62                         break;
63                 default:
64                         os << "UNHANDLED";
65                         break;
66         }
67
68         os << ")";
69         return os;
70 }
71
72 /* vim: set ts=4 sts=4 sw=4 noexpandtab textwidth=112: */