#pragma once #include "container.hpp" #include "function_wrapper.hpp" #include "object_wrapper.hpp" template BindingBuilder::BindingBuilder(Container *container) : _container(container) { } template template void BindingBuilder::to() { _container->bindings.emplace( ObjectType(), std::dynamic_pointer_cast( std::make_shared>(*_container))); } template void BindingBuilder::to_factory(Interface func) { _container->bindings.emplace(ObjectType(), std::dynamic_pointer_cast( std::make_shared>(func))); } template BindingBuilder Container::bind() { return BindingBuilder(this); } template std::shared_ptr Container::get() const { auto wrapper = std::dynamic_pointer_cast>>( bindings.at(ObjectType())); return wrapper->get(); } template Interface Container::get() const { auto wrapper = std::dynamic_pointer_cast>( bindings.at(ObjectType())); return wrapper->get(); }