54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
|
||
#pragma once
|
||
|
||
#include <TestProject/DCR/fp.h>
|
||
#include <TestProject/DCR/ihdb_header.h>
|
||
#include <stdint.h>
|
||
#include <atomic>
|
||
#include <future>
|
||
#include <mutex>
|
||
#include <numeric>
|
||
#include <string>
|
||
#include <thread>
|
||
#include <vector>
|
||
namespace DCR {
|
||
|
||
namespace ihd {
|
||
/**
|
||
* @brief IhyperDB的连接
|
||
*/
|
||
struct Connection {
|
||
// 由于iHyperDB的设计独特,一个进程只使用一个iHyperDB连接
|
||
// 且ihyperDB的连接一经建立,即使断开网络连接,也不会自动释放,故不再对其使用手动释放
|
||
struct Config {
|
||
// 基本信息
|
||
std::string username;
|
||
std::string password;
|
||
HD3Connection hd3_conn;
|
||
};
|
||
enum class State { disconnected, connected };
|
||
Config config;
|
||
State state;
|
||
std::thread::id tid;
|
||
};
|
||
|
||
auto read_conn_config_maybe() -> maybe<Connection::Config>;
|
||
|
||
auto init_conn_maybe(maybe<Connection::Config>&& conn_config_maybe)
|
||
-> maybe<Connection>;
|
||
|
||
auto disconnect_maybe(maybe<Connection> conn_maybe) -> maybe<Connection>;
|
||
|
||
auto connect_maybe(maybe<Connection> conn_maybe) -> maybe<Connection>;
|
||
|
||
auto read_conn_state() -> Connection::State;
|
||
|
||
auto read_conn() -> Connection;
|
||
|
||
auto store_conn_to_local(Connection& conn) -> Connection;
|
||
|
||
auto auto_connect() -> maybe<Connection>; ///<对外实际使用
|
||
|
||
} // namespace ihd
|
||
} // namespace DCR
|