XNSim/XNMonitorServer/PluginGenerator.h

67 lines
1.5 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @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<InterfaceInfo> 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;
};