#pragma once #include "stdafx.h" #include <iostream> #include "tinyxml2.h" #include <string> #include <ctime> using namespace std; using namespace tinyxml2; enum class StartupMode { ColdStart, HotStart }; class NetworkConfig { private: tinyxml2::XMLDocument doc; // ÓÃÓÚ´æ´¢ XML ÎĵµµÄ¶ÔÃó bool loaded; // 񈬀 XML ÎļþÊÇ·ñ³É¹¦¼ÓÔØ static bool startupModeSelected; public: NetworkConfig(const string& xmlFilePath); ~NetworkConfig(); bool isLoaded() const;// ¼ì²é XML ÎļþÊÇ·ñ³É¹¦¼ÓÔØ bool getTCPConfig(string& ipAddress, int& portNumber);//»ñÈ¡TCPÅäÖÃÃÅ⣬·µ»ØIPµØÖ·ºÃ¶Ë¿ÚºÅ bool getRTSPConfig(string& ipAddress, int& portNumber);//»ñÈ¡RTSPÅäÖÃÃÅ⣬·µ»ØIPµØÖ·ºÃ¶Ë¿ÚºÅ bool getLogConfig(string& path, int& size);// »ñÈ¡ ÈÕÖ¾ ÅäÖÃÃÅâ bool getMySQLConfig(string& ip, int& port, string& db, string& user, string& password);// »ñÈ¡ MySQL ÅäÖÃÃÅâ bool getPictureManagementRootPath(string& rootPath);// »ñÈ¡ üƬ¹ÜÀà ¸ù·¾¶ // ÌüӻñȡԤ´¦ÀÃÉú³ÉüƬµÄ¸ù·¾¶µÄ³ÉÔ±º¯Êý bool getPreprocessedPictureRootPath(std::string & rootPath); bool getVideoManagementRootPath(string& rootPath);// »ñÈ¡ ÊÓÆµ¹ÜÀà ¸ù·¾¶ bool getCNNModelSavePath(string& path);// »ñÈ¡ CNN Ä£Ãñ£´æÂ·¾¶ bool getVersionManagementRootPath(string& rootPath); // »ñÈ¡ °æ±¾¹ÜÀà ¸ù·¾¶ bool getStartupMode(string& mode);// »ñÈ¡ Æô¶¯Ä£Ê½ bool setStartupMode(const string& mode);// ÉèÖà Æô¶¯Ä£Ê½ bool saveXML(const string& xmlFilePath);// ±£´æÃ޸ĺóµÄ XML Îļþµ½Ö¸¶¨Â·¾¶ void coldStart(); void hotStart(NetworkConfig& oldParser); bool isConfigUpdated(const string& xmlFilePath, time_t& lastModifiedTime);// ¼ì²éÅäÖÃÎļþÊÇ·ñÓøüàvoid restartServices(StartupMode currentMode, const string& xmlFilePath, time_t& lastModifiedTime); bool setTCPConfig(const std::string& ipAddress, int portNumber); };