#pragma once #include "crow.h" #include "crow/middlewares/cors.h" #include "alarm/alarm_service.h" #include "dataCache/live_data_cache.h" #include "deviceManager/device_manager.h" #include "systemMonitor/system_monitor.h" #include "nlohmann/json.hpp" #include #include class WebServer : public crow::Crow { public: WebServer(SystemMonitor::SystemMonitor &monitor, DeviceManager &deviceManager, LiveDataCache &liveDataCache, AlarmService &alarm_service, uint16_t port = 8080); ~WebServer(); WebServer(const WebServer &) = delete; WebServer &operator=(const WebServer &) = delete; void start(); void stop(); void set_shutdown_handler(std::function handler); private: void setup_routes(); bool validate_video_config(const std::string &json_string, std::string &error_message); bool validate_main_config(const std::string &json_string, std::string &error_message); SystemMonitor::SystemMonitor &m_monitor; DeviceManager &m_device_manager; LiveDataCache &m_live_data_cache; AlarmService &m_alarm_service; uint16_t m_port; std::thread m_thread; std::function m_shutdown_handler; };