70 lines
2.4 KiB
C++
70 lines
2.4 KiB
C++
#ifndef BASIC_PROTOTYPE_INFO_HPP
|
|
#define BASIC_PROTOTYPE_INFO_HPP
|
|
|
|
#include "matador/object/attribute.hpp"
|
|
#include "matador/object/constraint.hpp"
|
|
#include "matador/object/relation_endpoint.hpp"
|
|
|
|
#include "matador/utils/identifier.hpp"
|
|
|
|
#include <list>
|
|
#include <string>
|
|
#include <typeindex>
|
|
|
|
namespace matador::object {
|
|
|
|
class repository_node;
|
|
class relation_endpoint;
|
|
|
|
class basic_object_info {
|
|
public:
|
|
using t_endpoint_map = std::unordered_map<std::type_index, std::shared_ptr<relation_endpoint>>;
|
|
using endpoint_iterator = t_endpoint_map::iterator;
|
|
using const_endpoint_iterator = t_endpoint_map::const_iterator;
|
|
|
|
virtual ~basic_object_info() = default;
|
|
|
|
[[nodiscard]] std::type_index type_index() const;
|
|
[[nodiscard]] std::string name() const;
|
|
[[nodiscard]] const std::list<attribute>& attributes() const;
|
|
[[nodiscard]] const std::list<class constraint>& constraints() const;
|
|
|
|
[[nodiscard]] bool has_primary_key() const;
|
|
[[nodiscard]] const utils::identifier& primary_key() const;
|
|
[[nodiscard]] attribute* primary_key_attribute() const;
|
|
|
|
void update_name(const std::string& name);
|
|
|
|
endpoint_iterator register_relation_endpoint(const std::type_index &type, const std::shared_ptr<relation_endpoint> &endpoint);
|
|
void unregister_relation_endpoint(const std::type_index &type);
|
|
|
|
[[nodiscard]] const_endpoint_iterator find_relation_endpoint(const std::type_index &type) const;
|
|
endpoint_iterator find_relation_endpoint(const std::type_index &type);
|
|
|
|
[[nodiscard]] const_endpoint_iterator find_relation_endpoint(const std::string &field) const;
|
|
endpoint_iterator find_relation_endpoint(const std::string &field);
|
|
|
|
endpoint_iterator endpoint_begin();
|
|
[[nodiscard]] const_endpoint_iterator endpoint_begin() const;
|
|
|
|
endpoint_iterator endpoint_end();
|
|
[[nodiscard]] const_endpoint_iterator endpoint_end() const;
|
|
|
|
[[nodiscard]] std::size_t endpoints_size() const;
|
|
[[nodiscard]] bool endpoints_empty() const;
|
|
|
|
protected:
|
|
basic_object_info(std::shared_ptr<repository_node> node, std::unique_ptr<object> &&obj);
|
|
|
|
protected:
|
|
std::unique_ptr<object> object_;
|
|
std::shared_ptr<repository_node> node_; /**< prototype node of the represented object type */
|
|
t_endpoint_map relation_endpoints_;
|
|
};
|
|
|
|
using basic_object_info_ref = std::reference_wrapper<const basic_object_info>;
|
|
|
|
}
|
|
|
|
#endif //BASIC_PROTOTYPE_INFO_HPP
|