pica/database/dbinterface.h

45 lines
975 B
C
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
2023-12-07 20:32:43 +00:00
#pragma once
#include <stdexcept>
#include <string>
#include <memory>
2023-12-08 22:26:16 +00:00
#include <stdint.h>
2023-12-07 20:32:43 +00:00
class DBInterface {
public:
enum class Type {
mysql
};
enum class State {
disconnected,
connecting,
connected
};
static std::unique_ptr<DBInterface> create(Type type);
virtual ~DBInterface();
State currentState() const;
const Type type;
public:
virtual void connect(const std::string& path) = 0;
virtual void disconnect() = 0;
virtual void setDatabase(const std::string& newDatabase) = 0;
virtual void setCredentials(const std::string& login, const std::string& password) = 0;
virtual void migrate(uint8_t targetVersion) = 0;
2023-12-08 22:26:16 +00:00
virtual uint8_t getVersion() = 0;
virtual void setVersion(uint8_t version) = 0;
2023-12-07 20:32:43 +00:00
protected:
DBInterface(Type type);
protected:
State state;
};