* An "untyped" `PID`, used to encapsulate the process ID for * lower-layer abstractions (eg, when receiving incoming requests) * in the dispatching mechanism. * * @see process::PID */
| 37 | * @see process::PID |
| 38 | */ |
| 39 | struct UPID |
| 40 | { |
| 41 | UPID() = default; |
| 42 | |
| 43 | UPID(const UPID& that) = default; |
| 44 | |
| 45 | UPID(UPID&& that) = default; |
| 46 | |
| 47 | UPID(const char* id_, const net::IP& ip_, uint16_t port_) |
| 48 | : id(id_), address(ip_, port_) { resolve(); } |
| 49 | |
| 50 | UPID(const char* id_, const network::inet::Address& address_) |
| 51 | : id(id_), address(address_) { resolve(); } |
| 52 | |
| 53 | UPID(const std::string& id_, const net::IP& ip_, uint16_t port_) |
| 54 | : id(id_), address(ip_, port_) { resolve(); } |
| 55 | |
| 56 | UPID(const std::string& id_, const network::inet::Address& address_) |
| 57 | : id(id_), address(address_) { resolve(); } |
| 58 | |
| 59 | /*implicit*/ UPID(const char* s); |
| 60 | |
| 61 | /*implicit*/ UPID(const std::string& s); |
| 62 | |
| 63 | /*implicit*/ UPID(const ProcessBase& process); |
| 64 | |
| 65 | UPID& operator=(const UPID& that) = default; |
| 66 | |
| 67 | UPID& operator=(UPID&& that) = default; |
| 68 | |
| 69 | operator std::string() const; |
| 70 | |
| 71 | operator bool() const |
| 72 | { |
| 73 | return id != "" && !address.ip.isAny() && address.port != 0; |
| 74 | } |
| 75 | |
| 76 | bool operator!() const // NOLINT(whitespace/operators) |
| 77 | { |
| 78 | return id == "" && address.ip.isAny() && address.port == 0; |
| 79 | } |
| 80 | |
| 81 | bool operator<(const UPID& that) const |
| 82 | { |
| 83 | if (address == that.address) { |
| 84 | return id < that.id; |
| 85 | } else { |
| 86 | return address < that.address; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | bool operator==(const UPID& that) const |
| 91 | { |
| 92 | return (id == that.id && address == that.address); |
| 93 | } |
| 94 | |
| 95 | bool operator!=(const UPID& that) const |
| 96 | { |