deviceAccessLayer/src/application.h

76 lines
1.6 KiB
C++

#ifndef APPLICATION_H
#define APPLICATION_H
#include "http/http_svr.h"
#include "mqtt/mqtt_cli.h"
#include "report_svr/report_svr.h"
#include "oss/oss.h"
#include "device_holder.h"
#include "controller/test.h"
#include "mqtt/mqtt_svr.h"
namespace zsy
{
struct AppProperties
{
bool daemon{false};
uint32_t delay{0};
std::string name;
bool embedMqtt{false};
};
inline void from_json(const nlohmann::json &j, AppProperties &o)
{
PARSE_JSON(daemon, o.daemon);
PARSE_JSON(delay, o.delay);
PARSE_JSON(name, o.name);
PARSE_JSON(embedMqtt, o.embedMqtt);
}
class Application
{
const std::string configFile;
std::string pidFilePath;
std::string pid;
static HANDLE STOP_EVENT;
nlohmann::json config;
void loadConfig();
void removePid();
void writePid();
public:
// static std::shared_ptr<ThreadPool> threadPool;
static std::shared_ptr<EventManager> eventManager;
static std::shared_ptr<HttpSvr> httpSvr;
static std::shared_ptr<OSS> oss;
static std::shared_ptr<MqttSvr> mqttSvr;
static std::shared_ptr<MqttCliHolder> mqttCliHolder;
static std::shared_ptr<ReportSvr> reportSvr;
static std::shared_ptr<DeviceHolder> deviceHolder;
static std::shared_ptr<Test> test;
Application(const std::string &configFile);
static void run();
static void run(const std::string &configFile);
static void stop();
~Application();
};
} // zsy
#endif //APPLICATION_H