stuff-from-scratch/src/database/DatabaseManager.cpp

42 lines
715 B
C++
Raw Normal View History

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
}
void DatabaseManager::CreateDatabase(const std::string& path)
{
2021-03-29 20:31:24 +00:00
mDatabase = Database::Create();
mDatabase->SetPath(path);
2020-05-02 07:31:03 +00:00
2021-03-29 20:31:24 +00:00
mDatabaseInterface = SqliteInterface::Create();
mDatabaseInterface->Open(mDatabase);
2020-05-02 07:31:03 +00:00
}
2022-01-01 18:46:31 +00:00
void DatabaseManager::Run(const std::string& statement)
{
mDatabaseInterface->Run(statement);
}
2020-05-02 07:31:03 +00:00
void DatabaseManager::OnShutDown()
{
2021-03-29 20:31:24 +00:00
if(mDatabaseInterface)
{
mDatabaseInterface->Close();
}
2020-05-02 07:31:03 +00:00
}