From d9c97983a34da1ff09f479592a7a405b372440fe Mon Sep 17 00:00:00 2001 From: TuxSH Date: Sat, 10 Nov 2018 23:03:06 +0100 Subject: [PATCH] meso: Client/server ifaces: use friendship --- .../include/mesosphere/interfaces/IClient.hpp | 10 +++------- .../mesosphere/interfaces/IClientServerParent.hpp | 14 +++++++------- .../include/mesosphere/interfaces/IServer.hpp | 11 +++-------- .../mesosphere/processes/KReadableEvent.hpp | 1 - 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/mesosphere/include/mesosphere/interfaces/IClient.hpp b/mesosphere/include/mesosphere/interfaces/IClient.hpp index c2339ea02..81d5c334d 100644 --- a/mesosphere/include/mesosphere/interfaces/IClient.hpp +++ b/mesosphere/include/mesosphere/interfaces/IClient.hpp @@ -21,15 +21,11 @@ class IClient : public IClientTag { void *operator new(size_t sz) noexcept = delete; void operator delete(void *ptr) noexcept {} - const SharedPtr& GetParent() const { return parent; } - - void SetParent(SharedPtr parent) - { - this->parent = std::move(parent); - } + const SharedPtr& GetParent() const { return parent; } protected: - SharedPtr parent{}; + friend class IClientServerParent; + SharedPtr parent{}; }; } diff --git a/mesosphere/include/mesosphere/interfaces/IClientServerParent.hpp b/mesosphere/include/mesosphere/interfaces/IClientServerParent.hpp index 8399c0ea6..491698f6c 100644 --- a/mesosphere/include/mesosphere/interfaces/IClientServerParent.hpp +++ b/mesosphere/include/mesosphere/interfaces/IClientServerParent.hpp @@ -18,18 +18,18 @@ class IClientServerParent : public IClientServerParentTag { using ClientClass = Client; using ServerClass = Server; - void SetClientServerParent() - { - Parent *par = (Parent *)this; - client.SetParent(par); - server.SetParentAndClient(par); - } - ClientClass &GetClient() { return client; } ServerClass &GetServer() { return server; } protected: + void SetClientServerParent() + { + ParentClass *par = (ParentClass *)this; + client.parent = par; + server.parent = par; + } + ClientClass client{}; ServerClass server{}; }; diff --git a/mesosphere/include/mesosphere/interfaces/IServer.hpp b/mesosphere/include/mesosphere/interfaces/IServer.hpp index 5935802de..0e1330b8d 100644 --- a/mesosphere/include/mesosphere/interfaces/IServer.hpp +++ b/mesosphere/include/mesosphere/interfaces/IServer.hpp @@ -21,16 +21,11 @@ class IServer : public IServerTag { void *operator new(size_t sz) noexcept = delete; void operator delete(void *ptr) noexcept {}; - const SharedPtr &GetParent() const { return parent; } - - void SetParentAndClient(SharedPtr parent) - { - this->parent = std::move(parent); - } + const SharedPtr &GetParent() const { return parent; } protected: - - SharedPtr parent{}; + friend class IClientServerParent; + SharedPtr parent{}; }; } diff --git a/mesosphere/include/mesosphere/processes/KReadableEvent.hpp b/mesosphere/include/mesosphere/processes/KReadableEvent.hpp index 6714e3305..103df2996 100644 --- a/mesosphere/include/mesosphere/processes/KReadableEvent.hpp +++ b/mesosphere/include/mesosphere/processes/KReadableEvent.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include