logplus/Workflow/WFEngine/Module/include/ModuleManager.h

155 lines
4.5 KiB
C
Raw Normal View History

2026-01-16 17:18:41 +08:00
/**
* @file ModuleManager.h
* @brief
* @author dev
* @date 2011-8-29
*/
#ifndef PAI_FRAME_MODULEAPI_MODULEMANAGER_H
#define PAI_FRAME_MODULEAPI_MODULEMANAGER_H
#include "ModuleMetaData.h"
#include <string>
#include <vector>
#include <map>
#include "Turtle.h"
namespace Json {
class Value;
}
namespace pai {
namespace module {
class CModuleParameter;
class CCompositeParameterItem;
class CModule;
/**
* @class CModuleManager
* @brief
*/
class PAI_MODULE_EXPORT CModuleManager
{
public:
/**
* @brief
*/
CModuleManager();
/**
* @brief
*/
virtual ~CModuleManager();
/**
* @brief
* @param[in] strModuleClassName
* @return <code>CModule</code>
*/
CModule* CreateModuleByClassName(const std::string& strModuleClassName);
/**
* @brief GUI调用
* @param[out] vecModules
*/
void ListAllModules(std::vector<CModule*>& vecModules) const;
/**
* @brief ID的模块句柄
* @param[in] id ID
* @return ID模块句柄NULL
*/
CModule* FindModule(const std::string& id) const;
/**
* @deprecated @see #FindModule(const std::string&)
* @brief ID的模块元数据
* @param[in] id IDCModuleMetaData
* @return ID模块元数据NULL
*/
CModuleMetaData* FindModuleMetaData(const std::string& id) const;
/**
* @brief
* @param[in] strCategory
* @param[out] vecModules strCategory对应参数所指定类型的模块
*/
void GetModulesByCategory(const std::string& strCategory, std::vector<CModule*>& vecModules);
/**
* @brief
* @param[out] vecCategoryNames
*/
void GetCategoryNames(std::vector<std::string>& vecCategoryNames);
/**
* @brief
* @return
*/
std::string GetLibDeployPath() const;
/**
* @brief
*/
void LoadAllModules();
/**
* @brief
*/
void ReLoadAllModules();
//some special module should be added in WellLog
//only use by WellLog
void AddModule(std::string modulefileFullPathName,CModule* aModule,void* modulehandle);
private:
/**
* @brief PAI_HOME/module目录下读取.json文件获取元数据信息到内存
* @param[in] moduleDir json文件所在目录
*
*/
void Initialize(std::string moduleDir);
/**
* @brief parse module metadata json data
* @param[in] metaDataFilePath: module json file path
* @param[out] root: the parsed json data
* @return return ture if the file is parsed success, if not return false
*/
bool ParseMetaData(const std::string metaDataFilePath,Json::Value& root);
/**
* @brief load module by the module class name
* @param[in] moduleClassName: the name of the module to be loaded
* @return return true if load the module success ,if not return false
*/
bool LoadModuleByClassName(const std::string moduleClassName);
/**
* @brief load module and add the module json value to the module
* @param[in] root:the parsed module json data
* @return return true if load the module success ,if not return false
*/
// bool LoadModule(const Json::Value& root);
/**
* @brief Json节点的模块参数信息
* @param[in] paramJsonNode Json节点
* @param[in] pParentItem
*/
void _ParseParameterInfo(const Json::Value& paramJsonNode, CCompositeParameterItem* pParentItem);
/**
* @brief
* @param[in] strModuleClassName:the name of the module to be created
* @return return the module that was created
*/
CModule* CreateModuleByClassNameInternal(const std::string& strModuleClassName);
private:
std::map<std::string,CModule*> m_moduleContainer;//模块的容器
std::map<std::string,std::string> m_modulePaths;
std::vector<void*> m_moduleHandles;
bool m_isLoadAllModules; //是否已加载所有模块
};
/**
* @brief
*/
extern PAI_MODULE_EXPORT CModuleManager* GetModuleManager();
}
}
#endif