//  SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//  SPDX-License-Identifier: GPL-3.0-or-later

#include "dbinterface.h"

#include "mysql/mysql.h"

DBInterface::DBInterface(Type type):
    type(type),
    state(State::disconnected)
{}

DBInterface::~DBInterface() {}

std::unique_ptr<DBInterface> DBInterface::create(Type type) {
    switch (type) {
        case Type::mysql:
            return std::make_unique<MySQL>();
    }

    throw std::runtime_error("Unexpected database type: " + std::to_string((uint8_t)type));
}

DBInterface::State DBInterface::currentState() const {
    return state;
}