diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-20 18:49:49 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:56 +0200 |
commit | e6644d6b235005de9ba1b9884472fa5f5d8d6074 (patch) | |
tree | b6d10d8e3ee8b092933baa55d35480d438bb6328 /src/interfaces/input.hpp | |
parent | 6f9d9fe1d1904ecc5ca52697ec2319a21008120f (diff) |
refactor: update event system terminology & structure
Diffstat (limited to 'src/interfaces/input.hpp')
-rw-r--r-- | src/interfaces/input.hpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/interfaces/input.hpp b/src/interfaces/input.hpp index 82ad57c..795ade2 100644 --- a/src/interfaces/input.hpp +++ b/src/interfaces/input.hpp @@ -1,21 +1,27 @@ #pragma once -#include "interfaces/command.hpp" -#include "interfaces/observable.hpp" +#include "interfaces/publisher.hpp" +#include "interfaces/subscriber.hpp" +#include <cstddef> #include <memory> -class IInputHandler : public IObservable<char> +class IInputHandler : public IPublisher<char, std::nullptr_t> { public: + using Event = char; + using Context = std::nullptr_t; + ~IInputHandler() noexcept override = default; - void listen() const noexcept override = 0; + virtual void listen() const noexcept = 0; - void attach(const char &key, - const std::shared_ptr<ICommand> &command) noexcept override = 0; + void subscribe( + const Event &event, + const std::shared_ptr<ISubscriber<Context>> &subscriber) noexcept override = 0; - void notify(const char &key) const noexcept override = 0; + void notify_subscribers(const Event &event, + const Context &context) const noexcept override = 0; virtual void enter_raw_mode() noexcept = 0; |