51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "XNMonitorServer_global.h"
|
|
#include "PluginInterface.h"
|
|
#include "PluginGenerator.h"
|
|
#include "TypeDefine.h"
|
|
|
|
class XNMONITORSERVER_EXPORT PluginManager
|
|
{
|
|
public:
|
|
static PluginManager &Instance();
|
|
|
|
// 设置生成的插件信息
|
|
void SetGeneratedPluginInfo(const GenPluginInfo &pluginInfo);
|
|
|
|
// 从生成器加载插件
|
|
bool LoadPluginFromGenerator();
|
|
|
|
// 卸载当前插件
|
|
void UnloadCurrentPlugin();
|
|
|
|
// 获取监控器实例
|
|
DataMonitorBasePtr GetMonitor(const std::string &interfaceName);
|
|
|
|
// 获取所有支持的接口
|
|
std::vector<std::string> GetSupportedInterfaces();
|
|
|
|
// 检查插件是否已加载
|
|
bool IsPluginLoaded() const;
|
|
|
|
private:
|
|
PluginManager() = default;
|
|
~PluginManager();
|
|
PluginManager(const PluginManager &) = delete;
|
|
PluginManager &operator=(const PluginManager &) = delete;
|
|
|
|
// 当前加载的插件信息
|
|
void *m_pluginHandle = nullptr;
|
|
PluginInfo *m_pluginInfo = nullptr;
|
|
GetPluginInfoFunc m_getPluginInfoFunc = nullptr;
|
|
CreateMonitorFunc m_createMonitorFunc = nullptr;
|
|
DestroyMonitorFunc m_destroyMonitorFunc = nullptr;
|
|
GetSupportedInterfacesFunc m_getSupportedInterfacesFunc = nullptr;
|
|
FreeStringArrayFunc m_freeStringArrayFunc = nullptr;
|
|
|
|
// 生成的插件信息
|
|
GenPluginInfo m_generatedPluginInfo;
|
|
|
|
// 监控器实例缓存
|
|
std::unordered_map<std::string, DataMonitorBasePtr> m_monitorCache;
|
|
}; |