Austin Schuh | e1dafe4 | 2020-01-06 21:12:03 -0800 | [diff] [blame] | 1 | #include "aos/events/simple_channel.h" |
| 2 | |
| 3 | #include "absl/strings/str_cat.h" |
| 4 | #include "glog/logging.h" |
| 5 | |
| 6 | namespace aos { |
| 7 | |
| 8 | SimpleChannel::SimpleChannel(const Channel *channel) |
| 9 | : name(CHECK_NOTNULL(CHECK_NOTNULL(channel)->name())->str()), |
| 10 | type(CHECK_NOTNULL(CHECK_NOTNULL(channel)->type())->str()) {} |
| 11 | |
| 12 | std::string SimpleChannel::DebugString() const { |
| 13 | return absl::StrCat("{ ", name, ", ", type, "}"); |
| 14 | } |
| 15 | |
| 16 | bool SimpleChannel::operator==(const SimpleChannel &other) const { |
| 17 | return name == other.name && type == other.type; |
| 18 | } |
| 19 | |
| 20 | bool SimpleChannel::operator<(const SimpleChannel &other) const { |
| 21 | int name_compare = other.name.compare(name); |
| 22 | if (name_compare == 0) { |
| 23 | return other.type < type; |
| 24 | } else if (name_compare < 0) { |
| 25 | return true; |
| 26 | } else { |
| 27 | return false; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | } // namespace aos |