meso: Client/server ifaces: use friendship

This commit is contained in:
TuxSH 2018-11-10 23:03:06 +01:00 committed by Michael Scire
parent b6bbc4f3e5
commit d9c97983a3
4 changed files with 13 additions and 23 deletions

View File

@ -21,15 +21,11 @@ class IClient : public IClientTag {
void *operator new(size_t sz) noexcept = delete;
void operator delete(void *ptr) noexcept {}
const SharedPtr<Parent>& GetParent() const { return parent; }
void SetParent(SharedPtr<Parent> parent)
{
this->parent = std::move(parent);
}
const SharedPtr<ParentClass>& GetParent() const { return parent; }
protected:
SharedPtr<Parent> parent{};
friend class IClientServerParent<ParentClass, ClientClass, ServerClass>;
SharedPtr<ParentClass> parent{};
};
}

View File

@ -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{};
};

View File

@ -21,16 +21,11 @@ class IServer : public IServerTag {
void *operator new(size_t sz) noexcept = delete;
void operator delete(void *ptr) noexcept {};
const SharedPtr<Parent> &GetParent() const { return parent; }
void SetParentAndClient(SharedPtr<Parent> parent)
{
this->parent = std::move(parent);
}
const SharedPtr<ParentClass> &GetParent() const { return parent; }
protected:
SharedPtr<Parent> parent{};
friend class IClientServerParent<ParentClass, ClientClass, ServerClass>;
SharedPtr<ParentClass> parent{};
};
}

View File

@ -2,7 +2,6 @@
#include <mesosphere/core/util.hpp>
#include <mesosphere/core/Result.hpp>
#include <mesosphere/core/KAutoObject.hpp>
#include <mesosphere/core/KSynchronizationObject.hpp>
#include <mesosphere/interfaces/IClient.hpp>