From fb080f6fb911b1831c176a06259e384772541dd5 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 2 May 2022 22:36:21 +0200 Subject: refactor: seperate statusline related concerns --- src/interfaces/status_manager.hpp | 28 ++++++++++++++++++++++++ src/interfaces/status_updater.hpp | 23 ------------------- src/interfaces/statusline.hpp | 16 ++++++++++---- src/interfaces/statusline_subscriber_adapter.hpp | 17 ++++++++++++++ 4 files changed, 57 insertions(+), 27 deletions(-) create mode 100644 src/interfaces/status_manager.hpp delete mode 100644 src/interfaces/status_updater.hpp create mode 100644 src/interfaces/statusline_subscriber_adapter.hpp (limited to 'src/interfaces') diff --git a/src/interfaces/status_manager.hpp b/src/interfaces/status_manager.hpp new file mode 100644 index 0000000..afc8416 --- /dev/null +++ b/src/interfaces/status_manager.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "interfaces/statusline.hpp" + +#include + +#include +#include + +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) +class IStatusManager +{ +public: + virtual ~IStatusManager() = default; + + virtual void set_section_title( + const StatusLineSection §ion, + const std::string_view &title + ) noexcept = 0; + + virtual void set_section_body( + const StatusLineSection §ion, + const std::string_view &body + ) noexcept = 0; +}; + +using IStatusManagerFactory = yacppdic::Factory< + std::unique_ptr(const std::shared_ptr &statusline)>; diff --git a/src/interfaces/status_updater.hpp b/src/interfaces/status_updater.hpp deleted file mode 100644 index 4b2ceb1..0000000 --- a/src/interfaces/status_updater.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "interfaces/generation_tracker.hpp" -#include "interfaces/statusline.hpp" -#include "interfaces/subscriber.hpp" - -#include "engine/data/vector2.hpp" - -#include - -#include - -// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) -class IStatusUpdater : public ISubscriber -{ -public: - void update(const Vector2 &context) noexcept override = 0; -}; - -using IStatusUpdaterFactory = yacppdic::Factory( - const std::shared_ptr &statusline, - const std::shared_ptr &generation_tracker -)>; diff --git a/src/interfaces/statusline.hpp b/src/interfaces/statusline.hpp index 0da295e..2b61d24 100644 --- a/src/interfaces/statusline.hpp +++ b/src/interfaces/statusline.hpp @@ -9,8 +9,12 @@ enum StatusLineSection { - A, - B + A = 0, + B = 1, + C = 2, + D = 3, + E = 4, + F = 5 }; // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) @@ -22,9 +26,13 @@ public: virtual void initialize_background() noexcept = 0; virtual void set_status( - StatusLineSection section, - const std::string_view &status_str + const StatusLineSection §ion, + const std::string_view &status, + std::size_t start = 1UL ) noexcept = 0; + + virtual void + set_section_length(const StatusLineSection §ion, uint32_t length) noexcept = 0; }; using IStatusLineFactory = yacppdic::Factory( diff --git a/src/interfaces/statusline_subscriber_adapter.hpp b/src/interfaces/statusline_subscriber_adapter.hpp new file mode 100644 index 0000000..53543f7 --- /dev/null +++ b/src/interfaces/statusline_subscriber_adapter.hpp @@ -0,0 +1,17 @@ +#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 + )>; -- cgit v1.2.3-18-g5258