blob: 00e30ba25497bed05a90f5548afd38595c07f7e8 [file] [log] [blame]
Austin Schuhe1dafe42020-01-06 21:12:03 -08001#include "aos/events/simple_channel.h"
2
3#include "absl/strings/str_cat.h"
4#include "glog/logging.h"
5
6namespace aos {
7
8SimpleChannel::SimpleChannel(const Channel *channel)
9 : name(CHECK_NOTNULL(CHECK_NOTNULL(channel)->name())->str()),
10 type(CHECK_NOTNULL(CHECK_NOTNULL(channel)->type())->str()) {}
11
12std::string SimpleChannel::DebugString() const {
13 return absl::StrCat("{ ", name, ", ", type, "}");
14}
15
16bool SimpleChannel::operator==(const SimpleChannel &other) const {
17 return name == other.name && type == other.type;
18}
19
20bool 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