1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-08 13:11:49 +00:00

Add more reflexivity to client/server interfaces

This commit is contained in:
TuxSH 2018-11-05 23:53:29 +01:00 committed by Michael Scire
parent e2d8316401
commit ac6762bb6c
6 changed files with 38 additions and 20 deletions

View file

@ -4,22 +4,26 @@
#include <mesosphere/core/types.hpp>
#include <mesosphere/interfaces/IClientServerParent.hpp>
#define MESOSPHERE_CLIENT_TRAITS(ParentId) using ParentClass = K##ParentId;
namespace mesosphere
{
struct IClientTag {};
template<typename Parent, typename Client, typename Server>
class IClient {
class IClient : public IClientTag {
public:
using ParentType = Parent;
using ClientType = Client;
using ServerType = Server;
using ParentClass = Parent;
using ClientClass = Client;
using ServerClass = Server;
~IClient()
{
parent->HandleClientDestroyed();
}
ParentType *GetParent() const { return parent; }
ParentClass *GetParent() const { return parent; }
void SetParent(SharedPtr<Parent> parent)
{
@ -30,4 +34,4 @@ class IClient {
SharedPtr<Parent> parent{};
};
}
}

View file

@ -2,15 +2,21 @@
#include <mesosphere/core/types.hpp>
#define MESOSPHERE_CLIENT_SERVER_PARENT_TRAITS(ClientId, ServerId)\
using ClientClass = K##ClientId;\
using ServerClass = K##ServerId;
namespace mesosphere
{
struct IClientServerParentTag {};
template<typename Parent, typename Client, typename Server>
class IClientServerParent {
class IClientServerParent : public IClientServerParentTag {
public:
using ParentType = Parent;
using ClientType = Client;
using ServerType = Server;
using ParentClass = Parent;
using ClientClass = Client;
using ServerClass = Server;
void SetClientServerParent()
{
@ -21,8 +27,8 @@ class IClientServerParent {
protected:
ClientType client{};
ServerType server{};
ClientClass client{};
ServerClass server{};
};
}

View file

@ -4,22 +4,26 @@
#include <mesosphere/core/types.hpp>
#include <mesosphere/interfaces/IClientServerParent.hpp>
#define MESOSPHERE_SERVER_TRAITS(ParentId) using ParentClass = K##ParentId;
namespace mesosphere
{
struct IServerTag {};
template<typename Parent, typename Client, typename Server>
class IServer {
class IServer : public IServerTag {
public:
using ParentType = Parent;
using ClientType = Client;
using ServerType = Server;
using ParentClass = Parent;
using ClientClass = Client;
using ServerClass = Server;
~IServer()
{
parent->HandleServerDestroyed();
}
ParentType *GetParent() const { return parent; }
ParentClass *GetParent() const { return parent; }
void SetParentAndClient(SharedPtr<Parent> parent, SharedPtr<Client> client)
{
@ -33,4 +37,4 @@ class IServer {
SharedPtr<Client> client{};
};
}
}

View file

@ -21,6 +21,7 @@ class KEvent final :
public ILimitedResource<KEvent> {
public:
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Event);
MESOSPHERE_CLIENT_SERVER_PARENT_TRAITS(ReadableEvent, WritableEvent);
virtual ~KEvent();

View file

@ -13,9 +13,11 @@ namespace mesosphere
class KWritableEvent;
class KEvent;
class KReadableEvent final : public KSynchronizationObject, public IClient<KEvent, KReadableEvent, KWritableEvent> {
// Inherited by KInterruptEvent
class KReadableEvent : public KSynchronizationObject, public IClient<KEvent, KReadableEvent, KWritableEvent> {
public:
MESOSPHERE_AUTO_OBJECT_TRAITS(SynchronizationObject, ReadableEvent);
MESOSPHERE_CLIENT_TRAITS(Event);
virtual bool IsAlive() const override { return true; }

View file

@ -15,7 +15,8 @@ class KEvent;
class KWritableEvent final : public KAutoObject, public IServer<KEvent, KReadableEvent, KWritableEvent> {
public:
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, WritableEvent);
MESOSPHERE_SERVER_TRAITS(Event);
virtual bool IsAlive() const override { return true; }
virtual ~KWritableEvent();