MCPcopy Create free account
hub / github.com/AimRT/AimRT / LoadPlugin

Method LoadPlugin

src/runtime/core/plugin/plugin_loader.cc:14–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12static constexpr const char* kDynlibDestroyCorePluginFuncName = "AimRTDynlibDestroyCorePluginHandle";
13
14void PluginLoader::LoadPlugin(std::string_view plugin_path) {
15 plugin_path_ = plugin_path;
16
17 AIMRT_CHECK_ERROR_THROW(dynamic_lib_.Load(plugin_path_),
18 "Load dynamic lib failed, lib path {}, error info {}",
19 plugin_path_, aimrt::common::util::DynamicLib::GetErr());
20
21 auto* create_func = dynamic_lib_.GetSymbol(kDynlibCreateCorePluginFuncName);
22 AIMRT_CHECK_ERROR_THROW(create_func != nullptr,
23 "Cannot find symbol '{}' in lib {}.",
24 kDynlibCreateCorePluginFuncName, plugin_path_);
25
26 destroy_func_ = dynamic_lib_.GetSymbol(kDynlibDestroyCorePluginFuncName);
27 AIMRT_CHECK_ERROR_THROW(destroy_func_ != nullptr,
28 "Cannot find symbol '{}' in lib {}.",
29 kDynlibDestroyCorePluginFuncName, plugin_path_);
30
31 // Loading plugin
32 plugin_ptr_ = ((DynlibCreateCorePluginFunc)create_func)();
33
34 AIMRT_CHECK_ERROR_THROW(plugin_ptr_ != nullptr,
35 "Cannot create plugin in lib {}.", plugin_path_);
36}
37
38void PluginLoader::UnLoadPlugin() {
39 if (!dynamic_lib_.IsLoaded()) return;

Callers 1

InitializeMethod · 0.80

Calls 2

GetSymbolMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected