MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / loadPlugin

Method loadPlugin

Source/Falcor/Core/Plugin.cpp:56–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56bool PluginManager::loadPlugin(const std::filesystem::path& path)
57{
58 // Early exit if plugin is already loaded.
59 {
60 std::lock_guard<std::mutex> lock(mLibrariesMutex);
61 if (mLibraries.find(path) != mLibraries.end())
62 return false;
63 }
64
65 if (!std::filesystem::exists(path))
66 FALCOR_THROW("Failed to load plugin library from {}. File not found.", path);
67
68 SharedLibraryHandle library = loadSharedLibrary(path);
69 if (library == nullptr)
70 FALCOR_THROW("Failed to load plugin library from {}. Cannot load shared library.", path);
71
72 using RegisterPluginProc = void (*)(PluginRegistry&);
73
74 auto registerPluginProc = (RegisterPluginProc)getProcAddress(library, "registerPlugin");
75 if (registerPluginProc == nullptr)
76 FALCOR_THROW("Failed to load plugin library from {}. Symbol 'registerPlugin' not found.", path);
77
78 // Register plugin library.
79 {
80 std::lock_guard<std::mutex> lock(mLibrariesMutex);
81 mLibraries[path] = library;
82 }
83
84 // Call plugin library to register plugin classes.
85 {
86 PluginRegistry registry(*this, library);
87 registerPluginProc(registry);
88 }
89
90 return true;
91}
92
93bool PluginManager::releasePlugin(const std::filesystem::path& path)
94{

Callers

nothing calls this directly

Calls 3

loadSharedLibraryFunction · 0.50
getProcAddressFunction · 0.50
endMethod · 0.45

Tested by

no test coverage detected