2022-11-01 01:04:41 -03:00
|
|
|
#include "models/rule.h"
|
|
|
|
|
|
|
|
const char* obelisk::Rule::createTable()
|
|
|
|
{
|
|
|
|
return R"(
|
|
|
|
CREATE TABLE "rule" (
|
|
|
|
"id" INTEGER NOT NULL UNIQUE,
|
|
|
|
"fact" INTEGER NOT NULL,
|
|
|
|
"reason" INTEGER NOT NULL CHECK("reason" != "fact"),
|
|
|
|
PRIMARY KEY("id" AUTOINCREMENT),
|
2022-11-29 00:06:35 -03:00
|
|
|
UNIQUE("fact", "reason"),
|
2022-11-01 01:04:41 -03:00
|
|
|
FOREIGN KEY("fact") REFERENCES "fact"("id") ON DELETE RESTRICT,
|
|
|
|
FOREIGN KEY("reason") REFERENCES "fact"("id") ON DELETE RESTRICT
|
|
|
|
);
|
|
|
|
)";
|
|
|
|
}
|
|
|
|
|
2022-11-26 00:32:06 -03:00
|
|
|
int& obelisk::Rule::getId()
|
2022-11-01 01:04:41 -03:00
|
|
|
{
|
|
|
|
return id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void obelisk::Rule::setId(int id)
|
|
|
|
{
|
|
|
|
id_ = id;
|
|
|
|
}
|
|
|
|
|
2022-11-26 00:32:06 -03:00
|
|
|
obelisk::Fact& obelisk::Rule::getFact()
|
2022-11-01 01:04:41 -03:00
|
|
|
{
|
|
|
|
return fact_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void obelisk::Rule::setFact(obelisk::Fact fact)
|
|
|
|
{
|
|
|
|
fact_ = fact;
|
|
|
|
}
|
|
|
|
|
2022-11-26 00:32:06 -03:00
|
|
|
obelisk::Fact& obelisk::Rule::getReason()
|
2022-11-01 01:04:41 -03:00
|
|
|
{
|
|
|
|
return reason_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void obelisk::Rule::setReason(obelisk::Fact reason)
|
|
|
|
{
|
|
|
|
reason_ = reason;
|
|
|
|
}
|