#pragma once #include "DI/interfaces/wrapper.hpp" #include "DI/concepts.hpp" #include "DI/factory.hpp" #include "DI/object_type.hpp" #include #include #include #include class Container; template class BindingBuilder { public: explicit BindingBuilder(Container *container) noexcept; template requires Abstract && std::derived_from void to() noexcept; template requires IsFactory && std::constructible_from void to_factory(FactoryFunc factory) noexcept; private: Container *_container; }; class Container { public: Container() noexcept = default; template using WrapperPtr = std::shared_ptr; template auto bind() noexcept -> BindingBuilder; template requires Abstract auto get() const noexcept -> std::unique_ptr; template requires IsFactory auto get() const noexcept -> AFactory; void add(BaseObjectType type, const WrapperPtr &wrapper) noexcept; private: std::unordered_map, ObjectTypeHasher> _bindings; }; #include "container.tpp"