format to 80 columns for terminal display

This commit is contained in:
2023-02-20 22:05:57 -03:00
parent 09925b567c
commit adc5042c6c
30 changed files with 412 additions and 194 deletions

View File

@@ -1,13 +1,15 @@
#include <string>
/**
* @brief The obelisk namespace contains everything needed to compile obelisk code.
* @brief The obelisk namespace contains everything needed to compile obelisk
* code.
*
*/
namespace obelisk
{
/**
* @brief The obelisk library provides everything needed to consult the KnowledgeBase.
* @brief The obelisk library provides everything needed to consult the
* KnowledgeBase.
*
*/
class Obelisk

View File

@@ -44,7 +44,11 @@ obelisk::KnowledgeBase::~KnowledgeBase()
void obelisk::KnowledgeBase::enableForeignKeys()
{
char* errmsg;
int result = sqlite3_exec(dbConnection_, "PRAGMA foreign_keys = ON;", NULL, NULL, &errmsg);
int result = sqlite3_exec(dbConnection_,
"PRAGMA foreign_keys = ON;",
NULL,
NULL,
&errmsg);
if (result != SQLITE_OK)
{
if (errmsg)
@@ -86,7 +90,9 @@ void obelisk::KnowledgeBase::addEntities(std::vector<obelisk::Entity>& entities)
catch (obelisk::DatabaseConstraintException& exception)
{
// ignore unique constraint error
if (std::strcmp(exception.what(), "UNIQUE constraint failed: entity.name") != 0)
if (std::strcmp(exception.what(),
"UNIQUE constraint failed: entity.name")
!= 0)
{
throw;
}
@@ -105,7 +111,9 @@ void obelisk::KnowledgeBase::addVerbs(std::vector<obelisk::Verb>& verbs)
catch (obelisk::DatabaseConstraintException& exception)
{
// ignore unique constraint error
if (std::strcmp(exception.what(), "UNIQUE constraint failed: verb.name") != 0)
if (std::strcmp(exception.what(),
"UNIQUE constraint failed: verb.name")
!= 0)
{
throw;
}
@@ -124,7 +132,9 @@ void obelisk::KnowledgeBase::addActions(std::vector<obelisk::Action>& actions)
catch (obelisk::DatabaseConstraintException& exception)
{
// ignore unique constraint error
if (std::strcmp(exception.what(), "UNIQUE constraint failed: action.name") != 0)
if (std::strcmp(exception.what(),
"UNIQUE constraint failed: action.name")
!= 0)
{
throw;
}
@@ -153,7 +163,8 @@ void obelisk::KnowledgeBase::addFacts(std::vector<obelisk::Fact>& facts)
}
}
void obelisk::KnowledgeBase::addSuggestActions(std::vector<obelisk::SuggestAction>& suggestActions)
void obelisk::KnowledgeBase::addSuggestActions(
std::vector<obelisk::SuggestAction>& suggestActions)
{
for (auto& suggestAction : suggestActions)
{
@@ -185,7 +196,9 @@ void obelisk::KnowledgeBase::addRules(std::vector<obelisk::Rule>& rules)
catch (obelisk::DatabaseConstraintException& exception)
{
// ignore unique constraint error
if (std::strcmp(exception.what(), "UNIQUE constraint failed: rule.fact, rule.reason") != 0)
if (std::strcmp(exception.what(),
"UNIQUE constraint failed: rule.fact, rule.reason")
!= 0)
{
throw;
}
@@ -213,7 +226,8 @@ void obelisk::KnowledgeBase::getFact(obelisk::Fact& fact)
fact.selectById(dbConnection_);
}
void obelisk::KnowledgeBase::getSuggestAction(obelisk::SuggestAction& suggestAction)
void obelisk::KnowledgeBase::getSuggestAction(
obelisk::SuggestAction& suggestAction)
{
suggestAction.selectById(dbConnection_);
}
@@ -245,7 +259,9 @@ void obelisk::KnowledgeBase::updateIsTrue(obelisk::Fact& fact)
fact.updateIsTrue(dbConnection_);
}
void obelisk::KnowledgeBase::getFloat(float& result1, float& result2, double var)
void obelisk::KnowledgeBase::getFloat(float& result1,
float& result2,
double var)
{
result1 = (float) var;
result2 = (float) (var - (double) result1);

View File

@@ -18,7 +18,8 @@
namespace obelisk
{
/**
* @brief The KnowledgeBase class represents a collection of facts, rules, actions, and related language connectors.
* @brief The KnowledgeBase class represents a collection of facts, rules,
* actions, and related language connectors.
*
*/
class KnowledgeBase
@@ -45,8 +46,8 @@ namespace obelisk
/**
* @brief Enable foreign key functionality in the open database.
*
* This must always be done when the connection is opened or it will not enforce the foreign key
* constraints.
* This must always be done when the connection is opened or it will
* not enforce the foreign key constraints.
*/
void enableForeignKeys();
@@ -61,7 +62,8 @@ namespace obelisk
/**
* @brief Construct a new KnowledgeBase object.
*
* @param[in] filename The name of the file to save the knowledge base as.
* @param[in] filename The name of the file to save the knowledge
* base as.
* @param[in] flags The flags to open the KnowledgeBase with.
*/
KnowledgeBase(const char* filename, int flags);
@@ -69,10 +71,12 @@ namespace obelisk
/**
* @brief Construct a new KnowledgeBase object.
*
* @param[in] filename The name of the file to save the knowledge base as.
* @param[in] filename The name of the file to save the knowledge
* base as.
*/
KnowledgeBase(const char* filename) :
KnowledgeBase(filename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)
KnowledgeBase(filename,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)
{
}
@@ -86,96 +90,104 @@ namespace obelisk
/**
* @brief Add entities to the KnowledgeBase.
*
* @param[in,out] entities The entities to add. If the insert is successful it will have a row ID, if not
* the ID will be 0.
* @param[in,out] entities The entities to add. If the insert is
* successful it will have a row ID, if not the ID will be 0.
*/
void addEntities(std::vector<obelisk::Entity>& entities);
/**
* @brief Add verbs to the KnowledgeBase.
*
* @param[in,out] verbs The verbs to add. If the insert is successful it will have a row ID, if not the ID
* will be 0.
* @param[in,out] verbs The verbs to add. If the insert is
* successful it will have a row ID, if not the ID will be 0.
*/
void addVerbs(std::vector<obelisk::Verb>& verbs);
/**
* @brief Add actions to the KnowledgeBase.
*
* @param[in,out] actions The actions to add. If the insert is successful it will have a row ID, if nto the
* ID will be 0.
* @param[in,out] actions The actions to add. If the insert is
* successful it will have a row ID, if nto the ID will be 0.
*/
void addActions(std::vector<obelisk::Action>& actions);
/**
* @brief Add facts to the KnowledgeBase.
*
* @param[in,out] facts The facts to add. If the insert is successful it will have a row ID, if not the ID
* will be 0.
* @param[in,out] facts The facts to add. If the insert is
* successful it will have a row ID, if not the ID will be 0.
*/
void addFacts(std::vector<obelisk::Fact>& facts);
/**
* @brief Add suggested actions to the KnowledgeBase.
*
* @param[in,out] suggestActions The suggested actions to add. If the insert is successful it will have a
* row ID, if not the ID will be 0.
* @param[in,out] suggestActions The suggested actions to add. If
* the insert is successful it will have a row ID, if not the ID
* will be 0.
*/
void addSuggestActions(std::vector<obelisk::SuggestAction>& suggestActions);
void addSuggestActions(
std::vector<obelisk::SuggestAction>& suggestActions);
/**
* @brief Add rules to the KnowledgeBase.
*
* @param[in,out] rules The rules to add. If the insert is successful it will have a row ID, if not the ID
* will be 0.
* @param[in,out] rules The rules to add. If the insert is
* successful it will have a row ID, if not the ID will be 0.
*/
void addRules(std::vector<obelisk::Rule>& rules);
/**
* @brief Get an Entity object based on the ID it contains.
*
* @param[in,out] entity The Entity object should contain just the ID and the rest will be filled in.
* @param[in,out] entity The Entity object should contain just the
* ID and the rest will be filled in.
*/
void getEntity(obelisk::Entity& entity);
/**
* @brief Get a Verb object based on the ID it contains.
*
* @param[in,out] verb The Verb object should contain just the ID and the rest will be filled in.
* @param[in,out] verb The Verb object should contain just the ID
* and the rest will be filled in.
*/
void getVerb(obelisk::Verb& verb);
/**
* @brief Get an Action based on the ID it contains.
*
* @param[in] action The Action object should contain just the ID and the rest will be filled in.
* @param[in] action The Action object should contain just the ID
* and the rest will be filled in.
*/
void getAction(obelisk::Action& action);
/**
* @brief Get a Fact object based on the ID it contains.
*
* @param[in,out] fact The Fact object should contain just the ID and the rest will be filled in.
* @param[in,out] fact The Fact object should contain just the ID
* and the rest will be filled in.
*/
void getFact(obelisk::Fact& fact);
/**
* @brief Get a SuggestAction based on the ID it contains.
*
* @param[in,out] suggestAction The SuggestAction object should contain just the ID and the rest will be
* filled in.
* @param[in,out] suggestAction The SuggestAction object should
* contain just the ID and the rest will be filled in.
*/
void getSuggestAction(obelisk::SuggestAction& suggestAction);
/**
* @brief Get a Rule based on the ID it contains.
*
* @param[in,out] rule The Rule object should contain just the ID and the rest will be filled in.
* @param[in,out] rule The Rule object should contain just the ID
* and the rest will be filled in.
*/
void getRule(obelisk::Rule& rule);
/**
* @brief Check if a rule looks for this Fact, if so update its truth.
* @brief Check if a rule looks for this Fact, if so update its
* truth.
*
* @param[in,out] fact The Fact to check for existing rules.
*/
@@ -191,8 +203,9 @@ namespace obelisk
/**
* @brief Take a float and divide it into 2 floats.
*
* This is useful to store doubles in SQLite since SQLite doesn't have a double type. Instead just store the
* 2 floats in the database. Then after selecting them combine them.
* This is useful to store doubles in SQLite since SQLite doesn't
* have a double type. Instead just store the 2 floats in the
* database. Then after selecting them combine them.
*
* @param[out] result1 The first float generated from the double.
* @param[out] result2 The second float generated from the double.
@@ -203,7 +216,8 @@ namespace obelisk
/**
* @brief Combines 2 separated floats back into a double.
*
* This will recombine the separated floats from the getFloat method.
* This will recombine the separated floats from the getFloat
* method.
*
* @param[out] result The double generated from the combined floats.
* @param[in] var1 The first float to combine.

View File

@@ -21,7 +21,11 @@ void obelisk::Action::selectByName(sqlite3* dbConnection)
sqlite3_stmt* ppStmt = nullptr;
auto result = sqlite3_prepare_v2(dbConnection, "SELECT id, name FROM action WHERE name=?", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"SELECT id, name FROM action WHERE name=?",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
@@ -85,13 +89,18 @@ void obelisk::Action::insert(sqlite3* dbConnection)
sqlite3_stmt* ppStmt = nullptr;
auto result = sqlite3_prepare_v2(dbConnection, "INSERT INTO action (name) VALUES (?)", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"INSERT INTO action (name) VALUES (?)",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
throw obelisk::DatabaseException(sqlite3_errmsg(dbConnection));
}
result = sqlite3_bind_text(ppStmt, 1, getName().c_str(), -1, SQLITE_TRANSIENT);
result
= sqlite3_bind_text(ppStmt, 1, getName().c_str(), -1, SQLITE_TRANSIENT);
switch (result)
{
case SQLITE_OK :
@@ -118,7 +127,8 @@ void obelisk::Action::insert(sqlite3* dbConnection)
sqlite3_set_last_insert_rowid(dbConnection, 0);
break;
case SQLITE_CONSTRAINT :
throw obelisk::DatabaseConstraintException(sqlite3_errmsg(dbConnection));
throw obelisk::DatabaseConstraintException(
sqlite3_errmsg(dbConnection));
case SQLITE_BUSY :
throw obelisk::DatabaseBusyException();
break;

View File

@@ -8,7 +8,8 @@
namespace obelisk
{
/**
* @brief The Action model represents an action to take when a fact is true or false.
* @brief The Action model represents an action to take when a fact is true
* or false.
*
*/
class Action
@@ -107,14 +108,16 @@ namespace obelisk
void setName(std::string name);
/**
* @brief Select an Action from the datbase based on the object name.
* @brief Select an Action from the datbase based on the object
* name.
*
* @param[in] dbConnection The database connection to use.
*/
void selectByName(sqlite3* dbConnection);
/**
* @brief Insert an Action into the KnowledgeBase based on the object's fields.
* @brief Insert an Action into the KnowledgeBase based on the
* object's fields.
*
* @param[in] dbConnection The database connection to use.
*/

View File

@@ -21,7 +21,11 @@ void obelisk::Entity::selectByName(sqlite3* dbConnection)
sqlite3_stmt* ppStmt = nullptr;
auto result = sqlite3_prepare_v2(dbConnection, "SELECT id, name FROM entity WHERE name=?", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"SELECT id, name FROM entity WHERE name=?",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
@@ -85,13 +89,18 @@ void obelisk::Entity::insert(sqlite3* dbConnection)
sqlite3_stmt* ppStmt = nullptr;
auto result = sqlite3_prepare_v2(dbConnection, "INSERT INTO entity (name) VALUES (?)", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"INSERT INTO entity (name) VALUES (?)",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
throw obelisk::DatabaseException(sqlite3_errmsg(dbConnection));
}
result = sqlite3_bind_text(ppStmt, 1, getName().c_str(), -1, SQLITE_TRANSIENT);
result
= sqlite3_bind_text(ppStmt, 1, getName().c_str(), -1, SQLITE_TRANSIENT);
switch (result)
{
case SQLITE_OK :
@@ -118,7 +127,8 @@ void obelisk::Entity::insert(sqlite3* dbConnection)
sqlite3_set_last_insert_rowid(dbConnection, 0);
break;
case SQLITE_CONSTRAINT :
throw obelisk::DatabaseConstraintException(sqlite3_errmsg(dbConnection));
throw obelisk::DatabaseConstraintException(
sqlite3_errmsg(dbConnection));
case SQLITE_BUSY :
throw obelisk::DatabaseBusyException();
break;

View File

@@ -8,7 +8,8 @@
namespace obelisk
{
/**
* @brief The Entity model represents either a left or right side entity, typically used in facts and rules.
* @brief The Entity model represents either a left or right side entity,
* typically used in facts and rules.
*
*/
class Entity
@@ -107,14 +108,16 @@ namespace obelisk
void setName(std::string name);
/**
* @brief Select an Entity from the KnowledgeBase based on the object's name.
* @brief Select an Entity from the KnowledgeBase based on the
* object's name.
*
* @param[in] dbConnection The database connection to use.
*/
void selectByName(sqlite3* dbConnection);
/**
* @brief Insert an Entity into the KnowledgeBase based on the object's fields.
* @brief Insert an Entity into the KnowledgeBase based on the
* object's fields.
*
* @param[in] dbConnection The database connection to use.
*/

View File

@@ -35,14 +35,16 @@ namespace obelisk
* @param[in] errorCode The error code that came from sqlite.
*/
DatabaseException(const int errorCode) :
errorMessage_("database error " + std::to_string(errorCode) + " ocurred")
errorMessage_(
"database error " + std::to_string(errorCode) + " ocurred")
{
}
/**
* @brief Construct a new DatabaseException object.
*
* @param[in] errorMessage The error message to describe the exception.
* @param[in] errorMessage The error message to describe the
* exception.
*/
DatabaseException(const std::string& errorMessage) :
errorMessage_(errorMessage)
@@ -71,7 +73,8 @@ namespace obelisk
};
/**
* @brief Exception thrown if the string or blob size exceeds sqlite's limits.
* @brief Exception thrown if the string or blob size exceeds sqlite's
* limits.
*
*/
class DatabaseSizeException : public obelisk::DatabaseException
@@ -105,7 +108,8 @@ namespace obelisk
};
/**
* @brief Exception thrown if there is not enough memory to perform the operation.
* @brief Exception thrown if there is not enough memory to perform the
* operation.
*
*/
class DatabaseMemoryException : public obelisk::DatabaseException
@@ -134,7 +138,8 @@ namespace obelisk
*/
DatabaseBusyException()
{
setErrorMessage("database was busy and operation was not performed");
setErrorMessage(
"database was busy and operation was not performed");
}
};
@@ -175,7 +180,8 @@ namespace obelisk
/**
* @brief Construct a new DatabaseConstraintException object.
*
* @param[in] errorMessage The error message to send when the constraint is violated.
* @param[in] errorMessage The error message to send when the
* constraint is violated.
*/
DatabaseConstraintException(const std::string& errorMessage)
{

View File

@@ -36,7 +36,8 @@ void obelisk::Fact::selectById(sqlite3* dbConnection)
}
else
{
query = "SELECT id, left_entity, right_entity, verb, is_true FROM fact WHERE (id=?)";
query
= "SELECT id, left_entity, right_entity, verb, is_true FROM fact WHERE (id=?)";
}
auto result = sqlite3_prepare_v2(dbConnection, query, -1, &ppStmt, nullptr);
if (result != SQLITE_OK)
@@ -259,7 +260,8 @@ void obelisk::Fact::insert(sqlite3* dbConnection)
sqlite3_set_last_insert_rowid(dbConnection, 0);
break;
case SQLITE_CONSTRAINT :
throw obelisk::DatabaseConstraintException(sqlite3_errmsg(dbConnection));
throw obelisk::DatabaseConstraintException(
sqlite3_errmsg(dbConnection));
case SQLITE_BUSY :
throw obelisk::DatabaseBusyException();
break;
@@ -287,7 +289,11 @@ void obelisk::Fact::updateIsTrue(sqlite3* dbConnection)
sqlite3_stmt* ppStmt = nullptr;
auto result = sqlite3_prepare_v2(dbConnection, "UPDATE fact SET is_true=? WHERE id=?", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"UPDATE fact SET is_true=? WHERE id=?",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
throw obelisk::DatabaseException(sqlite3_errmsg(dbConnection));
@@ -338,7 +344,8 @@ void obelisk::Fact::updateIsTrue(sqlite3* dbConnection)
// Row updated
break;
case SQLITE_CONSTRAINT :
throw obelisk::DatabaseConstraintException(sqlite3_errmsg(dbConnection));
throw obelisk::DatabaseConstraintException(
sqlite3_errmsg(dbConnection));
case SQLITE_BUSY :
throw obelisk::DatabaseBusyException();
break;

View File

@@ -10,7 +10,8 @@
namespace obelisk
{
/**
* @brief The Fact model represents truth in the releationship between two entities separated by a verb.
* @brief The Fact model represents truth in the releationship between two
* entities separated by a verb.
*
*/
class Fact
@@ -35,7 +36,8 @@ namespace obelisk
obelisk::Entity rightEntity_;
/**
* @brief The Verb that represents the relationship in the expression.
* @brief The Verb that represents the relationship in the
* expression.
*
*/
obelisk::Verb verb_;
@@ -77,12 +79,17 @@ namespace obelisk
/**
* @brief Construct a new Fact object.
*
* @param[in] leftEntity The Entity on the left side of the expression.
* @param[in] rightEntity The Entity on the right side of the expression.
* @param[in] leftEntity The Entity on the left side of the
* expression.
* @param[in] rightEntity The Entity on the right side of the
* expression.
* @param[in] verb The Verb separating the entities.
* @param[in] isTrue Whether or not the fact is true.
*/
Fact(obelisk::Entity leftEntity, obelisk::Entity rightEntity, obelisk::Verb verb, bool isTrue = false) :
Fact(obelisk::Entity leftEntity,
obelisk::Entity rightEntity,
obelisk::Verb verb,
bool isTrue = false) :
id_(0),
leftEntity_(leftEntity),
rightEntity_(rightEntity),
@@ -95,8 +102,10 @@ namespace obelisk
* @brief Construct a new Fact object.
*
* @param[in] id The ID of the Fact in the KnowledgeBase.
* @param[in] leftEntity The Entity on the left side of the expression.
* @param[in] rightEntity The Entity on the right side of the expression.
* @param[in] leftEntity The Entity on the left side of the
* expression.
* @param[in] rightEntity The Entity on the right side of the
* expression.
* @param[in] verb The Verb separating the entities.
* @param[in] isTrue Whether or not the fact is true.
*/
@@ -192,7 +201,8 @@ namespace obelisk
void setIsTrue(bool isTrue);
/**
* @brief Select the Fact from the KnowledgeBase by IDs of the sub-objects.
* @brief Select the Fact from the KnowledgeBase by IDs of the
* sub-objects.
*
* @param[in] dbConnection The database connection to use.
*/
@@ -206,7 +216,8 @@ namespace obelisk
void insert(sqlite3* dbConnection);
/**
* @brief Update whether or not the fact is true in the KnowledgeBase.
* @brief Update whether or not the fact is true in the
* KnowledgeBase.
*
* @param[in] dbConnection The database connection.
*/

View File

@@ -111,8 +111,11 @@ void obelisk::Rule::insert(sqlite3* dbConnection)
sqlite3_stmt* ppStmt = nullptr;
auto result
= sqlite3_prepare_v2(dbConnection, "INSERT INTO rule (fact, reason) VALUES (?, ?)", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"INSERT INTO rule (fact, reason) VALUES (?, ?)",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
throw obelisk::DatabaseException(sqlite3_errmsg(dbConnection));
@@ -164,7 +167,8 @@ void obelisk::Rule::insert(sqlite3* dbConnection)
sqlite3_set_last_insert_rowid(dbConnection, 0);
break;
case SQLITE_CONSTRAINT :
throw obelisk::DatabaseConstraintException(sqlite3_errmsg(dbConnection));
throw obelisk::DatabaseConstraintException(
sqlite3_errmsg(dbConnection));
case SQLITE_BUSY :
throw obelisk::DatabaseBusyException();
break;
@@ -183,7 +187,9 @@ void obelisk::Rule::insert(sqlite3* dbConnection)
}
}
void obelisk::Rule::selectByReason(sqlite3* dbConnection, int reasonId, std::vector<obelisk::Rule>& rules)
void obelisk::Rule::selectByReason(sqlite3* dbConnection,
int reasonId,
std::vector<obelisk::Rule>& rules)
{
if (dbConnection == nullptr)
{
@@ -192,8 +198,11 @@ void obelisk::Rule::selectByReason(sqlite3* dbConnection, int reasonId, std::vec
sqlite3_stmt* ppStmt = nullptr;
auto result
= sqlite3_prepare_v2(dbConnection, "SELECT id, fact, reason FROM rule WHERE (reason=?)", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"SELECT id, fact, reason FROM rule WHERE (reason=?)",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
throw obelisk::DatabaseException(sqlite3_errmsg(dbConnection));

View File

@@ -134,7 +134,8 @@ namespace obelisk
void setReason(obelisk::Fact reason);
/**
* @brief Select the Rule from the KnowledgeBase by IDs of the sub-objects.
* @brief Select the Rule from the KnowledgeBase by IDs of the
* sub-objects.
*
* @param[in] dbConnection The database connection to use.
*/
@@ -146,7 +147,9 @@ namespace obelisk
* @param[in] dbConnection The database connection to use.
* @param[out] rules The rules to fill in from the database.
*/
static void selectByReason(sqlite3* dbConnection, int reasonId, std::vector<obelisk::Rule>& rules);
static void selectByReason(sqlite3* dbConnection,
int reasonId,
std::vector<obelisk::Rule>& rules);
/**
* @brief Insert the Rule into the KnowledgeBase.

View File

@@ -208,7 +208,8 @@ void obelisk::SuggestAction::insert(sqlite3* dbConnection)
sqlite3_set_last_insert_rowid(dbConnection, 0);
break;
case SQLITE_CONSTRAINT :
throw obelisk::DatabaseConstraintException(sqlite3_errmsg(dbConnection));
throw obelisk::DatabaseConstraintException(
sqlite3_errmsg(dbConnection));
case SQLITE_BUSY :
throw obelisk::DatabaseBusyException();
break;

View File

@@ -9,7 +9,8 @@
namespace obelisk
{
/**
* @brief The SuggestAction model representas the actions to take depending on if the Fact is true or false.
* @brief The SuggestAction model representas the actions to take depending
* on if the Fact is true or false.
*
*/
class SuggestAction
@@ -72,7 +73,9 @@ namespace obelisk
* @param[in] trueAction The true Action.
* @param[in] falseAction The false Action.
*/
SuggestAction(obelisk::Fact fact, obelisk::Action trueAction, obelisk::Action falseAction) :
SuggestAction(obelisk::Fact fact,
obelisk::Action trueAction,
obelisk::Action falseAction) :
id_(0),
fact_(fact),
trueAction_(trueAction),
@@ -88,7 +91,10 @@ namespace obelisk
* @param[in] trueAction The true Action.
* @param[in] falseAction The false Action.
*/
SuggestAction(int id, obelisk::Fact fact, obelisk::Action trueAction, obelisk::Action falseAction) :
SuggestAction(int id,
obelisk::Fact fact,
obelisk::Action trueAction,
obelisk::Action falseAction) :
id_(id),
fact_(fact),
trueAction_(trueAction),
@@ -160,7 +166,8 @@ namespace obelisk
void setFalseAction(obelisk::Action falseAction);
/**
* @brief Select the SuggestAction from the KnowledgeBase by IDs of the sub-objects.
* @brief Select the SuggestAction from the KnowledgeBase by IDs of
* the sub-objects.
*
* @param[in] dbConnection The database connection to use.
*/

View File

@@ -23,7 +23,11 @@ void obelisk::Verb::selectByName(sqlite3* dbConnection)
sqlite3_stmt* ppStmt = nullptr;
auto result = sqlite3_prepare_v2(dbConnection, "SELECT id, name FROM verb WHERE name=?", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"SELECT id, name FROM verb WHERE name=?",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
throw obelisk::DatabaseException(sqlite3_errmsg(dbConnection));
@@ -85,13 +89,18 @@ void obelisk::Verb::insert(sqlite3* dbConnection)
sqlite3_stmt* ppStmt = nullptr;
auto result = sqlite3_prepare_v2(dbConnection, "INSERT INTO verb (name) VALUES (?)", -1, &ppStmt, nullptr);
auto result = sqlite3_prepare_v2(dbConnection,
"INSERT INTO verb (name) VALUES (?)",
-1,
&ppStmt,
nullptr);
if (result != SQLITE_OK)
{
throw obelisk::DatabaseException(sqlite3_errmsg(dbConnection));
}
result = sqlite3_bind_text(ppStmt, 1, getName().c_str(), -1, SQLITE_TRANSIENT);
result
= sqlite3_bind_text(ppStmt, 1, getName().c_str(), -1, SQLITE_TRANSIENT);
switch (result)
{
case SQLITE_OK :
@@ -118,7 +127,8 @@ void obelisk::Verb::insert(sqlite3* dbConnection)
sqlite3_set_last_insert_rowid(dbConnection, 0);
break;
case SQLITE_CONSTRAINT :
throw obelisk::DatabaseConstraintException(sqlite3_errmsg(dbConnection));
throw obelisk::DatabaseConstraintException(
sqlite3_errmsg(dbConnection));
case SQLITE_BUSY :
throw obelisk::DatabaseBusyException();
break;

View File

@@ -8,7 +8,8 @@
namespace obelisk
{
/**
* @brief The Verb model represents a verb which is used to connnect entities.
* @brief The Verb model represents a verb which is used to connnect
* entities.
*
*/
class Verb