2022-10-25 17:08:36 -03:00
|
|
|
#ifndef OBELISK_MODELS_ENTITY_H
|
|
|
|
#define OBELISK_MODELS_ENTITY_H
|
|
|
|
|
2022-11-26 00:32:06 -03:00
|
|
|
#include <sqlite3.h>
|
|
|
|
|
2022-10-25 17:08:36 -03:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace obelisk
|
|
|
|
{
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief The Entity model represents either a left or right side entity,
|
|
|
|
* typically used in facts and rules.
|
|
|
|
*
|
|
|
|
*/
|
2022-10-25 17:08:36 -03:00
|
|
|
class Entity
|
|
|
|
{
|
|
|
|
private:
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief The ID of the Entity.
|
|
|
|
*
|
|
|
|
*/
|
2022-10-25 17:08:36 -03:00
|
|
|
int id_;
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief The name of the Entity.
|
|
|
|
*
|
|
|
|
*/
|
2022-10-25 17:08:36 -03:00
|
|
|
std::string name_;
|
|
|
|
|
|
|
|
public:
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief Construct a new Entity object.
|
|
|
|
*
|
|
|
|
*/
|
2022-11-01 01:04:41 -03:00
|
|
|
Entity() :
|
|
|
|
id_(0),
|
|
|
|
name_("")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief Construct a new Entity object.
|
|
|
|
*
|
|
|
|
* @param[in] id The ID of the Entity.
|
|
|
|
*/
|
2022-11-01 01:04:41 -03:00
|
|
|
Entity(int id) :
|
|
|
|
id_(id),
|
|
|
|
name_("")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief Construct a new Entity object.
|
|
|
|
*
|
|
|
|
* @param[in] name The name of the Entity.
|
|
|
|
*/
|
2022-11-01 01:04:41 -03:00
|
|
|
Entity(std::string name) :
|
|
|
|
id_(0),
|
|
|
|
name_(name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief Construct a new Entity object.
|
|
|
|
*
|
|
|
|
* @param[in] id The ID of the Entity.
|
|
|
|
* @param[in] name The name of the Entity.
|
|
|
|
*/
|
2022-11-01 01:04:41 -03:00
|
|
|
Entity(int id, std::string name) :
|
|
|
|
id_(id),
|
|
|
|
name_(name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief Create the table in the knowledge base.
|
|
|
|
*
|
|
|
|
* @return const char* Returns the query used to create the table.
|
|
|
|
*/
|
2022-11-01 01:04:41 -03:00
|
|
|
static const char* createTable();
|
2022-10-25 17:08:36 -03:00
|
|
|
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief Get the ID of the Entity.
|
|
|
|
*
|
|
|
|
* @return int& Returns the ID.
|
|
|
|
*/
|
2022-11-26 00:32:06 -03:00
|
|
|
int& getId();
|
2022-12-10 18:29:21 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the ID of the Entity.
|
|
|
|
*
|
|
|
|
* @param[in] id The ID of the Entity.
|
|
|
|
*/
|
2022-10-25 17:08:36 -03:00
|
|
|
void setId(int id);
|
|
|
|
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief Get the name of the Entity.
|
|
|
|
*
|
|
|
|
* @return std::string& The name of the Entity.
|
|
|
|
*/
|
2022-11-26 00:32:06 -03:00
|
|
|
std::string& getName();
|
2022-12-10 18:29:21 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the name of the Entity.
|
|
|
|
*
|
|
|
|
* @param[in] name The name of the Entity.
|
|
|
|
*/
|
2022-10-25 17:08:36 -03:00
|
|
|
void setName(std::string name);
|
2022-11-26 00:32:06 -03:00
|
|
|
|
2022-12-10 18:29:21 -03:00
|
|
|
/**
|
|
|
|
* @brief Select an Entity from the database based on the object's
|
|
|
|
* ID.
|
|
|
|
*
|
|
|
|
* @param[in] dbConnection The database connection to use.
|
|
|
|
*/
|
2023-02-16 00:40:43 -03:00
|
|
|
void select(sqlite3* dbConnection);
|
2022-12-10 18:29:21 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Insert an Entity into the database based on the object's
|
|
|
|
* fields.
|
|
|
|
*
|
|
|
|
* @param[in] dbConnection The database connection to use.
|
|
|
|
*/
|
2023-02-16 00:40:43 -03:00
|
|
|
void insert(sqlite3* dbConnection);
|
2022-10-25 17:08:36 -03:00
|
|
|
};
|
|
|
|
} // namespace obelisk
|
|
|
|
|
|
|
|
#endif
|