From e6644d6b235005de9ba1b9884472fa5f5d8d6074 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 20 Mar 2022 18:49:49 +0100 Subject: refactor: update event system terminology & structure --- src/interfaces/input.hpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/interfaces/input.hpp') 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 #include -class IInputHandler : public IObservable +class IInputHandler : public IPublisher { 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 &command) noexcept override = 0; + void subscribe( + const Event &event, + const std::shared_ptr> &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; -- cgit v1.2.3-18-g5258