#include "matador/object/basic_object_info.hpp" #include "matador/object/repository_node.hpp" #include namespace matador::object { // basic_object_info::basic_object_info(std::shared_ptr node, // const std::vector &attributes, // utils::identifier &&pk, // const std::shared_ptr &pk_as_fk_column) // : node_(std::move(node)) // , attributes_(attributes) // , identifier_(std::move(pk)) // , pk_as_fk_column_(pk_as_fk_column) { // } // // basic_object_info::basic_object_info(std::shared_ptr node, // const std::vector &attributes) // : node_(std::move(node)) // , attributes_(attributes) {} basic_object_info::basic_object_info(std::shared_ptr node, std::unique_ptr&& obj) : object_(std::move(obj)) , node_(std::move(node)) {} std::type_index basic_object_info::type_index() const { return node_->type_index(); } std::string basic_object_info::name() const { return node_->name(); } const std::list& basic_object_info::attributes() const { return object_->attributes(); } bool basic_object_info::has_primary_key() const { return object_->has_primary_key(); } const utils::identifier& basic_object_info::primary_key() const { return object_->primary_key(); } attribute* basic_object_info::primary_key_attribute() const { return object_->primary_key_attribute(); } basic_object_info::endpoint_iterator basic_object_info::register_relation_endpoint(const std::type_index &type, const std::shared_ptr &endpoint) { return relation_endpoints_.insert(std::make_pair(type, endpoint)).first; } void basic_object_info::unregister_relation_endpoint(const std::type_index &type) { relation_endpoints_.erase(type); } basic_object_info::const_endpoint_iterator basic_object_info::find_relation_endpoint(const std::type_index &type) const { return relation_endpoints_.find(type); } basic_object_info::endpoint_iterator basic_object_info::find_relation_endpoint(const std::type_index &type) { return relation_endpoints_.find(type); } basic_object_info::const_endpoint_iterator basic_object_info::find_relation_endpoint(const std::string &field) const { return std::find_if(relation_endpoints_.begin(), relation_endpoints_.end(), [&field](const t_endpoint_map::value_type &value) { return value.second->field_name() == field; }); } basic_object_info::endpoint_iterator basic_object_info::find_relation_endpoint(const std::string &field) { return std::find_if(relation_endpoints_.begin(), relation_endpoints_.end(), [&field](const t_endpoint_map::value_type &value) { return value.second->field_name() == field; }); } basic_object_info::endpoint_iterator basic_object_info::endpoint_begin() { return relation_endpoints_.begin(); } basic_object_info::const_endpoint_iterator basic_object_info::endpoint_begin() const { return relation_endpoints_.begin(); } basic_object_info::endpoint_iterator basic_object_info::endpoint_end() { return relation_endpoints_.end(); } basic_object_info::const_endpoint_iterator basic_object_info::endpoint_end() const { return relation_endpoints_.end(); } std::size_t basic_object_info::endpoints_size() const { return relation_endpoints_.size(); } bool basic_object_info::endpoints_empty() const { return relation_endpoints_.empty(); } } // namespace matador::object