obelisk/src/models/entity.h

128 lines
3.1 KiB
C
Raw Normal View History

#ifndef OBELISK_MODELS_ENTITY_H
#define OBELISK_MODELS_ENTITY_H
2022-11-26 00:32:06 -03:00
#include <sqlite3.h>
#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.
*
*/
class Entity
{
private:
2022-12-10 18:29:21 -03:00
/**
* @brief The ID of the Entity.
*
*/
int id_;
2022-12-10 18:29:21 -03:00
/**
* @brief The name of the Entity.
*
*/
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-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.
*/
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.
*/
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.
*/
void selectEntity(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.
*/
void insertEntity(sqlite3* dbConnection);
};
} // namespace obelisk
#endif