/** * @file PluginGenerator.h * @brief 简化的插件生成器 - 从数据库生成插件cpp文件和CMakeLists */ #pragma once #include "TypeDefine.h" // 接口信息结构 struct InterfaceInfo { std::string interfaceName; // 接口名称(如:Aerodynamics_heartbeat) std::string templateType; // 模板类型(如:XNSim::C909::ATA04::Aerodynamics_heartbeat_Interface) }; // 插件信息 struct GenPluginInfo { std::string pluginName; // 插件名称(如:C909_V1) std::string pluginDescription; // 插件描述 std::string interfaceHeaderPath; // 接口头文件路径(如:IDL/C909_V1_Interface.h) std::vector interfaces; // 接口列表 std::string outputDirectory; // 输出目录 }; class PluginGenerator { public: PluginGenerator(); ~PluginGenerator(); // 从数据库加载插件信息 bool loadPluginFromDatabase(const int confID); // 生成插件cpp文件 bool generatePluginCpp(); // 生成CMakeLists.txt bool generateCMakeLists(); // 编译插件 bool compilePlugin(); // 获取错误信息 std::string getLastError() const; // 获取插件信息 const GenPluginInfo &getPluginInfo() const; private: // 生成插件cpp文件内容 std::string generatePluginCppContent(); // 生成CMakeLists.txt内容 std::string generateCMakeListsContent(); // 写入文件 bool writeFile(const std::string &filePath, const std::string &content); // 创建目录 bool createDirectory(const std::string &dirPath); private: std::string m_lastError; GenPluginInfo m_pluginInfo; };