summaryrefslogtreecommitdiff
path: root/include/erebos/network.h
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2021-01-06 21:52:53 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2021-01-06 21:52:53 +0100
commit381b6505b5afaacc9194168697f6bc93c43d2775 (patch)
tree1190917b6ee40d6f4a74bf724466b3062ab86f4f /include/erebos/network.h
parent96eb8471d11667a56466a6f701d1d23fa64c2225 (diff)
Access services via Server object
Diffstat (limited to 'include/erebos/network.h')
-rw-r--r--include/erebos/network.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/erebos/network.h b/include/erebos/network.h
index d730fb5..a2f989e 100644
--- a/include/erebos/network.h
+++ b/include/erebos/network.h
@@ -4,6 +4,7 @@
#include <erebos/service.h>
#include <functional>
+#include <typeinfo>
namespace erebos {
@@ -13,14 +14,24 @@ public:
Server(const Identity &, std::vector<std::unique_ptr<Service>> &&);
~Server();
+ template<class S> S & svc();
+
class PeerList & peerList() const;
struct Peer;
private:
+ Service & svcHelper(const std::type_info &);
+
struct Priv;
const std::shared_ptr<Priv> p;
};
+template<class S>
+S & Server::svc()
+{
+ return dynamic_cast<S&>(svcHelper(typeid(S)));
+}
+
class Peer
{
public: