2020-05-02 07:31:03 +00:00
|
|
|
#include "DatabaseManager.h"
|
|
|
|
|
|
|
|
DatabaseManager::DatabaseManager()
|
2021-03-29 20:31:24 +00:00
|
|
|
: mDatabase(),
|
|
|
|
mDatabaseInterface()
|
2020-05-02 07:31:03 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DatabaseManager::~DatabaseManager()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-03-29 20:31:24 +00:00
|
|
|
std::unique_ptr<DatabaseManager> DatabaseManager::Create()
|
2020-05-02 07:31:03 +00:00
|
|
|
{
|
2021-03-29 20:31:24 +00:00
|
|
|
return std::make_unique<DatabaseManager>();
|
2020-05-02 07:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-01 10:52:48 +00:00
|
|
|
void DatabaseManager::openDatabase(const Path& path)
|
2020-05-02 07:31:03 +00:00
|
|
|
{
|
2021-03-29 20:31:24 +00:00
|
|
|
mDatabase = Database::Create();
|
2022-12-01 10:52:48 +00:00
|
|
|
mDatabase->setPath(path);
|
2020-05-02 07:31:03 +00:00
|
|
|
|
2021-03-29 20:31:24 +00:00
|
|
|
mDatabaseInterface = SqliteInterface::Create();
|
2022-12-01 10:52:48 +00:00
|
|
|
mDatabaseInterface->open(mDatabase.get());
|
2020-05-02 07:31:03 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 10:52:48 +00:00
|
|
|
void DatabaseManager::run(const std::string& statement)
|
2022-01-01 18:46:31 +00:00
|
|
|
{
|
2022-12-01 10:52:48 +00:00
|
|
|
mDatabaseInterface->run(statement);
|
2022-01-01 18:46:31 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 10:52:48 +00:00
|
|
|
void DatabaseManager::onShutDown()
|
2020-05-02 07:31:03 +00:00
|
|
|
{
|
2021-03-29 20:31:24 +00:00
|
|
|
if(mDatabaseInterface)
|
|
|
|
{
|
2022-12-01 10:52:48 +00:00
|
|
|
mDatabaseInterface->close();
|
2021-03-29 20:31:24 +00:00
|
|
|
}
|
2020-05-02 07:31:03 +00:00
|
|
|
}
|