From 381b6505b5afaacc9194168697f6bc93c43d2775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 6 Jan 2021 21:52:53 +0100 Subject: Access services via Server object --- src/network.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/network.cpp') diff --git a/src/network.cpp b/src/network.cpp index 91f1923..4b79dcb 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -13,6 +14,7 @@ #include using std::holds_alternative; +using std::runtime_error; using std::scoped_lock; using std::to_string; using std::unique_lock; @@ -26,6 +28,14 @@ Server::Server(const Identity & self, vector> && svcs): Server::~Server() = default; +Service & Server::svcHelper(const std::type_info & tinfo) +{ + for (auto & s : p->services) + if (typeid(*s) == tinfo) + return *s; + throw runtime_error("service not found"); +} + PeerList & Server::peerList() const { return p->plist; -- cgit v1.2.3