diff options
author | HampusM <hampus@hampusmat.com> | 2022-06-28 19:22:06 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-28 19:22:06 +0200 |
commit | d2a76bd8cfd883070259bf572a9f723a37c0d96e (patch) | |
tree | cca72b471b0c3a562789a1ab966e4568edf7165a /src | |
parent | daf39f75d764449f18cd480b6d3c645b8372b0a5 (diff) |
refactor: improve includes with iwyu
Diffstat (limited to 'src')
30 files changed, 171 insertions, 122 deletions
diff --git a/src/bootstrap.cpp b/src/bootstrap.cpp index 12f7369..368f2a8 100644 --- a/src/bootstrap.cpp +++ b/src/bootstrap.cpp @@ -1,37 +1,41 @@ #include "bootstrap.hpp" -// Interfaces -#include "interfaces/RLE_reader.hpp" -#include "interfaces/cell_helper.hpp" -#include "interfaces/component.hpp" -#include "interfaces/component_renderer.hpp" -#include "interfaces/cursor.hpp" -#include "interfaces/engine.hpp" -#include "interfaces/game.hpp" -#include "interfaces/generation_tracker.hpp" -#include "interfaces/input.hpp" -#include "interfaces/matrix.hpp" -#include "interfaces/scene.hpp" -#include "interfaces/status_manager.hpp" -#include "interfaces/statusline.hpp" +#include <list> +#include <memory> +#include <vector> +#include <yacppdic/factory.hpp> -// Implementations -#include "engine/data/bounds.hpp" -#include "engine/data/vector2.hpp" #include "engine/engine.hpp" #include "engine/graphics/component_renderer.hpp" #include "engine/graphics/matrix.hpp" +#include "engine/graphics/matrix_impl.hpp" +#include "engine/graphics/matrix_iterator.hpp" +#include "engine/graphics/matrix_iterator_impl.hpp" #include "engine/graphics/scene.hpp" #include "engine/user/cursor.hpp" #include "engine/user/input.hpp" #include "game/RLE_reader.hpp" #include "game/cell_helper.hpp" +#include "game/cell_helper_impl.hpp" #include "game/components/statusline.hpp" #include "game/game.hpp" #include "game/generation_tracker.hpp" #include "game/status_manager.hpp" +#include "interfaces/RLE_reader.hpp" +#include "interfaces/cell_helper.hpp" +#include "interfaces/component.hpp" +#include "interfaces/component_renderer.hpp" +#include "interfaces/cursor.hpp" +#include "interfaces/engine.hpp" +#include "interfaces/game.hpp" +#include "interfaces/generation_tracker.hpp" +#include "interfaces/input.hpp" +#include "interfaces/matrix.hpp" +#include "interfaces/scene.hpp" +#include "interfaces/status_manager.hpp" +#include "interfaces/statusline.hpp" -#include <memory> +class Bounds; auto bootstrap() noexcept -> yacppdic::DIContainer { 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 <cstdint> + #include "engine/data/vector2.hpp" -#include <cstdint> +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 <compare> #include <tuple> +#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 <cstddef> #include <cstdint> #include <functional> 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 <fmt/core.h> - +#include <yacppdic/factory.hpp> #include <chrono> +#include <cstdlib> #include <exception> #include <thread> #include <utility> +#include <vector> + +#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 <memory> +#include <unordered_map> +#include <yacppdic/auto_wirable.hpp> + #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 <yacppdic/auto_wirable.hpp> - -#include <memory> -#include <unordered_map> +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 <fmt/core.h> - #include <iostream> +#include <optional> #include <utility> +#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<ICursorController> 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 <memory> + +#include "engine/data/vector2.hpp" #include "interfaces/component.hpp" #include "interfaces/component_renderer.hpp" #include "interfaces/cursor.hpp" -#include "engine/data/vector2.hpp" - -#include <memory> +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 <fmt/color.h> #include <fmt/core.h> - -#include <iostream> #include <sys/ioctl.h> +#include <termios.h> +#include <unistd.h> +#include <cstdint> +#include <iostream> + +#include "engine/escape.hpp" + +class IComponent; Scene::Scene(const IMatrixFactory<MatrixElement> &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 <fmt/core.h> -#include <yacppdic/auto_wirable.hpp> - #include <memory> #include <string_view> #include <termios.h> #include <utility> #include <vector> +#include <yacppdic/auto_wirable.hpp> + +#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 <backward.hpp> +#include <yacppdic/container.hpp> +#include <memory> #include "bootstrap.hpp" - -#include <backward.hpp> +#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 <cstdlib> #include <iostream> +#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 <cstdint> #include <fmt/core.h> -#include <yacppdic/auto_wirable.hpp> - #include <memory> #include <string_view> #include <unordered_map> #include <vector> +#include <yacppdic/auto_wirable.hpp> + +#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 <iostream> -#include <unistd.h> #include <unordered_map> +#include "engine/keycodes.hpp" + const std::unordered_map<char, char> 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 <yacppdic/auto_wirable.hpp> - #include <memory> #include <mutex> #include <string> +#include <yacppdic/auto_wirable.hpp> class UserInputObserver : public IUserInputObserver, diff --git a/src/game/RLE_reader.cpp b/src/game/RLE_reader.cpp index f971966..df2823c 100644 --- a/src/game/RLE_reader.cpp +++ b/src/game/RLE_reader.cpp @@ -1,20 +1,16 @@ #include "RLE_reader.hpp" -#include "engine/data/bounds.hpp" -#include "engine/data/vector2.hpp" -#include "errors/RLE_reader.hpp" -#include "util/algorithm.hpp" -#include "util/io.hpp" -#include "util/string.hpp" - #include <ctre.hpp> - #include <cctype> -#include <fstream> #include <string> #include <vector> -#include <iostream> +#include "engine/data/bounds.hpp" +#include "engine/data/vector2.hpp" +#include "errors/RLE_reader.hpp" +#include "util/algorithm_impl.hpp" +#include "util/io_impl.hpp" +#include "util/string_impl.hpp" RLEReader::RLEReader(const IMatrixFactory<MatrixElement> &matrix_factory) noexcept : _matrix_factory(matrix_factory) diff --git a/src/game/components/statusline.cpp b/src/game/components/statusline.cpp index c2fe7ea..aac1c27 100644 --- a/src/game/components/statusline.cpp +++ b/src/game/components/statusline.cpp @@ -1,14 +1,13 @@ #include "statusline.hpp" -#include "engine/data/bounds.hpp" -#include "engine/data/vector2.hpp" -#include "util/color.hpp" -#include "util/ranges.hpp" - #include <fmt/color.h> - #include <utility> +#include "engine/data/vector2.hpp" +#include "interfaces/matrix.hpp" +#include "util/ranges.hpp" +#include "util/ranges_impl.hpp" + StatusLine::StatusLine(std::shared_ptr<ComponentMatrix> component_matrix) noexcept : _component_matrix(std::move(component_matrix)), _need_render(false) { diff --git a/src/game/components/statusline.hpp b/src/game/components/statusline.hpp index 4451fde..a6742c9 100644 --- a/src/game/components/statusline.hpp +++ b/src/game/components/statusline.hpp @@ -1,14 +1,17 @@ #pragma once -#include "interfaces/matrix.hpp" -#include "interfaces/statusline.hpp" +#include <cstdint> +#include <memory> +#include <string_view> +#include <unordered_map> #include "engine/data/style.hpp" #include "engine/data/vector2.hpp" +#include "interfaces/component.hpp" +#include "interfaces/matrix.hpp" +#include "interfaces/statusline.hpp" -#include <memory> -#include <string_view> -#include <unordered_map> +class Vector2; constexpr std::uint32_t STATUSLINE_COLOR = 0x1A1A1AU; @@ -32,7 +35,8 @@ public: const std::string_view &status, std::int32_t start) noexcept override; - void set_section_length(StatusLineSection section, std::int32_t length) noexcept override; + void + set_section_length(StatusLineSection section, std::int32_t length) noexcept override; void set_section_style(StatusLineSection section, const Style &style) noexcept override; diff --git a/src/game/game.cpp b/src/game/game.cpp index 921f21d..a121089 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -1,24 +1,33 @@ #include "game.hpp" -#include "engine/data/bounds.hpp" -#include "engine/escape.hpp" -#include "engine/keycodes.hpp" -#include "errors/RLE_reader.hpp" -#include "errors/io.hpp" -#include "util/algorithm.hpp" -#include "util/fs.hpp" -#include "util/string.hpp" - #include <fmt/color.h> #include <fmt/core.h> - -#include <algorithm> +#include <fmt/format.h> +#include <yacppdic/factory.hpp> #include <cstdlib> #include <filesystem> #include <iostream> +#include <iterator> #include <stdexcept> #include <utility> +#include "engine/data/bounds.hpp" +#include "engine/escape.hpp" +#include "engine/graphics/matrix_iterator.hpp" +#include "engine/graphics/matrix_iterator_impl.hpp" +#include "engine/keycodes.hpp" +#include "errors/RLE_reader.hpp" +#include "errors/io.hpp" +#include "interfaces/RLE_reader.hpp" +#include "interfaces/cell_helper.hpp" +#include "interfaces/generation_tracker.hpp" +#include "interfaces/input.hpp" +#include "interfaces/matrix.hpp" +#include "interfaces/status_manager.hpp" +#include "util/algorithm_impl.hpp" +#include "util/fs.hpp" +#include "util/string_impl.hpp" + Game::Game( IStatusLineFactory statusline_factory, std::shared_ptr<IScene> scene, diff --git a/src/game/game.hpp b/src/game/game.hpp index da1ba11..13e229e 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -1,5 +1,18 @@ #pragma once +#include <chrono> +#include <cstddef> +#include <cstdint> +#include <functional> +#include <list> +#include <memory> +#include <optional> +#include <string> +#include <string_view> +#include <unordered_map> +#include <vector> + +#include "engine/data/vector2.hpp" #include "interfaces/RLE_reader.hpp" #include "interfaces/cell_helper.hpp" #include "interfaces/cursor.hpp" @@ -11,17 +24,13 @@ #include "interfaces/status_manager.hpp" #include "interfaces/statusline.hpp" -#include "engine/data/vector2.hpp" - -#include <chrono> -#include <cstddef> -#include <functional> -#include <list> -#include <memory> -#include <optional> -#include <string> -#include <string_view> -#include <vector> +class ICellHelper; +class IGenerationTracker; +class IRLEReader; +class IStatusManager; +class IUserInputObserver; +template <typename ElementType> +class IMatrix; constexpr auto DEFAULT_GENERATIONS_PER_SECOND = 5L; diff --git a/src/game/status_manager.cpp b/src/game/status_manager.cpp index fd56627..a174680 100644 --- a/src/game/status_manager.cpp +++ b/src/game/status_manager.cpp @@ -1,9 +1,7 @@ #include "status_manager.hpp" #include <fmt/core.h> - #include <stdexcept> -#include <utility> void StatusManager::bind(const std::shared_ptr<IStatusLine> &statusline) noexcept { diff --git a/src/game/status_manager.hpp b/src/game/status_manager.hpp index b170cf9..e9f2d15 100644 --- a/src/game/status_manager.hpp +++ b/src/game/status_manager.hpp @@ -1,13 +1,15 @@ #pragma once #include "interfaces/status_manager.hpp" -#include "interfaces/statusline.hpp" - -#include <yacppdic/auto_wirable.hpp> +#include <cstdint> #include <memory> #include <optional> #include <string_view> +#include <unordered_map> +#include <yacppdic/auto_wirable.hpp> + +#include "interfaces/statusline.hpp" class StatusManager : public IStatusManager, public yacppdic::AutoWirable<IStatusManager, StatusManager> diff --git a/src/interfaces/RLE_reader.hpp b/src/interfaces/RLE_reader.hpp index a3266a8..9cc6722 100644 --- a/src/interfaces/RLE_reader.hpp +++ b/src/interfaces/RLE_reader.hpp @@ -16,4 +16,3 @@ public: [[nodiscard]] virtual auto read_RLE_file(const std::filesystem::path &path) const -> std::unique_ptr<IMatrix<MatrixElement>> = 0; }; - diff --git a/src/interfaces/generation_tracker.hpp b/src/interfaces/generation_tracker.hpp index 5f9bd13..291fbbc 100644 --- a/src/interfaces/generation_tracker.hpp +++ b/src/interfaces/generation_tracker.hpp @@ -11,7 +11,8 @@ class IGenerationTracker public: virtual ~IGenerationTracker() noexcept = default; - [[nodiscard]] virtual auto get_current_generation() const noexcept -> std::uint32_t = 0; + [[nodiscard]] virtual auto get_current_generation() const noexcept + -> std::uint32_t = 0; virtual void set_current_generation(std::uint32_t current_generation) noexcept = 0; diff --git a/src/interfaces/scene.hpp b/src/interfaces/scene.hpp index b7bb97d..d43a8e2 100644 --- a/src/interfaces/scene.hpp +++ b/src/interfaces/scene.hpp @@ -36,4 +36,3 @@ public: [[nodiscard]] virtual auto get_components() const noexcept -> std::vector<std::pair<std::shared_ptr<IComponent>, Vector2>> = 0; }; - diff --git a/src/interfaces/status_manager.hpp b/src/interfaces/status_manager.hpp index 7744eb6..29750d6 100644 --- a/src/interfaces/status_manager.hpp +++ b/src/interfaces/status_manager.hpp @@ -21,4 +21,3 @@ public: const StatusLineSection §ion, const std::string_view &body) noexcept = 0; }; - diff --git a/src/util/color.hpp b/src/util/color.hpp index 2bb147c..d209b36 100644 --- a/src/util/color.hpp +++ b/src/util/color.hpp @@ -1,5 +1,6 @@ #pragma once +#include <cstdint> #include <fmt/core.h> #include <string> diff --git a/src/util/fs.cpp b/src/util/fs.cpp index 68c3dd9..87e3cc0 100644 --- a/src/util/fs.cpp +++ b/src/util/fs.cpp @@ -1,8 +1,9 @@ #include "fs.hpp" -#include <cstdlib> #include <pwd.h> #include <unistd.h> +#include <cstdlib> +#include <string> auto get_current_user_home_path() noexcept -> std::filesystem::path { diff --git a/src/util/ranges_impl.hpp b/src/util/ranges_impl.hpp index b18a11c..1f1a577 100644 --- a/src/util/ranges_impl.hpp +++ b/src/util/ranges_impl.hpp @@ -57,4 +57,3 @@ IOTA_VIEW(auto)::end() const noexcept -> IotaViewIterator<Value> { return IotaViewIterator(_bound); } - |