#ifndef SQLPP_REF_CONSTRAINT_HPP
#define SQLPP_REF_CONSTRAINT_HPP
#include <sqlpp/config.hpp>
#include <sqlpp/utils.hpp>
#include <sqlpp/predefs.hpp>
#include <sqlpp/constraint.hpp>
namespace sqlpp{
class ref_constraint :
public constraint
{
public:
enum EventAction
{
EventActionUnknown,
EventActionNoAction,
EventActionCascade,
EventActionSetNull,
EventActionSetDefault
};
enum Match
{
MatchUnknown,
MatchFull,
MatchPartial
};
protected:
friend table;
ref_constraint(
table_shared_ptr table_,
string_const_reference name_,
field_container_const_reference fields_,
table_shared_ptr reference_table_,
EventAction on_delete_ = EventActionUnknown,
EventAction on_update_ = EventActionUnknown,
Match match_ = MatchUnknown
);
public:
virtual string_type get_sql() const;
table_shared_ptr get_reference_table() const;
protected:
virtual const char* get_type_string() const { return "FOREIGN KEY";};
virtual const char* get_small_type_string() const { return "FK";};
protected:
const char* event_action_to_string(EventAction action) const;
const char* match_to_string(Match match) const;
private:
table_weak_ptr m_reference_table;
EventAction m_on_delete;
EventAction m_on_update;
Match m_match;
};
typedef boost::shared_ptr< ref_constraint > ref_constraint_shared_ptr;
typedef std::vector< ref_constraint_shared_ptr > ref_constraint_container;
};
#endif