🛰️航天仿真算法库 SpaceAST 0.4.0
载入中...
搜索中...
未找到
ast::Library类 参考

#include <Library.hpp>

Public 成员函数

 Library ()=default
 
 Library (StringView fileName)
 
 ~Library ()
 
errc_t load (StringView fileName)
 
errc_t unload ()
 
bool isLoaded () const
 
void * resolve (const char *symbol) const
 
std::string filePath () const
 

静态 Public 成员函数

static bool IsLibrary (StringView fileName)
 
static void * Resolve (StringView fileName, const char *symbol)
 

详细描述

动态库加载类

封装动态库的加载、符号解析和卸载,提供 RAII 生命周期管理。

使用示例:

Library lib("myLib"); // 构造时加载
if (!lib.isLoaded()) {
return;
}
auto func = (MyFunc)lib.resolve("myFunction");
if (func) {
func();
}
动态库加载类
定义 Library.hpp:48

成员函数说明

◆ load()

errc_t ast::Library::load ( StringView fileName)

加载动态库,然后卸载旧库

返回
eNoError 成功,其他错误码表示失败

◆ Resolve()

void * ast::Library::Resolve ( StringView fileName,
const char * symbol )
static

加载库并解析符号

库加载后保持到进程退出

参数
fileName库文件名
symbol符号名称
返回
函数指针,失败返回 nullptr

◆ resolve()

void * ast::Library::resolve ( const char * symbol) const

解析符号地址

参数
symbol符号名称
返回
函数指针,失败返回 nullptr
注解
不会自动加载库,未加载时直接返回 nullptr

◆ unload()

errc_t ast::Library::unload ( )

卸载动态库

返回
eNoError 成功

该类的文档由以下文件生成: