Inviwo  0.9.10.1
Inviwo documentation
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::string &filePath)
 
 SharedLibrary (const SharedLibrary &rhs)=delete
 
SharedLibraryoperator= (const SharedLibrary &that)=delete
 
 SharedLibrary (SharedLibrary &&rhs)
 
SharedLibraryoperator= (SharedLibrary &&that)
 
std::string getFilePath ()
 
void * findSymbol (const std::string &name)
 Get function address from library. More...
 
template<typename T >
findSymbolTyped (const std::string &name)
 Get typed function address from library. More...
 
void release ()
 

Static Public Member Functions

static std::set< std::string > 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"));
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 files: