1
0
forked from blue/pica
pica/database/interface.cpp

27 lines
613 B
C++
Raw Normal View History

2023-12-30 22:42:11 +00:00
//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
2023-12-29 17:40:00 +00:00
#include "interface.h"
2023-12-07 20:32:43 +00:00
#include "mysql/mysql.h"
2023-12-29 17:40:00 +00:00
DB::Interface::Interface(Type type):
2023-12-07 20:32:43 +00:00
type(type),
state(State::disconnected)
{}
2023-12-29 17:40:00 +00:00
DB::Interface::~Interface() {}
2023-12-07 20:32:43 +00:00
2023-12-29 17:40:00 +00:00
std::unique_ptr<DB::Interface> DB::Interface::create(Type type) {
2023-12-07 20:32:43 +00:00
switch (type) {
case Type::mysql:
return std::make_unique<MySQL>();
}
throw std::runtime_error("Unexpected database type: " + std::to_string((uint8_t)type));
}
2023-12-29 17:40:00 +00:00
DB::Interface::State DB::Interface::currentState() const {
2023-12-07 20:32:43 +00:00
return state;
}