diff --git a/mesosphere/include/mesosphere/interfaces/IClient.hpp b/mesosphere/include/mesosphere/interfaces/IClient.hpp index e3a1f8cd7..4e01c7efb 100644 --- a/mesosphere/include/mesosphere/interfaces/IClient.hpp +++ b/mesosphere/include/mesosphere/interfaces/IClient.hpp @@ -4,22 +4,26 @@ #include #include +#define MESOSPHERE_CLIENT_TRAITS(ParentId) using ParentClass = K##ParentId; + namespace mesosphere { +struct IClientTag {}; + template -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) { @@ -30,4 +34,4 @@ class IClient { SharedPtr parent{}; }; -} \ No newline at end of file +} diff --git a/mesosphere/include/mesosphere/interfaces/IClientServerParent.hpp b/mesosphere/include/mesosphere/interfaces/IClientServerParent.hpp index cdb458346..4cb40800a 100644 --- a/mesosphere/include/mesosphere/interfaces/IClientServerParent.hpp +++ b/mesosphere/include/mesosphere/interfaces/IClientServerParent.hpp @@ -2,15 +2,21 @@ #include +#define MESOSPHERE_CLIENT_SERVER_PARENT_TRAITS(ClientId, ServerId)\ +using ClientClass = K##ClientId;\ +using ServerClass = K##ServerId; + namespace mesosphere { +struct IClientServerParentTag {}; + template -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{}; }; } diff --git a/mesosphere/include/mesosphere/interfaces/IServer.hpp b/mesosphere/include/mesosphere/interfaces/IServer.hpp index e7ea74533..15e4e1d55 100644 --- a/mesosphere/include/mesosphere/interfaces/IServer.hpp +++ b/mesosphere/include/mesosphere/interfaces/IServer.hpp @@ -4,22 +4,26 @@ #include #include +#define MESOSPHERE_SERVER_TRAITS(ParentId) using ParentClass = K##ParentId; + namespace mesosphere { +struct IServerTag {}; + template -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, SharedPtr client) { @@ -33,4 +37,4 @@ class IServer { SharedPtr client{}; }; -} \ No newline at end of file +} diff --git a/mesosphere/include/mesosphere/processes/KEvent.hpp b/mesosphere/include/mesosphere/processes/KEvent.hpp index a9e974b09..f0f6e833a 100644 --- a/mesosphere/include/mesosphere/processes/KEvent.hpp +++ b/mesosphere/include/mesosphere/processes/KEvent.hpp @@ -21,6 +21,7 @@ class KEvent final : public ILimitedResource { public: MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Event); + MESOSPHERE_CLIENT_SERVER_PARENT_TRAITS(ReadableEvent, WritableEvent); virtual ~KEvent(); diff --git a/mesosphere/include/mesosphere/processes/KReadableEvent.hpp b/mesosphere/include/mesosphere/processes/KReadableEvent.hpp index b218bb5a2..d13e48116 100644 --- a/mesosphere/include/mesosphere/processes/KReadableEvent.hpp +++ b/mesosphere/include/mesosphere/processes/KReadableEvent.hpp @@ -13,9 +13,11 @@ namespace mesosphere class KWritableEvent; class KEvent; -class KReadableEvent final : public KSynchronizationObject, public IClient { +// Inherited by KInterruptEvent +class KReadableEvent : public KSynchronizationObject, public IClient { public: MESOSPHERE_AUTO_OBJECT_TRAITS(SynchronizationObject, ReadableEvent); + MESOSPHERE_CLIENT_TRAITS(Event); virtual bool IsAlive() const override { return true; } diff --git a/mesosphere/include/mesosphere/processes/KWritableEvent.hpp b/mesosphere/include/mesosphere/processes/KWritableEvent.hpp index bf691aecc..6932e2ed8 100644 --- a/mesosphere/include/mesosphere/processes/KWritableEvent.hpp +++ b/mesosphere/include/mesosphere/processes/KWritableEvent.hpp @@ -15,7 +15,8 @@ class KEvent; class KWritableEvent final : public KAutoObject, public IServer { public: MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, WritableEvent); - + MESOSPHERE_SERVER_TRAITS(Event); + virtual bool IsAlive() const override { return true; } virtual ~KWritableEvent();