-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.hpp
66 lines (55 loc) · 1.84 KB
/
Config.hpp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (C) 2024 Mikhail Sapozhnikov
*
* This file is part of ship-position.
*
* ship-position is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ship-position is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ship-position. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef CONFIG_HPP
#define CONFIG_HPP
#include "BN880GPSConfig.hpp"
#include "IPCConfig.hpp"
#include "Log.hpp"
#include "json.hpp"
using json = nlohmann::json;
namespace ship_position
{
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(BN880GPSConfig, bufferSize, devPath, maxRetries, rawOutput, maxRawFileSize)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IPCConfig, bufSize, socketPath)
class Config
{
public:
Config(const std::string &configFile);
void getBN880GPSConfig(BN880GPSConfig &config) const { config = _configData.bn880GPSConfig; }
void getIPCConfig(IPCConfig &config) const { config = _configData.ipcConfig;}
LogLevel getLogLevel() const;
bool isSyslogEnabled() const;
bool isConsoleLogEnabled() const;
bool isOk() const { return _ok; }
protected:
struct ConfigData
{
BN880GPSConfig bn880GPSConfig;
IPCConfig ipcConfig;
std::string logLevel;
std::vector<std::string> logBackends;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(ConfigData, bn880GPSConfig, ipcConfig, logLevel, logBackends)
};
ConfigData _configData;
Log *_log;
bool _ok;
};
}
#endif // CONFIG_HPP