refactor select and insert methods to be less redundant

This commit is contained in:
Chris Cromer 2023-02-16 00:40:43 -03:00
parent bc93f42c00
commit f7b62e4645
Signed by: cromer
GPG Key ID: FA91071797BEEEC2
7 changed files with 18 additions and 18 deletions

View File

@ -87,7 +87,7 @@ void obelisk::KnowledgeBase::addEntities(std::vector<obelisk::Entity>& entities)
{ {
try try
{ {
entity.insertEntity(dbConnection_); entity.insert(dbConnection_);
} }
catch (obelisk::DatabaseConstraintException& exception) catch (obelisk::DatabaseConstraintException& exception)
{ {
@ -106,7 +106,7 @@ void obelisk::KnowledgeBase::addVerbs(std::vector<obelisk::Verb>& verbs)
{ {
try try
{ {
verb.insertVerb(dbConnection_); verb.insert(dbConnection_);
} }
catch (obelisk::DatabaseConstraintException& exception) catch (obelisk::DatabaseConstraintException& exception)
{ {
@ -125,7 +125,7 @@ void obelisk::KnowledgeBase::addFacts(std::vector<obelisk::Fact>& facts)
{ {
try try
{ {
fact.insertFact(dbConnection_); fact.insert(dbConnection_);
} }
catch (obelisk::DatabaseConstraintException& exception) catch (obelisk::DatabaseConstraintException& exception)
{ {
@ -142,17 +142,17 @@ void obelisk::KnowledgeBase::addFacts(std::vector<obelisk::Fact>& facts)
void obelisk::KnowledgeBase::getEntity(obelisk::Entity& entity) void obelisk::KnowledgeBase::getEntity(obelisk::Entity& entity)
{ {
entity.selectEntity(dbConnection_); entity.select(dbConnection_);
} }
void obelisk::KnowledgeBase::getVerb(obelisk::Verb& verb) void obelisk::KnowledgeBase::getVerb(obelisk::Verb& verb)
{ {
verb.selectVerb(dbConnection_); verb.select(dbConnection_);
} }
void obelisk::KnowledgeBase::getFact(obelisk::Fact& fact) void obelisk::KnowledgeBase::getFact(obelisk::Fact& fact)
{ {
fact.selectFact(dbConnection_); fact.select(dbConnection_);
} }
void obelisk::KnowledgeBase::getFloat(float& result1, float& result2, double var) void obelisk::KnowledgeBase::getFloat(float& result1, float& result2, double var)

View File

@ -12,7 +12,7 @@ const char* obelisk::Entity::createTable()
)"; )";
} }
void obelisk::Entity::selectEntity(sqlite3* dbConnection) void obelisk::Entity::select(sqlite3* dbConnection)
{ {
if (dbConnection == nullptr) if (dbConnection == nullptr)
{ {
@ -76,7 +76,7 @@ void obelisk::Entity::selectEntity(sqlite3* dbConnection)
} }
} }
void obelisk::Entity::insertEntity(sqlite3* dbConnection) void obelisk::Entity::insert(sqlite3* dbConnection)
{ {
if (dbConnection == nullptr) if (dbConnection == nullptr)
{ {

View File

@ -112,7 +112,7 @@ namespace obelisk
* *
* @param[in] dbConnection The database connection to use. * @param[in] dbConnection The database connection to use.
*/ */
void selectEntity(sqlite3* dbConnection); void select(sqlite3* dbConnection);
/** /**
* @brief Insert an Entity into the database based on the object's * @brief Insert an Entity into the database based on the object's
@ -120,7 +120,7 @@ namespace obelisk
* *
* @param[in] dbConnection The database connection to use. * @param[in] dbConnection The database connection to use.
*/ */
void insertEntity(sqlite3* dbConnection); void insert(sqlite3* dbConnection);
}; };
} // namespace obelisk } // namespace obelisk

View File

@ -19,7 +19,7 @@ const char* obelisk::Fact::createTable()
)"; )";
} }
void obelisk::Fact::selectFact(sqlite3* dbConnection) void obelisk::Fact::select(sqlite3* dbConnection)
{ {
if (dbConnection == nullptr) if (dbConnection == nullptr)
{ {
@ -126,7 +126,7 @@ void obelisk::Fact::selectFact(sqlite3* dbConnection)
} }
} }
void obelisk::Fact::insertFact(sqlite3* dbConnection) void obelisk::Fact::insert(sqlite3* dbConnection)
{ {
if (dbConnection == nullptr) if (dbConnection == nullptr)
{ {

View File

@ -76,8 +76,8 @@ namespace obelisk
bool& getIsTrue(); bool& getIsTrue();
void setIsTrue(bool isTrue); void setIsTrue(bool isTrue);
void selectFact(sqlite3* dbConnection); void select(sqlite3* dbConnection);
void insertFact(sqlite3* dbConnection); void insert(sqlite3* dbConnection);
}; };
} // namespace obelisk } // namespace obelisk

View File

@ -14,7 +14,7 @@ const char* obelisk::Verb::createTable()
)"; )";
} }
void obelisk::Verb::selectVerb(sqlite3* dbConnection) void obelisk::Verb::select(sqlite3* dbConnection)
{ {
if (dbConnection == nullptr) if (dbConnection == nullptr)
{ {
@ -76,7 +76,7 @@ void obelisk::Verb::selectVerb(sqlite3* dbConnection)
} }
} }
void obelisk::Verb::insertVerb(sqlite3* dbConnection) void obelisk::Verb::insert(sqlite3* dbConnection)
{ {
if (dbConnection == nullptr) if (dbConnection == nullptr)
{ {

View File

@ -112,14 +112,14 @@ namespace obelisk
* *
* @param[in] dbConnection The database connection to use. * @param[in] dbConnection The database connection to use.
*/ */
void selectVerb(sqlite3* dbConnection); void select(sqlite3* dbConnection);
/** /**
* @brief Insert a new verb into the KnowledgeBase. * @brief Insert a new verb into the KnowledgeBase.
* *
* @param[in] dbConnection The database connection to use. * @param[in] dbConnection The database connection to use.
*/ */
void insertVerb(sqlite3* dbConnection); void insert(sqlite3* dbConnection);
}; };
} // namespace obelisk } // namespace obelisk