aboutsummaryrefslogtreecommitdiff
path: root/src/DI/container.hpp
diff options
context:
space:
mode:
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"