aboutsummaryrefslogtreecommitdiff
path: root/src/engine/user/input.hpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-20 18:49:49 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:56 +0200
commite6644d6b235005de9ba1b9884472fa5f5d8d6074 (patch)
treeb6d10d8e3ee8b092933baa55d35480d438bb6328 /src/engine/user/input.hpp
parent6f9d9fe1d1904ecc5ca52697ec2319a21008120f (diff)
refactor: update event system terminology & structure
Diffstat (limited to 'src/engine/user/input.hpp')
-rw-r--r--src/engine/user/input.hpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp
index d2aa447..7a3c88e 100644
--- a/src/engine/user/input.hpp
+++ b/src/engine/user/input.hpp
@@ -1,9 +1,8 @@
#pragma once
#include "DI/auto_wirable.hpp"
-#include "interfaces/command.hpp"
#include "interfaces/input.hpp"
-#include "interfaces/observable.hpp"
+#include "interfaces/subscriber.hpp"
#include <limits>
#include <memory>
@@ -18,21 +17,23 @@ public:
void listen() const noexcept override;
- void attach(const char &key,
- const std::shared_ptr<ICommand> &command) noexcept override;
+ void
+ subscribe(const Event &event,
+ const std::shared_ptr<ISubscriber<Context>> &subscriber) noexcept override;
- void notify(const char &key) const noexcept override;
+ void notify_subscribers(const Event &event,
+ const Context &context) const noexcept override;
void enter_raw_mode() noexcept override;
void leave_raw_mode() noexcept override;
private:
- std::array<std::vector<std::shared_ptr<ICommand>>, CHAR_MAX> _key_commands;
+ std::array<std::vector<std::shared_ptr<ISubscriber<Context>>>, CHAR_MAX> _subscribers;
std::shared_ptr<termios> _original_termios = nullptr;
- using _KeyCommandsSizeType = decltype(_key_commands)::size_type;
+ using _SubscribersSizeType = decltype(_subscribers)::size_type;
- static _KeyCommandsSizeType _key_as_index(const char &key) noexcept;
+ static _SubscribersSizeType _event_as_index(const Event &event) noexcept;
};