#ifndef MATADOR_CONTAINER_RESOLVER_FACTORY_HPP #define MATADOR_CONTAINER_RESOLVER_FACTORY_HPP #include "matador/object/collection_resolver.hpp" namespace matador::object { class abstract_collection_resolver_factory { public: virtual ~abstract_collection_resolver_factory() = default; [[nodiscard]] virtual std::shared_ptr acquire_collection_resolver(const std::type_index &root_type, const std::type_index &element_type, const std::string &collection_name) const = 0; virtual void register_collection_resolver(std::shared_ptr &&resolver) = 0; }; class collection_resolver_factory : public abstract_collection_resolver_factory { public: template [[nodiscard]] std::shared_ptr> resolver(const std::type_index &root_type, const std::string &collection_name) const { const auto res = acquire_collection_resolver(typeid(Type), root_type, collection_name); if (!res) { return std::dynamic_pointer_cast>(res); } return std::dynamic_pointer_cast>(res); } }; } #endif //MATADOR_CONTAINER_RESOLVER_FACTORY_HPP