forked from halfgaar/FlashMQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bridgeinfodb.h
43 lines (30 loc) · 965 Bytes
/
bridgeinfodb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef BRIDGEINFODB_H
#define BRIDGEINFODB_H
#include <list>
#include "persistencefile.h"
#include "bridgeconfig.h"
#define MAGIC_STRING_BRIDGEINFO_FILE_V1 "BridgeInfoDbV1"
struct BridgeInfoForSerializing
{
std::string prefix;
std::string clientId;
BridgeInfoForSerializing() = default;
BridgeInfoForSerializing(const std::shared_ptr<BridgeConfig> bridge);
static std::list<BridgeInfoForSerializing> getBridgeInfosForSerializing(const std::unordered_map<std::string, std::shared_ptr<BridgeConfig>> &input);
};
class BridgeInfoDb : private PersistenceFile
{
enum class ReadVersion
{
unknown,
v1,
};
ReadVersion readVersion = ReadVersion::unknown;
public:
BridgeInfoDb(const std::string &filePath);
void openWrite();
void openRead();
void saveInfo(const std::list<BridgeInfoForSerializing> &bridgeInfos);
std::list<BridgeInfoForSerializing> readInfo();
};
#endif // BRIDGEINFODB_H