added logging module and a sandbox project
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef SCHEMA_HPP
|
||||
#define SCHEMA_HPP
|
||||
|
||||
#include "matador/logger/log_manager.hpp"
|
||||
#include "matador/object/many_to_many_relation.hpp"
|
||||
#include "matador/object/primary_key_resolver.hpp"
|
||||
#include "matador/object/error_code.hpp"
|
||||
@@ -10,6 +11,8 @@
|
||||
#include "matador/utils/result.hpp"
|
||||
#include "matador/utils/error.hpp"
|
||||
|
||||
#include "matador/logger/logger.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
@@ -77,9 +80,7 @@ public:
|
||||
static void on_attribute(const char * /*id*/, std::optional<AttributeType> &/*val*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
|
||||
|
||||
template<class ForeignPointerType>
|
||||
void on_belongs_to(const char * /*id*/, ForeignPointerType &/*obj*/, const utils::foreign_attributes &/*attr*/) {
|
||||
on_foreign_key<ForeignPointerType>();
|
||||
}
|
||||
void on_belongs_to(const char *id, ForeignPointerType &obj, const utils::foreign_attributes &attr);
|
||||
template<class ForeignPointerType>
|
||||
void on_has_one(const char * /*id*/, ForeignPointerType &/*obj*/, const utils::foreign_attributes &/*attr*/);
|
||||
|
||||
@@ -93,19 +94,16 @@ public:
|
||||
template<class ContainerType>
|
||||
void on_has_many_to_many(const char *id, ContainerType &collection, const utils::foreign_attributes &attr);
|
||||
|
||||
private:
|
||||
template<class ForeignPointerType>
|
||||
void on_foreign_key();
|
||||
|
||||
private:
|
||||
explicit relation_completer(schema_node& node)
|
||||
: node_(node)
|
||||
, schema_(node.schema_){}
|
||||
|
||||
, schema_(node.schema_)
|
||||
, log_(logger::create_logger("relation_completer")) {}
|
||||
|
||||
private:
|
||||
schema_node &node_;
|
||||
schema& schema_;
|
||||
logger::logger log_;
|
||||
};
|
||||
|
||||
|
||||
@@ -239,6 +237,7 @@ private:
|
||||
t_node_map node_map_;
|
||||
t_type_index_node_map type_index_node_map_;
|
||||
t_type_index_node_map expected_node_map_;
|
||||
logger::logger log_;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
@@ -250,7 +249,7 @@ void relation_completer<Type>::on_has_many( const char *id, CollectionType&, con
|
||||
return new many_to_many_relation<value_type, Type>(join_column, "id");
|
||||
});
|
||||
|
||||
schema_.attach_node(node, typeid(many_to_many_relation<value_type, Type>));
|
||||
// schema_.attach_node(node, typeid(many_to_many_relation<value_type, Type>));
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
@@ -262,7 +261,7 @@ void relation_completer<Type>::on_has_many( const char *id, CollectionType&, con
|
||||
return new many_to_many_relation<value_type, Type>(join_column, "value");
|
||||
});
|
||||
|
||||
const auto result = schema_.attach<many_to_many_relation<value_type, Type>>(id);
|
||||
const auto result = schema_.attach<many_to_relation<Type, value_type>>(id);
|
||||
if (!result) {
|
||||
// Todo: throw internal exception
|
||||
}
|
||||
@@ -280,15 +279,23 @@ void relation_completer<Type>::on_has_many_to_many( const char *id, CollectionTy
|
||||
return new many_to_many_relation<typename CollectionType::value_type, Type>(join_column, inverse_join_column);
|
||||
};
|
||||
|
||||
auto node = schema_node::make_relation_node<relation_type>(schema_, id);
|
||||
// auto node = schema_node::make_relation_node<relation_type>(schema_, id);
|
||||
|
||||
schema_.attach_node(node, typeid(relation_type));
|
||||
// schema_.attach_node(node, typeid(relation_type));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
template<class ContainerType>
|
||||
void relation_completer<Type>::on_has_many_to_many( const char *id, ContainerType &collection, const utils::foreign_attributes &attr ) {
|
||||
auto result = schema_.find_node(id);
|
||||
if (!result) {
|
||||
using relation_type = many_to_many_relation<typename ContainerType::value_type, Type>;
|
||||
// auto creator = [attr] {
|
||||
// return new relation_type(attr.join_column, attr.inverse_join_column);
|
||||
// };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
@@ -311,6 +318,11 @@ void relation_completer<Type>::on_has_one(const char * id, ForeignPointerType &/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
template<class ForeignPointerType>
|
||||
void relation_completer<Type>::on_belongs_to( const char* id, ForeignPointerType& obj, const utils::foreign_attributes& attr ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ public:
|
||||
static std::shared_ptr<schema_node> make_relation_node(object::schema& tree, const std::string& name, CreatorFunc &&creator) {
|
||||
auto node = std::shared_ptr<schema_node>(new schema_node(tree, name));
|
||||
|
||||
auto info = std::make_unique<object_info<Type>>(
|
||||
node,
|
||||
object_definition{attribute_definition_generator::generate<Type>(tree)}
|
||||
);
|
||||
node->info_ = std::move(info);
|
||||
// auto info = std::make_unique<object_info<Type>>(
|
||||
// node,
|
||||
// object_definition{attribute_definition_generator::generate<Type>(tree)}
|
||||
// );
|
||||
// node->info_ = std::move(info);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user