Wrapper class to facilitate loading and lifetime management of dynamic libraries and obtaining pointers to exported functions. More...
#include <DynamicLibraryLoader.h>
Public Member Functions | |
DynamicLibraryLoader (const std::string &library_file) | |
~DynamicLibraryLoader () | |
template<typename T > | |
T | getFunction (std::string func, bool hard_fail=true) |
Get a function/data pointer of type T to a function exported from the loaded library. More... | |
Private Attributes | |
void * | _handle |
Library handle returned by dlopen. More... | |
const std::string | _library_file |
Library file name. More... | |
Wrapper class to facilitate loading and lifetime management of dynamic libraries and obtaining pointers to exported functions.
Definition at line 24 of file DynamicLibraryLoader.h.
DynamicLibraryLoader::DynamicLibraryLoader | ( | const std::string & | library_file | ) |
Definition at line 13 of file DynamicLibraryLoader.C.
DynamicLibraryLoader::~DynamicLibraryLoader | ( | ) |
Definition at line 29 of file DynamicLibraryLoader.C.
T DynamicLibraryLoader::getFunction | ( | std::string | func, |
bool | hard_fail = true |
||
) |
Get a function/data pointer of type T to a function exported from the loaded library.
hard_fail | Set this to false to return a nullptr if a symbol was not found. |
Definition at line 47 of file DynamicLibraryLoader.h.
|
private |
Library handle returned by dlopen.
Definition at line 39 of file DynamicLibraryLoader.h.
Referenced by DynamicLibraryLoader(), getFunction(), and ~DynamicLibraryLoader().
|
private |
Library file name.
Definition at line 42 of file DynamicLibraryLoader.h.
Referenced by DynamicLibraryLoader(), and getFunction().