SOFA API  1a4bb3e7
Open source framework for multi-physics simuation
sofa::helper::system::DynamicLibrary Class Reference

#include <DynamicLibrary.h>

Wrapper around the dynamic library facilities of the operating system. More...

Detailed Description

Wrapper around the dynamic library facilities of the operating system.

Classes

class  Handle
 A handle to a dynamic library. More...
 

Static Public Attributes

static const std::string extension = "so"
 System-specific file extension for a dynamic library (e.g. "so"). More...
 
static const std::string prefix = "lib"
 System-specific file prefix for a dynamic library (e.g. "lib"). More...
 

Static Public Member Functions

static Handle load (const std::string &filename)
 Load a dynamic library. More...
 
static int unload (Handle handle)
 Unload a dynamic library loaded with load(). More...
 
static void * getSymbolAddress (Handle handle, const std::string &symbol)
 Get the address of a symbol. More...
 
static std::string getLastError ()
 Get the message for the most recent error that occurred from load(), unload() or getSymbolAddress(). More...
 

Attribute details

◆ extension

const std::string sofa::helper::system::DynamicLibrary::extension = "so"
static

System-specific file extension for a dynamic library (e.g. "so").

◆ prefix

const std::string sofa::helper::system::DynamicLibrary::prefix = "lib"
static

System-specific file prefix for a dynamic library (e.g. "lib").

Function details

◆ getLastError()

std::string sofa::helper::system::DynamicLibrary::getLastError ( )
static

Get the message for the most recent error that occurred from load(), unload() or getSymbolAddress().

Returns
The error message, or an empty string if no errors have occurred since initialization or since it was last called.

◆ getSymbolAddress()

void * sofa::helper::system::DynamicLibrary::getSymbolAddress ( Handle  handle,
const std::string &  symbol 
)
static

Get the address of a symbol.

Parameters
handleThe handle of a library.
symbolThe symbol to look for.
Returns
A pointer to the symbol if it was found, or nullptr on error.

◆ load()

DynamicLibrary::Handle sofa::helper::system::DynamicLibrary::load ( const std::string &  filename)
static

Load a dynamic library.

Parameters
filenameThe library to load.
Returns
A handle, that must be unloaded with unload(). Use Handle::isValid() to know if the loading was successful.

◆ unload()

int sofa::helper::system::DynamicLibrary::unload ( Handle  handle)
static

Unload a dynamic library loaded with load().

Parameters
handleThe handle of a library.
Returns
0 on success, and nonzero on error.