66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
#ifndef MATADOR_CONSTRAINT_HPP
|
|
#define MATADOR_CONSTRAINT_HPP
|
|
|
|
#include "matador/utils/constraints.hpp"
|
|
|
|
#include <memory>
|
|
#include <ostream>
|
|
#include <string>
|
|
#include <variant>
|
|
|
|
namespace matador::object {
|
|
|
|
class attribute;
|
|
class constraint_builder;
|
|
class constraint_generator;
|
|
class object;
|
|
|
|
class restriction {
|
|
public:
|
|
restriction() = default;
|
|
explicit restriction(std::string name);
|
|
|
|
[[nodiscard]] const std::string& name() const;
|
|
[[nodiscard]] const class attribute* attribute() const;
|
|
[[nodiscard]] std::string column_name() const;
|
|
[[nodiscard]] std::shared_ptr<object> owner() const;
|
|
[[nodiscard]] bool is_primary_key_constraint() const;
|
|
[[nodiscard]] bool is_foreign_key_constraint() const;
|
|
[[nodiscard]] bool is_unique_constraint() const;
|
|
[[nodiscard]] const std::string& ref_table_name() const;
|
|
[[nodiscard]] const std::string& ref_column_name() const;
|
|
|
|
friend std::ostream& operator<<(std::ostream& os, const restriction& c);
|
|
|
|
private:
|
|
friend class constraint_builder;
|
|
friend class constraints_generator;
|
|
friend class object_generator;
|
|
friend class object;
|
|
|
|
std::string name_;
|
|
std::variant<class attribute*, std::string> attr_;
|
|
std::shared_ptr<object> owner_;
|
|
std::shared_ptr<object> reference_;
|
|
utils::constraints options_{utils::constraints::None};
|
|
};
|
|
|
|
// class constraint_builder {
|
|
// public:
|
|
// constraint_builder& constraint(std::string name);
|
|
// constraint_builder& primary_key(std::string name);
|
|
// constraint_builder& foreign_key(std::string name);
|
|
// constraint_builder& references(std::string table, std::string column);
|
|
//
|
|
// operator class restriction() const;
|
|
//
|
|
// private:
|
|
// std::string constraint_name;
|
|
// utils::constraints options_{utils::constraints::None};
|
|
// std::string column_name;
|
|
// };
|
|
//
|
|
// constraint_builder constraint(std::string name);
|
|
|
|
}
|
|
#endif //MATADOR_CONSTRAINT_HPP
|