From d2a76bd8cfd883070259bf572a9f723a37c0d96e Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 28 Jun 2022 19:22:06 +0200 Subject: refactor: improve includes with iwyu --- src/engine/data/bounds.cpp | 2 ++ src/engine/data/bounds.hpp | 4 +++- src/engine/data/vector2.cpp | 5 +++-- src/engine/data/vector2.hpp | 1 + src/engine/engine.cpp | 12 +++++++++--- src/engine/engine.hpp | 11 +++++++---- src/engine/graphics/component_renderer.cpp | 15 +++++++++++---- src/engine/graphics/component_renderer.hpp | 9 ++++++--- src/engine/graphics/scene.cpp | 14 ++++++++------ src/engine/graphics/scene.hpp | 18 ++++++++++-------- src/engine/main.cpp | 7 ++++--- src/engine/user/cursor.cpp | 5 ++--- src/engine/user/cursor.hpp | 16 +++++++++------- src/engine/user/input.cpp | 5 ++--- src/engine/user/input.hpp | 3 +-- 15 files changed, 78 insertions(+), 49 deletions(-) (limited to 'src/engine') diff --git a/src/engine/data/bounds.cpp b/src/engine/data/bounds.cpp index 21c6660..bee98ba 100644 --- a/src/engine/data/bounds.cpp +++ b/src/engine/data/bounds.cpp @@ -1,5 +1,7 @@ #include "bounds.hpp" +#include "engine/data/vector2.hpp" + Bounds::Bounds(const BoundsOptions &options) noexcept : _width(options.width), _height(options.height) { diff --git a/src/engine/data/bounds.hpp b/src/engine/data/bounds.hpp index b122489..2375d77 100644 --- a/src/engine/data/bounds.hpp +++ b/src/engine/data/bounds.hpp @@ -1,8 +1,10 @@ #pragma once +#include + #include "engine/data/vector2.hpp" -#include +class Vector2; enum CoordsValidation { diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp index cb81947..84986bd 100644 --- a/src/engine/data/vector2.cpp +++ b/src/engine/data/vector2.cpp @@ -1,9 +1,10 @@ #include "vector2.hpp" -#include "util/hash.hpp" - +#include #include +#include "util/hash_impl.hpp" + auto Vector2::get_x() const noexcept -> Vector2::Value { return _x; diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp index b83e924..03c2562 100644 --- a/src/engine/data/vector2.hpp +++ b/src/engine/data/vector2.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index b0456a3..7f7c4c3 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1,13 +1,19 @@ #include "engine.hpp" -#include "util/function.hpp" - #include - +#include #include +#include #include #include #include +#include + +#include "interfaces/component.hpp" +#include "interfaces/cursor.hpp" +#include "interfaces/input.hpp" +#include "interfaces/scene.hpp" +#include "util/function_impl.hpp" CLIGameEngine::CLIGameEngine( IGameFactory game_factory, diff --git a/src/engine/engine.hpp b/src/engine/engine.hpp index 65d1a80..82bde16 100644 --- a/src/engine/engine.hpp +++ b/src/engine/engine.hpp @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include + #include "interfaces/component_renderer.hpp" #include "interfaces/cursor.hpp" #include "interfaces/engine.hpp" @@ -7,10 +11,9 @@ #include "interfaces/input.hpp" #include "interfaces/scene.hpp" -#include - -#include -#include +class ICursorController; +class IScene; +class IUserInputObserver; constexpr auto MIN_TIME_SINCE_LAST_UPDATE_MILLIS = 15; diff --git a/src/engine/graphics/component_renderer.cpp b/src/engine/graphics/component_renderer.cpp index effe153..0584028 100644 --- a/src/engine/graphics/component_renderer.cpp +++ b/src/engine/graphics/component_renderer.cpp @@ -1,13 +1,20 @@ #include "component_renderer.hpp" -#include "engine/escape.hpp" -#include "util/color.hpp" - #include - #include +#include #include +#include "engine/data/style.hpp" +#include "engine/data/vector2.hpp" +#include "engine/escape.hpp" +#include "engine/graphics/matrix_iterator.hpp" +#include "engine/graphics/matrix_iterator_impl.hpp" +#include "interfaces/component.hpp" +#include "interfaces/cursor.hpp" +#include "interfaces/matrix.hpp" +#include "util/color.hpp" + ComponentRenderer::ComponentRenderer( std::shared_ptr cursor_controller) noexcept : _cursor_controller(std::move(cursor_controller)) diff --git a/src/engine/graphics/component_renderer.hpp b/src/engine/graphics/component_renderer.hpp index ff1bc47..4d21623 100644 --- a/src/engine/graphics/component_renderer.hpp +++ b/src/engine/graphics/component_renderer.hpp @@ -1,12 +1,15 @@ #pragma once +#include + +#include "engine/data/vector2.hpp" #include "interfaces/component.hpp" #include "interfaces/component_renderer.hpp" #include "interfaces/cursor.hpp" -#include "engine/data/vector2.hpp" - -#include +class IComponent; +class ICursorController; +class Vector2; constexpr auto SET_BOLD_MODE = "{esc}[1m"; diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp index ff64edd..7c23c7d 100644 --- a/src/engine/graphics/scene.cpp +++ b/src/engine/graphics/scene.cpp @@ -1,13 +1,15 @@ #include "scene.hpp" -#include "engine/escape.hpp" -#include "util/color.hpp" - -#include #include - -#include #include +#include +#include +#include +#include + +#include "engine/escape.hpp" + +class IComponent; Scene::Scene(const IMatrixFactory &matrix_factory) noexcept : _matrix(matrix_factory(size())), _is_shown(false) diff --git a/src/engine/graphics/scene.hpp b/src/engine/graphics/scene.hpp index 4df5f56..5b52027 100644 --- a/src/engine/graphics/scene.hpp +++ b/src/engine/graphics/scene.hpp @@ -1,19 +1,21 @@ #pragma once -#include "interfaces/component.hpp" -#include "interfaces/matrix.hpp" -#include "interfaces/scene.hpp" - -#include "engine/data/vector2.hpp" - #include -#include - #include #include #include #include #include +#include + +#include "engine/data/bounds.hpp" +#include "engine/data/vector2.hpp" +#include "interfaces/component.hpp" +#include "interfaces/matrix.hpp" +#include "interfaces/scene.hpp" + +class IComponent; +struct termios; constexpr fmt::string_view ENABLE_ALT_BUFFER = "{esc}[?1049h"; constexpr fmt::string_view DISABLE_ALT_BUFFER = "{esc}[?1049l"; diff --git a/src/engine/main.cpp b/src/engine/main.cpp index b703218..8043c68 100644 --- a/src/engine/main.cpp +++ b/src/engine/main.cpp @@ -1,8 +1,9 @@ -#include "interfaces/engine.hpp" +#include +#include +#include #include "bootstrap.hpp" - -#include +#include "interfaces/engine.hpp" auto main() noexcept -> int { diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp index a372ca7..5cd74a6 100644 --- a/src/engine/user/cursor.cpp +++ b/src/engine/user/cursor.cpp @@ -1,10 +1,9 @@ #include "cursor.hpp" -#include "engine/escape.hpp" - -#include #include +#include "engine/escape.hpp" + CursorController::CursorController() noexcept : _position({.x = 0, .y = 0}), _bounds({0, 0}) { diff --git a/src/engine/user/cursor.hpp b/src/engine/user/cursor.hpp index 06c6b88..ff7e89f 100644 --- a/src/engine/user/cursor.hpp +++ b/src/engine/user/cursor.hpp @@ -2,16 +2,16 @@ #include "interfaces/cursor.hpp" -#include "engine/data/bounds.hpp" -#include "engine/data/vector2.hpp" - +#include #include -#include - #include #include #include #include +#include + +#include "engine/data/bounds.hpp" +#include "engine/data/vector2.hpp" constexpr std::string_view MOVE_CURSOR_UP = "{esc}[{amount}A"; constexpr std::string_view MOVE_CURSOR_DOWN = "{esc}[{amount}B"; @@ -39,8 +39,10 @@ class CursorController : public ICursorController, public: CursorController() noexcept; - void move(const Vector2 &direction, const std::uint32_t &amount, bool flush_cout) noexcept - override; + void move( + const Vector2 &direction, + const std::uint32_t &amount, + bool flush_cout) noexcept override; void move_to(const Vector2 &position, bool flush_cout) noexcept override; diff --git a/src/engine/user/input.cpp b/src/engine/user/input.cpp index f0ffbe5..505a0fa 100644 --- a/src/engine/user/input.cpp +++ b/src/engine/user/input.cpp @@ -1,11 +1,10 @@ #include "input.hpp" -#include "engine/keycodes.hpp" - #include -#include #include +#include "engine/keycodes.hpp" + const std::unordered_map special_keys_map = { {'A', keycodes::UP_ARROW}, {'B', keycodes::DOWN_ARROW}, diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp index 12c27ee..9e8196d 100644 --- a/src/engine/user/input.hpp +++ b/src/engine/user/input.hpp @@ -2,11 +2,10 @@ #include "interfaces/input.hpp" -#include - #include #include #include +#include class UserInputObserver : public IUserInputObserver, -- cgit v1.2.3-18-g5258