Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::SharedLibrary Class Reference

Loader for dll/so/dylib. Get functions from loaded library using findSymbol(...). More...

#include <sharedlibrary.h>

Public Member Functions

 SharedLibrary (const std::filesystem::path &filePath)
 
 SharedLibrary (const SharedLibrary &rhs)=delete
 
SharedLibraryoperator= (const SharedLibrary &that)=delete
 
 SharedLibrary (SharedLibrary &&rhs) noexcept
 
SharedLibraryoperator= (SharedLibrary &&that) noexcept
 
const std::filesystem::path & getFilePath ()
 
void * findSymbol (const std::string &name)
 Get function address from library.
 
template<typename T >
findSymbolTyped (const std::string &name)
 Get typed function address from library.
 
void release ()
 

Static Public Member Functions

static std::set< std::filesystem::path > libraryFileExtensions ()
 

Detailed Description

Loader for dll/so/dylib. Get functions from loaded library using findSymbol(...).

Loads specified dll/so/dylib on construction and unloads it on destruction. Throws an inviwo::Exception if library failed to load.

Member Function Documentation

◆ findSymbol()

void * inviwo::SharedLibrary::findSymbol ( const std::string & name)

Get function address from library.

Example usage:

using f_getModule = InviwoModuleFactoryObject* (__stdcall *)();
auto moduleFunc = reinterpret_cast<f_getModule>(sharedLib->findSymbol("createModule"));
Definition inviwomodulefactoryobject.h:49
Parameters
nameFunction name
Returns
Address to function if found, otherwise nullptr

◆ findSymbolTyped()

template<typename T >
T inviwo::SharedLibrary::findSymbolTyped ( const std::string & name)

Get typed function address from library.

Example usage:

using f_getModule = InviwoModuleFactoryObject* (__stdcall *)();
auto moduleFunc = sharedLib->findSymbolTyped<f_getModule>("createModule"));
Parameters
nameFunction name
Returns
Address to function if found, otherwise nullptr

◆ release()

void inviwo::SharedLibrary::release ( )

Reset the handle and effectively leak the lib. Needed for some dll that crashes on exit otherwise


The documentation for this class was generated from the following file: