diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2020-01-06 17:19:24 +0000 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2020-01-07 09:00:45 +0000 |
commit | 150dfba95b9a6352b869804691aa6c07c83ef9df (patch) | |
tree | f187ba5bb7a393ba74cef5f08feba5b4e7656e32 /src/network/network_admin.h | |
parent | 4cc1420beb0470ba076c5f30dbd57b05489b0b1b (diff) | |
download | openttd-150dfba95b9a6352b869804691aa6c07c83ef9df.tar.xz |
Codechange: Remove std::function from Pool iteration wrapper
Add a separate template wrapper for filtered iteration
Diffstat (limited to 'src/network/network_admin.h')
-rw-r--r-- | src/network/network_admin.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/network/network_admin.h b/src/network/network_admin.h index 98dbab481..16bd57a4d 100644 --- a/src/network/network_admin.h +++ b/src/network/network_admin.h @@ -83,15 +83,18 @@ public: return "admin"; } + struct ServerNetworkAdminSocketHandlerFilter { + bool operator() (size_t index) { return ServerNetworkAdminSocketHandler::Get(index)->GetAdminStatus() == ADMIN_STATUS_ACTIVE; } + }; + /** * Returns an iterable ensemble of all active admin sockets * @param from index of the first socket to consider * @return an iterable ensemble of all active admin sockets */ - static Pool::IterateWrapper<ServerNetworkAdminSocketHandler> IterateActive(size_t from = 0) + static Pool::IterateWrapperFiltered<ServerNetworkAdminSocketHandler, ServerNetworkAdminSocketHandlerFilter> IterateActive(size_t from = 0) { - return Pool::IterateWrapper<ServerNetworkAdminSocketHandler>(from, - [](size_t index) { return ServerNetworkAdminSocketHandler::Get(index)->GetAdminStatus() == ADMIN_STATUS_ACTIVE; }); + return Pool::IterateWrapperFiltered<ServerNetworkAdminSocketHandler, ServerNetworkAdminSocketHandlerFilter>(from, ServerNetworkAdminSocketHandlerFilter{}); } }; |