From 18e1db1fb8692752f64d3912c3b5ff1818be9028 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 23 May 2022 18:12:39 +0200 Subject: refactor: replace last subscriber patterned code --- src/interfaces/command.hpp | 19 ------------------- src/interfaces/cursor.hpp | 16 +++------------- src/interfaces/game.hpp | 1 - src/interfaces/input.hpp | 3 --- src/interfaces/publisher.hpp | 21 --------------------- src/interfaces/statusline_subscriber_adapter.hpp | 16 ---------------- src/interfaces/subscriber.hpp | 11 ----------- 7 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 src/interfaces/command.hpp delete mode 100644 src/interfaces/publisher.hpp delete mode 100644 src/interfaces/statusline_subscriber_adapter.hpp delete mode 100644 src/interfaces/subscriber.hpp (limited to 'src/interfaces') diff --git a/src/interfaces/command.hpp b/src/interfaces/command.hpp deleted file mode 100644 index f433eab..0000000 --- a/src/interfaces/command.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "interfaces/subscriber.hpp" - -#include - -// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) -class ICommand : public ISubscriber -{ -public: - ~ICommand() override = default; - - virtual void execute() noexcept = 0; - - void update(const std::nullptr_t & /*context*/) noexcept override - { - execute(); - }; -}; diff --git a/src/interfaces/cursor.hpp b/src/interfaces/cursor.hpp index 053ff40..63aae41 100644 --- a/src/interfaces/cursor.hpp +++ b/src/interfaces/cursor.hpp @@ -1,8 +1,5 @@ #pragma once -#include "interfaces/publisher.hpp" -#include "interfaces/subscriber.hpp" - #include "engine/data/vector2.hpp" #include @@ -13,19 +10,18 @@ enum CursorEvent }; // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) -class ICursorController : public IPublisher +class ICursorController { public: using Event = CursorEvent; using Context = Vector2; - using Subscriber = std::shared_ptr>; - ~ICursorController() noexcept override = default; + virtual ~ICursorController() noexcept = default; virtual void move(const Vector2 &direction, const uint32_t &amount) noexcept = 0; // NOLINTNEXTLINE(google-default-arguments) - virtual void move_to(const Vector2 &position, bool silent = false) noexcept = 0; + virtual void move_to(const Vector2 &position) noexcept = 0; [[nodiscard]] virtual auto where() const noexcept -> Vector2 = 0; @@ -34,10 +30,4 @@ public: virtual void hide() noexcept = 0; virtual void show() noexcept = 0; - - void - subscribe(const Event &event, const Subscriber &subscriber) noexcept override = 0; - - void notify_subscribers(const Event &event, const Context &context) - const noexcept override = 0; }; diff --git a/src/interfaces/game.hpp b/src/interfaces/game.hpp index 3aac6a9..e205fae 100644 --- a/src/interfaces/game.hpp +++ b/src/interfaces/game.hpp @@ -1,6 +1,5 @@ #pragma once -#include "interfaces/command.hpp" #include "interfaces/cursor.hpp" #include "interfaces/input.hpp" #include "interfaces/scene.hpp" diff --git a/src/interfaces/input.hpp b/src/interfaces/input.hpp index 8239e48..0797c0d 100644 --- a/src/interfaces/input.hpp +++ b/src/interfaces/input.hpp @@ -1,8 +1,5 @@ #pragma once -#include "interfaces/publisher.hpp" -#include "interfaces/subscriber.hpp" - #include #include diff --git a/src/interfaces/publisher.hpp b/src/interfaces/publisher.hpp deleted file mode 100644 index 2c47c34..0000000 --- a/src/interfaces/publisher.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "interfaces/subscriber.hpp" - -#include -#include - -template -// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) -class IPublisher -{ -public: - virtual ~IPublisher() noexcept = default; - - virtual void subscribe( - const Event &event, - const std::shared_ptr> &subscriber) noexcept = 0; - - virtual void - notify_subscribers(const Event &event, const Context &context) const noexcept = 0; -}; diff --git a/src/interfaces/statusline_subscriber_adapter.hpp b/src/interfaces/statusline_subscriber_adapter.hpp deleted file mode 100644 index 925341f..0000000 --- a/src/interfaces/statusline_subscriber_adapter.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "interfaces/status_manager.hpp" -#include "interfaces/statusline.hpp" -#include "interfaces/subscriber.hpp" - -#include - -#include -#include - -template -using IStatusLineSubscriberAdapterFactory = - yacppdic::Factory>( - const std::shared_ptr &status_manager, - std::vector sections)>; diff --git a/src/interfaces/subscriber.hpp b/src/interfaces/subscriber.hpp deleted file mode 100644 index 942c1d5..0000000 --- a/src/interfaces/subscriber.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -template -// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) -class ISubscriber -{ -public: - virtual ~ISubscriber() = default; - - virtual void update(const Context &context) noexcept = 0; -}; -- cgit v1.2.3-18-g5258