collection_resolver progress

This commit is contained in:
Sascha Kühl
2026-01-27 16:31:37 +01:00
parent b6cabbe3ed
commit 6205ae81c9
20 changed files with 294 additions and 134 deletions
@@ -0,0 +1,25 @@
#ifndef MATADOR_ABSTRACT_COLLECTION_RESOLVER_HPP
#define MATADOR_ABSTRACT_COLLECTION_RESOLVER_HPP
#include <string>
#include <typeindex>
namespace matador::object {
class abstract_collection_resolver {
public:
virtual ~abstract_collection_resolver() = default;
[[nodiscard]] const std::type_index& root_type() const;
[[nodiscard]] const std::type_index& type() const;
[[nodiscard]] const std::string& collection_name() const;
protected:
explicit abstract_collection_resolver(const std::type_index& root_type, const std::type_index& type, std::string collection_name);
public:
const std::type_index root_type_;
const std::type_index type_;
const std::string collection_name_;
};
}
#endif // MATADOR_ABSTRACT_COLLECTION_RESOLVER_HPP
+8 -17
View File
@@ -1,30 +1,21 @@
#ifndef MATADOR_COLLECTION_RESOLVER_HPP
#define MATADOR_COLLECTION_RESOLVER_HPP
#include "matador/object/abstract_type_resolver.hpp"
#include "matador/object/object_ptr.hpp"
#include "matador/object/abstract_collection_resolver.hpp"
#include <typeindex>
#include <vector>
namespace matador::utils {
class identifier;
}
namespace matador::object {
class abstract_collection_resolver {
public:
virtual ~abstract_collection_resolver() = default;
[[nodiscard]] const std::type_index& type() const { return type_; }
protected:
explicit abstract_collection_resolver(const std::type_index& ti) : type_(ti) {}
public:
const std::type_index type_;
};
template<typename Type>
class collection_resolver : public abstract_type_resolver {
class collection_resolver : public abstract_collection_resolver {
public:
collection_resolver() : abstract_type_resolver(typeid(std::vector<Type>)) {}
collection_resolver(const std::type_index& root_type, std::string collection_name)
: abstract_collection_resolver(root_type, typeid(Type), std::move(collection_name)) {}
virtual std::vector<Type> resolve(const utils::identifier& id) = 0;
};
@@ -1,7 +1,6 @@
#ifndef MATADOR_CONTAINER_RESOLVER_FACTORY_HPP
#define MATADOR_CONTAINER_RESOLVER_FACTORY_HPP
#include "matador/object/abstract_type_resolver_factory.hpp"
#include "matador/object/collection_resolver.hpp"
namespace matador::object {
@@ -13,11 +12,11 @@ public:
virtual void register_collection_resolver(std::shared_ptr<abstract_collection_resolver> &&resolver) = 0;
};
class collection_resolver_factory : public abstract_type_resolver_factory {
class collection_resolver_factory : public abstract_collection_resolver_factory {
public:
template<class Type>
std::shared_ptr<collection_resolver<Type>> resolver() {
const auto res = acquire_object_resolver(typeid(std::vector<object_ptr<Type>>));
std::shared_ptr<collection_resolver<Type>> resolver(const std::type_index &root_type, const std::string &collection_name) {
const auto res = acquire_collection_resolver(typeid(Type), root_type, collection_name);
if (!res) {
return std::dynamic_pointer_cast<collection_resolver<Type>>(res);
}
@@ -1,23 +0,0 @@
#ifndef MATADOR_CONTAINER_RESOLVER_HPP
#define MATADOR_CONTAINER_RESOLVER_HPP
#include "matador/object/abstract_type_resolver.hpp"
#include <memory>
#include <vector>
namespace matador::utils {
class identifier;
}
namespace matador::object {
template<typename Type>
class container_resolver : public abstract_type_resolver {
public:
container_resolver() : abstract_type_resolver(typeid(Type)) {}
virtual std::shared_ptr<std::vector<Type>> resolve(const utils::identifier& id) = 0;
};
}
#endif //MATADOR_CONTAINER_RESOLVER_HPP
@@ -18,10 +18,5 @@ public:
return std::dynamic_pointer_cast<object_resolver<Type>>(res);
}
};
class object_resolver_service : public object_resolver_factory, public collection_resolver_factory {
public:
};
}
#endif //MATADOR_OBJECT_RESOLVER_FACTORY_HPP