108 lines
3.6 KiB
C++
108 lines
3.6 KiB
C++
#include "matador/object/basic_object_info.hpp"
|
|
|
|
#include "matador/object/repository_node.hpp"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace matador::object {
|
|
// basic_object_info::basic_object_info(std::shared_ptr<repository_node> node,
|
|
// const std::vector<attribute> &attributes,
|
|
// utils::identifier &&pk,
|
|
// const std::shared_ptr<attribute> &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<repository_node> node,
|
|
// const std::vector<attribute> &attributes)
|
|
// : node_(std::move(node))
|
|
// , attributes_(attributes) {}
|
|
|
|
basic_object_info::basic_object_info(std::shared_ptr<repository_node> node, std::unique_ptr<object>&& 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<attribute>& basic_object_info::attributes() const {
|
|
return object_->attributes();
|
|
}
|
|
|
|
const std::list<class constraint>& basic_object_info::constraints() const {
|
|
return object_->constraints();
|
|
}
|
|
|
|
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<relation_endpoint> &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
|