aboutsummaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-28 19:22:06 +0200
committerHampusM <hampus@hampusmat.com>2022-06-28 19:22:06 +0200
commitd2a76bd8cfd883070259bf572a9f723a37c0d96e (patch)
treecca72b471b0c3a562789a1ab966e4568edf7165a /src/engine
parentdaf39f75d764449f18cd480b6d3c645b8372b0a5 (diff)
refactor: improve includes with iwyu
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/data/bounds.cpp2
-rw-r--r--src/engine/data/bounds.hpp4
-rw-r--r--src/engine/data/vector2.cpp5
-rw-r--r--src/engine/data/vector2.hpp1
-rw-r--r--src/engine/engine.cpp12
-rw-r--r--src/engine/engine.hpp11
-rw-r--r--src/engine/graphics/component_renderer.cpp15
-rw-r--r--src/engine/graphics/component_renderer.hpp9
-rw-r--r--src/engine/graphics/scene.cpp14
-rw-r--r--src/engine/graphics/scene.hpp18
-rw-r--r--src/engine/main.cpp7
-rw-r--r--src/engine/user/cursor.cpp5
-rw-r--r--src/engine/user/cursor.hpp16
-rw-r--r--src/engine/user/input.cpp5
-rw-r--r--src/engine/user/input.hpp3
15 files changed, 78 insertions, 49 deletions
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,