mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
Add more reflexivity to client/server interfaces
This commit is contained in:
parent
e2d8316401
commit
ac6762bb6c
6 changed files with 38 additions and 20 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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{};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ 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; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue