renamed class attribute_definition_generator to attribute_generator

This commit is contained in:
Sascha Kühl
2025-11-21 09:24:53 +01:00
parent 758284c2b3
commit a146dce321
9 changed files with 44 additions and 45 deletions
@@ -52,18 +52,17 @@ private:
utils::basic_type type_{};
};
class attribute_definition_generator final {
class attribute_generator final {
private:
attribute_definition_generator(std::vector<attribute> &columns, const repository &repo);
attribute_generator(std::vector<attribute> &columns, const repository &repo);
public:
~attribute_definition_generator() = default;
~attribute_generator() = default;
template < class Type >
static std::vector<attribute> generate(const repository &repo)
{
static std::vector<attribute> generate(const repository &repo) {
std::vector<attribute> columns;
attribute_definition_generator gen(columns, repo);
attribute_generator gen(columns, repo);
Type obj;
access::process(gen, obj);
return columns;
@@ -72,7 +71,7 @@ public:
template < class Type >
static std::vector<attribute> generate(const Type& obj, const repository &repo) {
std::vector<attribute> columns;
attribute_definition_generator gen(columns, repo);
attribute_generator gen(columns, repo);
access::process(gen, obj);
return columns;
}
@@ -133,17 +132,17 @@ private:
};
template<typename ValueType>
void attribute_definition_generator::on_primary_key(const char *id, ValueType &x, const utils::primary_key_attribute& attr) {
void attribute_generator::on_primary_key(const char *id, ValueType &x, const utils::primary_key_attribute& attr) {
on_attribute(id, x, { attr.size(), utils::constraints::PRIMARY_KEY });
}
template<typename Type>
void attribute_definition_generator::on_attribute(const char *id, Type &x, const utils::field_attributes &attr) {
void attribute_generator::on_attribute(const char *id, Type &x, const utils::field_attributes &attr) {
columns_.emplace_back(id, utils::data_type_traits<Type>::type(attr.size()), attr, null_option_type::NOT_NULL);
}
template<typename Type>
void attribute_definition_generator::on_attribute(const char *id, std::optional<Type> & /*x*/, const utils::field_attributes &attr)
void attribute_generator::on_attribute(const char *id, std::optional<Type> & /*x*/, const utils::field_attributes &attr)
{
columns_.emplace_back(id, utils::data_type_traits<Type>::type(attr.size()), attr, null_option_type::NULLABLE);
}
+1 -1
View File
@@ -178,7 +178,7 @@ private:
private:
friend class internal::shadow_repository;
friend class repository_node;
friend class attribute_definition_generator;
friend class attribute_generator;
std::string name_;
std::shared_ptr<repository_node> root_;
+3 -3
View File
@@ -1,7 +1,7 @@
#ifndef SCHEMA_NODE_HPP
#define SCHEMA_NODE_HPP
#include "matador/object/attribute_definition_generator.hpp"
#include "matador/object/attribute_generator.hpp"
#include "matador/object/object_info.hpp"
#include "matador/object/primary_key_resolver.hpp"
@@ -23,7 +23,7 @@ public:
primary_key_resolver resolver;
auto pk_info = resolver.resolve<Type>();
auto ref_column = determine_reference_column(typeid(Type), name, pk_info, repo);
const auto attributes = attribute_definition_generator::generate<Type>(repo);
const auto attributes = attribute_generator::generate<Type>(repo);
auto info = std::make_unique<object_info<Type>>(
node,
attributes,
@@ -47,7 +47,7 @@ public:
auto obj = creator();
auto info = std::make_unique<object_info<Type>>(
result.value(),
attribute_definition_generator::generate(*obj, repo),
attribute_generator::generate(*obj, repo),
std::move(creator)
);
result.value()->info_ = std::move(info);