#pragma once #include #include #include #include namespace erebos { class Server { struct Priv; public: Server(const Head &, std::vector> &&); Server(const std::shared_ptr &); ~Server(); const Head & localHead() const; const Bhv & localState() const; const Identity & identity() const; template S & svc(); class PeerList & peerList() const; struct Peer; private: Service & svcHelper(const std::type_info &); const std::shared_ptr p; }; template S & Server::svc() { return dynamic_cast(svcHelper(typeid(S))); } class Peer { public: struct Priv; Peer(const std::shared_ptr & p); ~Peer(); Server server() const; const Storage & tempStorage() const; const PartialStorage & partialStorage() const; std::string name() const; std::optional identity() const; bool hasChannel() const; bool send(UUID, const Ref &) const; bool send(UUID, const Object &) const; bool operator==(const Peer & other) const; bool operator!=(const Peer & other) const; bool operator<(const Peer & other) const; bool operator<=(const Peer & other) const; bool operator>(const Peer & other) const; bool operator>=(const Peer & other) const; private: bool send(UUID, const Ref &, const Object &) const; std::shared_ptr p; }; class PeerList { public: struct Priv; PeerList(); PeerList(const std::shared_ptr & p); ~PeerList(); size_t size() const; Peer at(size_t n) const; void onUpdate(std::function); private: friend Server; const std::shared_ptr p; }; }