aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-27 20:22:52 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:57 +0200
commitea8cc60dc4af9b88d13f4a143986a3fad7e1691a (patch)
treeccb622de7c03aef041916b1bd451d10939fbf861
parent3b326d77dceb3cc70abd54943689d76ecd96fc8b (diff)
refactor: clean up DI code
-rw-r--r--src/DI/auto_wirable.hpp9
-rw-r--r--src/DI/container.hpp2
-rw-r--r--src/DI/object_type.hpp10
-rw-r--r--src/interfaces/engine.hpp3
-rw-r--r--src/interfaces/window.hpp3
5 files changed, 10 insertions, 17 deletions
diff --git a/src/DI/auto_wirable.hpp b/src/DI/auto_wirable.hpp
index a903242..178158a 100644
--- a/src/DI/auto_wirable.hpp
+++ b/src/DI/auto_wirable.hpp
@@ -4,15 +4,8 @@
#include <memory>
-// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
-class IGenericAutoWirable
-{
-public:
- virtual ~IGenericAutoWirable() noexcept = default;
-};
-
template <class Interface>
-class IAutoWirable : public IGenericAutoWirable
+class IAutoWirable
{
public:
static Interface resolve() noexcept;
diff --git a/src/DI/container.hpp b/src/DI/container.hpp
index 974780a..2efb265 100644
--- a/src/DI/container.hpp
+++ b/src/DI/container.hpp
@@ -34,7 +34,7 @@ public:
template <class Interface>
BindingBuilder<Interface> bind() noexcept;
- template <class Interface, class = std::enable_if_t<std::is_class_v<Interface>>>
+ template <class Interface, class = std::enable_if_t<std::is_abstract_v<Interface>>>
std::shared_ptr<Interface> get() const noexcept;
template <typename Interface, typename = std::enable_if_t<is_func_v<Interface>>>
diff --git a/src/DI/object_type.hpp b/src/DI/object_type.hpp
index 84bb287..6b27682 100644
--- a/src/DI/object_type.hpp
+++ b/src/DI/object_type.hpp
@@ -25,14 +25,8 @@ public:
ObjectType() noexcept : BaseObjectType(typeid(Object)) {}
};
-class IObjectTypeHasher
+class ObjectTypeHasher
{
public:
- virtual std::size_t operator()(const BaseObjectType &object_type) const noexcept = 0;
-};
-
-class ObjectTypeHasher : public IObjectTypeHasher
-{
-public:
- std::size_t operator()(const BaseObjectType &object_type) const noexcept override;
+ std::size_t operator()(const BaseObjectType &object_type) const noexcept;
};
diff --git a/src/interfaces/engine.hpp b/src/interfaces/engine.hpp
index 6830340..72d8f81 100644
--- a/src/interfaces/engine.hpp
+++ b/src/interfaces/engine.hpp
@@ -2,8 +2,11 @@
#include <unordered_map>
+// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class ICLIGameEngine
{
public:
+ virtual ~ICLIGameEngine() noexcept = default;
+
virtual void start() noexcept = 0;
};
diff --git a/src/interfaces/window.hpp b/src/interfaces/window.hpp
index 5da9aff..d880762 100644
--- a/src/interfaces/window.hpp
+++ b/src/interfaces/window.hpp
@@ -2,8 +2,11 @@
#include "engine/data/bounds.hpp"
+// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class IWindow
{
public:
+ virtual ~IWindow() noexcept = default;
+
[[nodiscard]] virtual Bounds size() const noexcept = 0;
};