#include "DatabaseManager.h"

DatabaseManager::DatabaseManager()
    : mDatabase(),
      mDatabaseInterface()
{

}

DatabaseManager::~DatabaseManager()
{

}

std::unique_ptr<DatabaseManager> DatabaseManager::Create()
{
    return std::make_unique<DatabaseManager>();
}


void DatabaseManager::openDatabase(const Path& path)
{
    mDatabase = Database::Create();
    mDatabase->setPath(path);

    mDatabaseInterface = SqliteInterface::Create();
    mDatabaseInterface->open(mDatabase.get());
}

void DatabaseManager::run(const std::string& statement)
{
    mDatabaseInterface->run(statement);
}

void DatabaseManager::onShutDown()
{
    if(mDatabaseInterface)
    {
        mDatabaseInterface->close();
    }
}
