object generation progress

This commit is contained in:
Sascha Kühl
2025-12-10 17:05:24 +01:00
parent 9b7b74524f
commit 5afb616205
9 changed files with 59 additions and 45 deletions
+1 -4
View File
@@ -15,7 +15,7 @@ class repository;
class object {
public:
explicit object(std::string name, std::string alias = "");
explicit object(std::string name);
static const attribute& create_attribute(std::string name, const std::shared_ptr<object>& obj);
@@ -24,7 +24,6 @@ public:
[[nodiscard]] bool has_primary_key() const;
[[nodiscard]] const std::string& name() const;
[[nodiscard]] const std::string& alias() const;
void update_name(const std::string& name);
@@ -44,8 +43,6 @@ private:
friend class object_generator;
std::string name_;
std::string alias_;
attribute* pk_attribute_{nullptr};
utils::identifier pk_identifier_;
std::list<attribute> attributes_;
+5 -4
View File
@@ -54,13 +54,13 @@ private:
public:
template < class Type >
static std::shared_ptr<object> generate(repository &repo, const std::string &name, const std::string &alias = "") {
return generate(std::make_unique<Type>(), repo, name, alias);
static std::shared_ptr<object> generate(repository &repo, const std::string &name) {
return generate(std::make_unique<Type>(), repo, name);
}
template < class Type >
static std::shared_ptr<object> generate(std::unique_ptr<Type>&& t, repository &repo, const std::string &name, const std::string &alias = "") {
auto obj = std::make_shared<object>(name, alias);
static std::shared_ptr<object> generate(std::unique_ptr<Type>&& t, repository &repo, const std::string &name) {
auto obj = acquire_object(repo, typeid(Type), name);
object_generator gen(repo, obj);
access::process(gen, *t);
return obj;
@@ -115,6 +115,7 @@ private:
[[nodiscard]] std::shared_ptr<class object> fk_object(const std::type_index& ti) const;
static std::shared_ptr<object> acquire_object(repository &repo, const std::type_index &ti, const std::string& name);
private:
repository &repo_;
std::shared_ptr<object> object_;
+2 -1
View File
@@ -20,7 +20,8 @@ public:
template < typename Type >
static std::shared_ptr<repository_node> make_node(repository& repo, const std::string& name, creator_func<Type> creator = []{ return std::make_unique<Type>(); }) {
auto node = std::shared_ptr<repository_node>(new repository_node(repo, name, typeid(Type)));
const std::type_index ti(typeid(Type));
auto node = std::shared_ptr<repository_node>(new repository_node(repo, name, ti));
auto obj = object_generator::generate<Type>(creator(), repo, name);
auto info = std::make_unique<object_info<Type>>(
+3 -1
View File
@@ -20,7 +20,7 @@ public:
restriction() = default;
explicit restriction(std::string name);
[[nodiscard]] const std::string& name() const;
[[nodiscard]] std::string name() const;
[[nodiscard]] const class attribute* attribute() const;
[[nodiscard]] std::string column_name() const;
[[nodiscard]] std::shared_ptr<object> owner() const;
@@ -32,6 +32,8 @@ public:
friend std::ostream& operator<<(std::ostream& os, const restriction& c);
std::string prefix() const;
private:
friend class constraint_builder;
friend class constraints_generator;