OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_EDK_SYSTEM_PORTS_NAME_H_ | 5 #ifndef MOJO_EDK_SYSTEM_PORTS_NAME_H_ |
6 #define MOJO_EDK_SYSTEM_PORTS_NAME_H_ | 6 #define MOJO_EDK_SYSTEM_PORTS_NAME_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <ostream> | 10 #include <ostream> |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 namespace edk { | 13 namespace edk { |
14 namespace ports { | 14 namespace ports { |
15 | 15 |
16 struct Name { | 16 struct Name { |
17 Name(uint64_t v1, uint64_t v2) : v1(v1), v2(v2) {} | 17 Name(uint64_t v1, uint64_t v2) : v1(v1), v2(v2) {} |
18 uint64_t v1, v2; | 18 uint64_t v1, v2; |
19 }; | 19 }; |
20 | 20 |
21 inline bool operator==(const Name& a, const Name& b) { | 21 inline bool operator==(const Name& a, const Name& b) { |
22 return a.v1 == b.v1 && a.v2 == b.v2; | 22 return a.v1 == b.v1 && a.v2 == b.v2; |
23 } | 23 } |
24 | |
24 inline bool operator!=(const Name& a, const Name& b) { | 25 inline bool operator!=(const Name& a, const Name& b) { |
25 return !(a == b); | 26 return !(a == b); |
26 } | 27 } |
28 | |
29 inline bool operator<(const Name& a, const Name& b) { | |
30 return a.v1 < b.v1 || (a.v1 == b.v1 && a.v2 < b.v2); | |
Anand Mistry (off Chromium)
2016/02/08 06:23:21
Use std::tie
Ken Rockot(use gerrit already)
2016/02/08 23:20:56
done
| |
31 } | |
32 | |
27 std::ostream& operator<<(std::ostream& stream, const Name& name); | 33 std::ostream& operator<<(std::ostream& stream, const Name& name); |
28 | 34 |
29 struct PortName : Name { | 35 struct PortName : Name { |
30 PortName() : Name(0, 0) {} | 36 PortName() : Name(0, 0) {} |
31 PortName(uint64_t v1, uint64_t v2) : Name(v1, v2) {} | 37 PortName(uint64_t v1, uint64_t v2) : Name(v1, v2) {} |
32 }; | 38 }; |
33 | 39 |
34 const PortName kInvalidPortName = {0, 0}; | 40 const PortName kInvalidPortName = {0, 0}; |
35 | 41 |
36 struct NodeName : Name { | 42 struct NodeName : Name { |
37 NodeName() : Name(0, 0) {} | 43 NodeName() : Name(0, 0) {} |
38 NodeName(uint64_t v1, uint64_t v2) : Name(v1, v2) {} | 44 NodeName(uint64_t v1, uint64_t v2) : Name(v1, v2) {} |
39 }; | 45 }; |
40 | 46 |
41 const NodeName kInvalidNodeName = {0, 0}; | 47 const NodeName kInvalidNodeName = {0, 0}; |
42 | 48 |
43 } // namespace ports | 49 } // namespace ports |
44 } // namespace edk | 50 } // namespace edk |
45 } // namespace mojo | 51 } // namespace mojo |
46 | 52 |
47 #endif // MOJO_EDK_SYSTEM_PORTS_NAME_H_ | 53 #endif // MOJO_EDK_SYSTEM_PORTS_NAME_H_ |
OLD | NEW |