From 3509d0de7865419109381b94d565642e7e6d04af Mon Sep 17 00:00:00 2001 From: Nav Date: Fri, 15 Apr 2022 22:04:02 +0100 Subject: [PATCH] New NotiferInterface class, for describing the interface used to notify different components within Bloom, of any important events. --- src/Helpers/NotifierInterface.hpp | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Helpers/NotifierInterface.hpp diff --git a/src/Helpers/NotifierInterface.hpp b/src/Helpers/NotifierInterface.hpp new file mode 100644 index 00000000..2e059ee3 --- /dev/null +++ b/src/Helpers/NotifierInterface.hpp @@ -0,0 +1,37 @@ +#pragma once + +namespace Bloom +{ + /** + * The NotifierInterface class describes an interface for notifying different components, within Bloom, of something + * important that has just happened. + * + * It's important to note that this interface only describes the issuing of notifications. It *does not* describe + * the listening for notifications. The listening can be defined by the implementation. + * + * For example, consider the EventFdNotifier implementation. That class is just an RAII wrapper for a Linux eventfd + * object. Notifications are recorded by incrementing the eventfd counter. And they can be listened for, using + * Linux system functions like poll(), select(), and similar. + * + * The EventListener class can hold a pointer to a NotifierInterface, where it will invoke + * NotifierInterface::notify() everytime a new event is registered on the listener. + */ + class NotifierInterface + { + public: + NotifierInterface() = default; + virtual ~NotifierInterface() noexcept = default; + + NotifierInterface(NotifierInterface& other) = delete; + + NotifierInterface& operator = (NotifierInterface& other) = delete; + NotifierInterface& operator = (NotifierInterface&& other) = delete; + + NotifierInterface(NotifierInterface&& other) noexcept = default; + + /** + * Should record a notification. + */ + virtual void notify() = 0; + }; +}