|
The DynamicLibrary class provides a mechanism to load libraries at runtime. More...
#include <ArmarXCore/core/system/DynamicLibrary.h>
Public Member Functions | |
DynamicLibrary () | |
std::string | getErrorMessage () noexcept |
std::filesystem::path | getLibraryFilename () noexcept |
template<class SymbolType > | |
SymbolType | getSymbol (const std::string &functionName) |
Retrieves a symbol (mostly a function) from the loaded library. More... | |
bool | isLibraryLoaded () noexcept |
Checks if a library is currently loaded. More... | |
void | load (std::filesystem::path libPath) |
Loads a shared library from the specified path. More... | |
void | reload () |
Reloads the current library. More... | |
void | setFlags (int newFlags) |
Sets the shared library opening flags and reloads the library, if a library is already loaded. More... | |
void | setUnloadOnDestruct (bool unload) |
void | unload () |
Unloads library. More... | |
~DynamicLibrary () override | |
Public Member Functions inherited from Logging | |
SpamFilterDataPtr | deactivateSpam (float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const |
disables the logging for the current line for the given amount of seconds. More... | |
MessageTypeT | getEffectiveLoggingLevel () const |
Logging () | |
void | setLocalMinimumLoggingLevel (MessageTypeT level) |
With setLocalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set. More... | |
void | setTag (const LogTag &tag) |
void | setTag (const std::string &tagName) |
virtual | ~Logging () |
Static Public Member Functions | |
static std::string | GetSharedLibraryFileExtension () |
Additional Inherited Members | |
Protected Member Functions inherited from Logging | |
bool | checkLogLevel (MessageTypeT level) const |
const LogSenderPtr & | getLogSender () const |
Retrieve log sender. More... | |
LogSenderPtr | loghelper (const char *file, int line, const char *function) const |
Protected Attributes inherited from Logging | |
MessageTypeT | minimumLoggingLevel |
SpamFilterDataPtr | spamFilter |
LogTag | tag |
The DynamicLibrary class provides a mechanism to load libraries at runtime.
A quick usage example looks as follows:
Definition at line 49 of file DynamicLibrary.h.
DynamicLibrary | ( | ) |
Definition at line 29 of file DynamicLibrary.cpp.
|
override |
|
noexcept |
Definition at line 174 of file DynamicLibrary.cpp.
|
noexcept |
Definition at line 168 of file DynamicLibrary.cpp.
|
static |
SymbolType getSymbol | ( | const std::string & | functionName | ) |
Retrieves a symbol (mostly a function) from the loaded library.
The requested function needs to be exported with "extern "C"".
SymbolType | type of the requested symbol |
functionName | name of the requested function |
exceptions::local::DynamicLibraryException |
Definition at line 133 of file DynamicLibrary.h.
|
noexcept |
Checks if a library is currently loaded.
Definition at line 137 of file DynamicLibrary.cpp.
void load | ( | std::filesystem::path | libPath | ) |
Loads a shared library from the specified path.
Throws exceptions::local::DynamicLibraryException on error.
libPath | Path to the library. Can be relative to ArmarXDataPath's paths. |
exceptions::local::DynamicLibraryException |
Definition at line 54 of file DynamicLibrary.cpp.
void reload | ( | ) |
Reloads the current library.
Useful, if the library has changed since last loading.
exceptions::local::DynamicLibraryException |
Definition at line 131 of file DynamicLibrary.cpp.
void setFlags | ( | int | newFlags | ) |
Sets the shared library opening flags and reloads the library, if a library is already loaded.
newFlags | flags of ::dlopen() |
exceptions::local::DynamicLibraryException |
Definition at line 147 of file DynamicLibrary.cpp.
void setUnloadOnDestruct | ( | bool | unload | ) |
void unload | ( | ) |
Unloads library.
User has to make sure that all references to the symbols in this library are deleted!
exceptions::local::DynamicLibraryException |
Definition at line 104 of file DynamicLibrary.cpp.