aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/game.hpp10
-rw-r--r--src/interfaces/generation_tracker.hpp5
-rw-r--r--src/interfaces/matrix.hpp4
-rw-r--r--src/interfaces/randomization.hpp4
-rw-r--r--src/interfaces/scene.hpp6
-rw-r--r--src/interfaces/status_updater.hpp5
-rw-r--r--src/interfaces/statusline.hpp6
7 files changed, 29 insertions, 11 deletions
diff --git a/src/interfaces/game.hpp b/src/interfaces/game.hpp
index 46d79e4..0f5c895 100644
--- a/src/interfaces/game.hpp
+++ b/src/interfaces/game.hpp
@@ -5,6 +5,8 @@
#include "interfaces/scene.hpp"
#include "interfaces/window.hpp"
+#include "DI/factory.hpp"
+
#include <memory>
#include <unordered_map>
@@ -24,6 +26,12 @@ public:
-> std::unordered_map<char, std::shared_ptr<ICommand>> = 0;
};
-using IGameFactory = std::shared_ptr<IGame> (*)(
+/*
+using IGameFactory = std::unique_ptr<IGame> (*)(
const std::shared_ptr<IWindow> &window, const std::shared_ptr<IScene> &scene,
const std::shared_ptr<ICursorController> &cursor_controller);
+ */
+
+using IGameFactory = Factory<std::unique_ptr<IGame>(
+ const std::shared_ptr<IWindow> &window, const std::shared_ptr<IScene> &scene,
+ const std::shared_ptr<ICursorController> &cursor_controller)>;
diff --git a/src/interfaces/generation_tracker.hpp b/src/interfaces/generation_tracker.hpp
index fcd2426..fd2c130 100644
--- a/src/interfaces/generation_tracker.hpp
+++ b/src/interfaces/generation_tracker.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "DI/factory.hpp"
+
#include <cstdint>
#include <memory>
@@ -16,4 +18,5 @@ public:
virtual void set_is_paused(bool is_paused) noexcept = 0;
};
-using IGenerationTrackerFactory = std::shared_ptr<IGenerationTracker> (*)(bool is_paused);
+using IGenerationTrackerFactory =
+ Factory<std::unique_ptr<IGenerationTracker>(bool is_paused)>;
diff --git a/src/interfaces/matrix.hpp b/src/interfaces/matrix.hpp
index edcf935..7fea003 100644
--- a/src/interfaces/matrix.hpp
+++ b/src/interfaces/matrix.hpp
@@ -1,8 +1,8 @@
#pragma once
+#include "DI/factory.hpp"
#include "engine/data/bounds.hpp"
#include "engine/data/vector2.hpp"
-
#include "engine/matrix_iterator.hpp"
#include <memory>
@@ -39,4 +39,4 @@ public:
};
template <typename Element>
-using IMatrixFactory = std::shared_ptr<IMatrix<Element>> (*)(const Bounds &bounds);
+using IMatrixFactory = Factory<std::unique_ptr<IMatrix<Element>>(const Bounds &bounds)>;
diff --git a/src/interfaces/randomization.hpp b/src/interfaces/randomization.hpp
index 8b1631c..4abad1d 100644
--- a/src/interfaces/randomization.hpp
+++ b/src/interfaces/randomization.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "DI/factory.hpp"
+
#include <memory>
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
@@ -28,4 +30,4 @@ public:
};
using IRandomNumberGeneratorFactory =
- std::shared_ptr<IRandomNumberGenerator> (*)(const uint32_t &seed);
+ Factory<std::unique_ptr<IRandomNumberGenerator>(const uint32_t &seed)>;
diff --git a/src/interfaces/scene.hpp b/src/interfaces/scene.hpp
index 3960985..0a51b6e 100644
--- a/src/interfaces/scene.hpp
+++ b/src/interfaces/scene.hpp
@@ -4,6 +4,8 @@
#include "interfaces/matrix.hpp"
#include "interfaces/window.hpp"
+#include "DI/factory.hpp"
+
#include <memory>
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
@@ -20,6 +22,6 @@ public:
-> const std::shared_ptr<IMatrix<std::string_view>> & = 0;
};
-using ISceneFactory = std::shared_ptr<IScene> (*)(
+using ISceneFactory = Factory<std::unique_ptr<IScene>(
const std::shared_ptr<ICursorController> &cursor_controller,
- const std::shared_ptr<IWindow> &window);
+ const std::shared_ptr<IWindow> &window)>;
diff --git a/src/interfaces/status_updater.hpp b/src/interfaces/status_updater.hpp
index 2770d5e..e5081ef 100644
--- a/src/interfaces/status_updater.hpp
+++ b/src/interfaces/status_updater.hpp
@@ -4,6 +4,7 @@
#include "interfaces/statusline.hpp"
#include "interfaces/subscriber.hpp"
+#include "DI/factory.hpp"
#include "engine/data/vector2.hpp"
#include <memory>
@@ -15,6 +16,6 @@ public:
void update(const Vector2 &context) noexcept override = 0;
};
-using IStatusUpdaterFactory = std::shared_ptr<IStatusUpdater> (*)(
+using IStatusUpdaterFactory = Factory<std::unique_ptr<IStatusUpdater>(
const std::shared_ptr<IStatusLine> &statusline,
- const std::shared_ptr<IGenerationTracker> &generation_tracker);
+ const std::shared_ptr<IGenerationTracker> &generation_tracker)>;
diff --git a/src/interfaces/statusline.hpp b/src/interfaces/statusline.hpp
index f07c1a0..bbd8e4a 100644
--- a/src/interfaces/statusline.hpp
+++ b/src/interfaces/statusline.hpp
@@ -3,6 +3,8 @@
#include "interfaces/cursor.hpp"
#include "interfaces/window.hpp"
+#include "DI/factory.hpp"
+
#include <string_view>
enum StatusLineSection
@@ -23,6 +25,6 @@ public:
const std::string_view &str) noexcept = 0;
};
-using IStatusLineFactory = std::shared_ptr<IStatusLine> (*)(
+using IStatusLineFactory = Factory<std::unique_ptr<IStatusLine>(
const std::shared_ptr<ICursorController> &cursor_controller,
- const std::shared_ptr<IWindow> &window);
+ const std::shared_ptr<IWindow> &window)>;