d4cb7f7ff7c6628a64bc0de641e8be5f9f4ba994
[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 (direction_ == ALL || rhs.direction_ == ALL)
16                 return true;
17
18         return (rhs.direction_ == direction_);
19 }
20
21 bool Stop::operator< (const Stop& rhs) const
22 {
23         /* If we do not use the direction to help differentiate, then it is
24          * possible that an object can be neither less, greater, or equal */
25         return (position_ < rhs.position_);
26 }
27
28 bool Stop::operator> (const Stop& rhs) const
29 {
30         return (position_ > rhs.position_);
31 }
32
33 const Direction Stop::getDirection () const
34 {
35         return direction_;
36 }
37
38 const Position Stop::getPosition () const
39 {
40         return position_;
41 }
42
43 std::ostream& operator<< (std::ostream& os, const Stop& rhs)
44 {
45         os << "Stop(" << rhs.position_ << ", "; // << rhs.direction_ << ")";
46
47         switch (rhs.direction_)
48         {
49                 case IDLE:
50                         os << "IDLE";
51                         break;
52                 case UP:
53                         os << "UP";
54                         break;
55                 case DOWN:
56                         os << "DOWN";
57                         break;
58                 case ALL:
59                         os << "ALL";
60                         break;
61                 default:
62                         os << "UNHANDLED";
63                         break;
64         }
65
66         os << ")";
67         return os;
68 }
69
70
71 /* vim: set ts=4 sts=4 sw=4 noexpandtab textwidth=112: */