diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2019-10-16 17:37:19 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2021-03-04 19:54:17 +0000 |
commit | c77de622dd8ef458f73b1a01a34629a7c4f49358 (patch) | |
tree | da0910c8472e5ab4820c16be3609b8b8bccd1a35 /src/netbase.h | |
parent | b4d22654fe9e90093e643cb7beb896c48a274d47 (diff) |
net: Replace enum CConnMan::NumConnections with enum class ConnectionDirection
Diffstat (limited to 'src/netbase.h')
-rw-r--r-- | src/netbase.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/netbase.h b/src/netbase.h index b225f128e7..751f7eb3f0 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -18,6 +18,7 @@ #include <memory> #include <stdint.h> #include <string> +#include <type_traits> #include <vector> extern int nConnectTimeout; @@ -28,6 +29,22 @@ static const int DEFAULT_CONNECT_TIMEOUT = 5000; //! -dns default static const int DEFAULT_NAME_LOOKUP = true; +enum class ConnectionDirection { + None = 0, + In = (1U << 0), + Out = (1U << 1), + Both = (In | Out), +}; +static inline ConnectionDirection& operator|=(ConnectionDirection& a, ConnectionDirection b) { + using underlying = typename std::underlying_type<ConnectionDirection>::type; + a = ConnectionDirection(underlying(a) | underlying(b)); + return a; +} +static inline bool operator&(ConnectionDirection a, ConnectionDirection b) { + using underlying = typename std::underlying_type<ConnectionDirection>::type; + return (underlying(a) & underlying(b)); +} + class proxyType { public: |