pica/database/dbinterface.h

37 lines
705 B
C++

#pragma once
#include <stdexcept>
#include <string>
#include <memory>
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;
protected:
DBInterface(Type type);
protected:
State state;
};