| 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 #include <tuple> |
| 11 | 12 |
| 12 namespace mojo { | 13 namespace mojo { |
| 13 namespace edk { | 14 namespace edk { |
| 14 namespace ports { | 15 namespace ports { |
| 15 | 16 |
| 16 struct Name { | 17 struct Name { |
| 17 Name(uint64_t v1, uint64_t v2) : v1(v1), v2(v2) {} | 18 Name(uint64_t v1, uint64_t v2) : v1(v1), v2(v2) {} |
| 18 uint64_t v1, v2; | 19 uint64_t v1, v2; |
| 19 }; | 20 }; |
| 20 | 21 |
| 21 inline bool operator==(const Name& a, const Name& b) { | 22 inline bool operator==(const Name& a, const Name& b) { |
| 22 return a.v1 == b.v1 && a.v2 == b.v2; | 23 return a.v1 == b.v1 && a.v2 == b.v2; |
| 23 } | 24 } |
| 25 |
| 24 inline bool operator!=(const Name& a, const Name& b) { | 26 inline bool operator!=(const Name& a, const Name& b) { |
| 25 return !(a == b); | 27 return !(a == b); |
| 26 } | 28 } |
| 29 |
| 30 inline bool operator<(const Name& a, const Name& b) { |
| 31 return std::tie(a.v1, a.v2) < std::tie(b.v1, b.v2); |
| 32 } |
| 33 |
| 27 std::ostream& operator<<(std::ostream& stream, const Name& name); | 34 std::ostream& operator<<(std::ostream& stream, const Name& name); |
| 28 | 35 |
| 29 struct PortName : Name { | 36 struct PortName : Name { |
| 30 PortName() : Name(0, 0) {} | 37 PortName() : Name(0, 0) {} |
| 31 PortName(uint64_t v1, uint64_t v2) : Name(v1, v2) {} | 38 PortName(uint64_t v1, uint64_t v2) : Name(v1, v2) {} |
| 32 }; | 39 }; |
| 33 | 40 |
| 34 const PortName kInvalidPortName = {0, 0}; | 41 const PortName kInvalidPortName = {0, 0}; |
| 35 | 42 |
| 36 struct NodeName : Name { | 43 struct NodeName : Name { |
| 37 NodeName() : Name(0, 0) {} | 44 NodeName() : Name(0, 0) {} |
| 38 NodeName(uint64_t v1, uint64_t v2) : Name(v1, v2) {} | 45 NodeName(uint64_t v1, uint64_t v2) : Name(v1, v2) {} |
| 39 }; | 46 }; |
| 40 | 47 |
| 41 const NodeName kInvalidNodeName = {0, 0}; | 48 const NodeName kInvalidNodeName = {0, 0}; |
| 42 | 49 |
| 43 } // namespace ports | 50 } // namespace ports |
| 44 } // namespace edk | 51 } // namespace edk |
| 45 } // namespace mojo | 52 } // namespace mojo |
| 46 | 53 |
| 47 #endif // MOJO_EDK_SYSTEM_PORTS_NAME_H_ | 54 #endif // MOJO_EDK_SYSTEM_PORTS_NAME_H_ |
| OLD | NEW |