2017-12-09 20:21:22 +01:00
|
|
|
|
#ifndef OPENDATABASE_H
|
2017-02-01 18:01:02 +01:00
|
|
|
|
#define OPENDATABASE_H
|
|
|
|
|
|
|
2017-08-23 13:27:23 +02:00
|
|
|
|
#include "ConnectionConfig.h"
|
|
|
|
|
|
#include "Expected.h"
|
2017-12-09 20:21:22 +01:00
|
|
|
|
#include <memory>
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2017-12-10 10:35:46 +01:00
|
|
|
|
class PgDatabaseCatalog;
|
2017-02-04 11:55:49 +01:00
|
|
|
|
class TypeSelectionItemModel;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2017-02-01 20:00:03 +01:00
|
|
|
|
/** Instances of this class represent a single database on which atleast one
|
|
|
|
|
|
* window is opened. This class is used to track details about that database.
|
|
|
|
|
|
*/
|
2017-12-25 10:31:58 +01:00
|
|
|
|
class OpenDatabase {
|
2017-02-01 18:01:02 +01:00
|
|
|
|
public:
|
2017-12-25 10:31:58 +01:00
|
|
|
|
using OpenDatabaseSPtr = std::shared_ptr<OpenDatabase>;
|
|
|
|
|
|
static Expected<OpenDatabaseSPtr> createOpenDatabase(const ConnectionConfig &cfg);
|
|
|
|
|
|
|
2017-12-25 15:33:10 +01:00
|
|
|
|
// using on_createResult_callback = std::function<void(Expected<std::shared_ptr<Pgsql::Result>>)>;
|
|
|
|
|
|
// void asyncCreateOpenDatabase(const ConnectionConfig &cfg, on_createResult_callback);
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
|
|
|
|
|
OpenDatabase(const OpenDatabase &) = delete;
|
|
|
|
|
|
OpenDatabase& operator=(const OpenDatabase &) = delete;
|
|
|
|
|
|
~OpenDatabase();
|
|
|
|
|
|
|
2018-11-25 09:05:01 +01:00
|
|
|
|
std::shared_ptr<PgDatabaseCatalog> catalog();
|
2017-02-07 21:39:45 +01:00
|
|
|
|
TypeSelectionItemModel* typeSelectionModel();
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2018-01-08 20:45:52 +01:00
|
|
|
|
const ConnectionConfig& config() const { return m_config; }
|
2017-02-01 18:01:02 +01:00
|
|
|
|
private:
|
|
|
|
|
|
ConnectionConfig m_config;
|
2018-11-25 09:05:01 +01:00
|
|
|
|
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2017-02-04 11:55:49 +01:00
|
|
|
|
TypeSelectionItemModel *m_typeSelectionModel = nullptr;
|
|
|
|
|
|
|
2017-12-25 10:31:58 +01:00
|
|
|
|
OpenDatabase(const ConnectionConfig& cfg);
|
2017-02-01 18:01:02 +01:00
|
|
|
|
bool Init();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // OPENDATABASE_H
|