aboutsummaryrefslogtreecommitdiff
path: root/src/DI/container.hpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-04-30 16:28:13 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:58 +0200
commit40d02748924aa7c48b04cf948204d8dacdfbbc74 (patch)
tree4d07a3703207295799b02cef52618a8f0c820542 /src/DI/container.hpp
parentdb6edcd473a684420e9a7611b24462df21165c1b (diff)
refactor: replace DI files with the yacppdic library
Diffstat (limited to 'src/DI/container.hpp')
-rw-r--r--src/DI/container.hpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/DI/container.hpp b/src/DI/container.hpp
deleted file mode 100644
index d5f52b8..0000000
--- a/src/DI/container.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#pragma once
-
-#include "DI/interfaces/wrapper.hpp"
-
-#include "DI/concepts.hpp"
-#include "DI/factory.hpp"
-#include "DI/object_type.hpp"
-
-#include <concepts>
-#include <functional>
-#include <memory>
-#include <unordered_map>
-
-class Container;
-
-template <typename Interface>
-class BindingBuilder
-{
-public:
- explicit BindingBuilder(Container *container) noexcept;
-
- template <typename Impl>
- requires Abstract<Interface> && std::derived_from<Impl, Interface>
- void to() noexcept;
-
- template <typename FactoryFunc>
- requires IsFactory<Interface> && std::constructible_from<Interface, FactoryFunc>
- void to_factory(FactoryFunc factory) noexcept;
-
-private:
- Container *_container;
-};
-
-class Container
-{
-public:
- Container() noexcept = default;
-
- template <typename Type>
- using WrapperPtr = std::shared_ptr<Type>;
-
- template <class Interface>
- auto bind() noexcept -> BindingBuilder<Interface>;
-
- template <class Interface>
- requires Abstract<Interface>
- auto get() const noexcept -> std::unique_ptr<Interface>;
-
- template <typename AFactory>
- requires IsFactory<AFactory>
- auto get() const noexcept -> AFactory;
-
- void add(BaseObjectType type, const WrapperPtr<IGenericWrapper> &wrapper) noexcept;
-
-private:
- std::unordered_map<BaseObjectType, WrapperPtr<IGenericWrapper>, ObjectTypeHasher>
- _bindings;
-};
-
-#include "container.tpp"