finish up comments

This commit is contained in:
2023-02-20 22:01:14 -03:00
parent 88f17011ef
commit 09925b567c
20 changed files with 492 additions and 117 deletions

View File

@@ -1,15 +1,13 @@
#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

@@ -18,8 +18,7 @@
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
@@ -46,8 +45,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();
@@ -62,8 +61,7 @@ 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);
@@ -71,8 +69,7 @@ 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)
@@ -89,103 +86,96 @@ 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);
/**
* @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.
*/
@@ -201,10 +191,8 @@ 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.
@@ -215,8 +203,7 @@ 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

@@ -8,8 +8,7 @@
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
@@ -108,16 +107,14 @@ 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

@@ -8,8 +8,7 @@
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
@@ -108,16 +107,14 @@ 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

@@ -42,8 +42,7 @@ namespace obelisk
/**
* @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)
@@ -72,8 +71,7 @@ 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
@@ -107,8 +105,7 @@ 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
@@ -178,8 +175,7 @@ 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

@@ -10,8 +10,7 @@
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
@@ -36,8 +35,7 @@ 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_;
@@ -79,10 +77,8 @@ 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.
*/
@@ -99,10 +95,8 @@ 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.
*/
@@ -198,8 +192,7 @@ 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.
*/
@@ -213,8 +206,7 @@ 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

@@ -134,8 +134,7 @@ 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.
*/

View File

@@ -9,8 +9,7 @@
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
@@ -161,8 +160,7 @@ 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

@@ -8,8 +8,7 @@
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