71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
#include "matador/object/object.hpp"
|
|
|
|
namespace matador::object {
|
|
object::object( std::string name, std::string alias )
|
|
: name_(std::move(name))
|
|
, alias_(std::move(alias)) {}
|
|
|
|
const attribute& object::create_attribute( std::string name, object& obj ) {
|
|
attribute attr{std::move(name)};
|
|
attr.owner_ = &obj;
|
|
return obj.attributes_.emplace_back(std::move(attr));
|
|
}
|
|
|
|
void object::add_attribute( attribute attr ) {
|
|
auto &ref = attributes_.emplace_back(std::move(attr));
|
|
ref.owner_ = this;
|
|
}
|
|
|
|
void object::add_constraint( class constraint c ) {
|
|
auto &ref = constraints_.emplace_back(std::move(c));
|
|
ref.owner_ = this;
|
|
}
|
|
|
|
attribute* object::primary_key_attribute() const {
|
|
return pk_attribute_;
|
|
}
|
|
|
|
const utils::identifier& object::primary_key() const {
|
|
return pk_identifier_;
|
|
}
|
|
|
|
bool object::has_primary_key() const {
|
|
return pk_attribute_ != nullptr;
|
|
}
|
|
|
|
const std::string& object::name() const {
|
|
return name_;
|
|
}
|
|
|
|
const std::string& object::alias() const {
|
|
return alias_;
|
|
}
|
|
|
|
void object::update_name(const std::string& name) {
|
|
name_ = name;
|
|
}
|
|
|
|
bool object::has_attributes() const {
|
|
return attributes_.empty();
|
|
}
|
|
|
|
size_t object::attribute_count() const {
|
|
return attributes_.size();
|
|
}
|
|
|
|
const std::vector<attribute>& object::attributes() const {
|
|
return attributes_;
|
|
}
|
|
|
|
bool object::has_constraints() const {
|
|
return constraints_.empty();
|
|
}
|
|
|
|
size_t object::constraint_count() const {
|
|
return constraints_.size();
|
|
}
|
|
|
|
const std::vector<class constraint>& object::constraints() const {
|
|
return constraints_;
|
|
}
|
|
} |