🛰️航天仿真算法库 SpaceAST 0.4.0
载入中...
搜索中...
未找到
Plugin

详细描述

类

class  ast::PluginInstance
 
struct  ast::InterfaceId< IFace >
 
struct  ast::PluginEntry
 
class  ast::PluginLoader
 
class  ast::PluginRegistry
 

宏定义

#define AST_PLUGIN_EXPORT   A_DECL_EXPORT
 
#define AST_PLUGIN_IID_NAME   ast_plugin_iid
 
#define AST_PLUGIN_KEYS_NAME   ast_plugin_keys
 
#define AST_PLUGIN_INSTANCE_NAME   ast_plugin_instance
 
#define AST_PLUGIN_IID_NAMESTR   A_STRINGIZE(AST_PLUGIN_IID_NAME)
 
#define AST_PLUGIN_KEYS_NAMESTR   A_STRINGIZE(AST_PLUGIN_KEYS_NAME)
 
#define AST_PLUGIN_INSTANCE_NAMESTR   A_STRINGIZE(AST_PLUGIN_INSTANCE_NAME)
 
#define AST_PLUGIN_INSTANCE(Type)
 
#define AST_PLUGIN_IID(IFace)
 
#define AST_PLUGIN_KEYS(...)
 
#define AST_DECLARE_INTERFACE(IFace, IID)
 

类型定义

typedef PluginInstance *(* ast::FPluginInstance) ()
 

函数

template<class IFace >
constexpr const char * ast::aInterfaceId ()
 
template<class IFace >
IFace * ast::aPluginCast (PluginInstance *instance)
 
A_ALWAYS_INLINE PluginRegistry & ast::aPluginRegistry ()
 
errc_t ast::aScanPlugins ()
 

宏定义说明

◆ AST_DECLARE_INTERFACE

#define AST_DECLARE_INTERFACE ( IFace,
IID )
值:
template<> struct InterfaceId<IFace> { \
static constexpr const char* value() { return IID; } \
};

声明一个插件接口及其唯一 ID

参数
IFace接口类型
IID接口唯一标识字符串,插件元数据里的 "iid" 必须与此一致

◆ AST_PLUGIN_IID

#define AST_PLUGIN_IID ( IFace)
值:
extern "C" { AST_PLUGIN_EXPORT const char* AST_PLUGIN_IID_NAME = aInterfaceId<IFace>(); }
#define AST_PLUGIN_EXPORT
插件库导出符号声明
定义 PluginInterface.hpp:36

◆ AST_PLUGIN_INSTANCE

#define AST_PLUGIN_INSTANCE ( Type)
值:
extern "C" AST_PLUGIN_EXPORT PluginInstance* AST_PLUGIN_INSTANCE_NAME(){static Type instance; return &instance;}

◆ AST_PLUGIN_KEYS

#define AST_PLUGIN_KEYS ( ...)
值:
extern "C" { AST_PLUGIN_EXPORT const char* AST_PLUGIN_KEYS_NAME[] = {__VA_ARGS__, nullptr}; }

函数说明

◆ aPluginCast()

template<class IFace >
IFace * ast::aPluginCast ( PluginInstance * instance)

把插件根对象转换为指定接口类型

依赖 C++ RTTI,转换失败返回 nullptr。

◆ aScanPlugins()

AST_UTIL_API errc_t ast::aScanPlugins ( )

扫描可用插件并建立索引

探测顺序:<可执行文件目录>/plugins、<库目录>/plugins; 两处都不存在时回退到库目录,按产物的命名习惯筛选插件: MSVC 产物没有 lib 前缀,只匹配 "AstPlugin" GCC / Clang / MinGW 的共享库可能带 lib 前缀,同时接受 "AstPlugin" 与 "libAstPlugin"

返回
错误码
注解
重复调用是幂等的。