mainapp.h
1.24 KB
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
#ifndef MAINAPP_H
#define MAINAPP_H
#include <iostream>
#include <sys/socket.h>
#include <stdexcept>
#include <netinet/in.h>
#include <fcntl.h>
#include <thread>
#include <vector>
#include <functional>
#include <forward_list>
#include "forward_declarations.h"
#include "utils.h"
#include "threaddata.h"
#include "client.h"
#include "mqttpacket.h"
#include "subscriptionstore.h"
#include "configfileparser.h"
class MainApp
{
static MainApp *instance;
bool started = false;
bool running = true;
std::vector<std::shared_ptr<ThreadData>> threads;
std::shared_ptr<SubscriptionStore> subscriptionStore;
std::unique_ptr<ConfigFileParser> confFileParser;
std::forward_list<std::function<void()>> taskQueue;
int taskEventFd = -1;
std::mutex eventMutex;
void loadConfig();
void reloadConfig();
static void doHelp(const char *arg);
static void showLicense();
MainApp(const std::string &configFilePath);
public:
MainApp(const MainApp &rhs) = delete;
MainApp(MainApp &&rhs) = delete;
static MainApp *getMainApp();
static void initMainApp(int argc, char *argv[]);
void start();
void quit();
bool getStarted() const {return started;}
void queueConfigReload();
};
#endif // MAINAPP_H