#pragma once #include "stdafx.h" #include #include "tinyxml2.h" #include #include 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); };