DynamicLibrary
-
class DynamicLibrary
Dynamically loadable library.
This provides capabilities to load a shared library (also known as dynamic library) and obtain C-functions that can be then called.
Public Functions
-
explicit DynamicLibrary(String lib_name)
Construct a dynamic library instance.
- Parameters:
lib_name – Library name (the part after
libon Unix-based systems, without the file extension). For example, if your library is namedlibExt.so, you would provideExthere.
-
void load()
Load the library.
-
void unload()
Unload the library.
-
template<typename SIGNATURE>
inline auto get_symbol(const char *symbol_name) Get symbol as a function delegate.
Usage:
DynamicLibrary dll(<name>); dll.load(); auto add = dll.get_symbol<double(double, double)>("add"); double res = add.invoke(10, 20);
- Template Parameters:
SIGNATURE – function signature
- Parameters:
symbol_name – symbol in the library
- Returns:
Delegatethat can call the function
Public Static Functions
-
static void add_search_path(const std::filesystem::path &new_path)
Add a new path that will be searched for extensions to load.
- Parameters:
new_path – New path to search for extensions
-
static void clear_search_paths()
Remove all search paths.
-
static const std::vector<std::filesystem::path> &get_search_paths()
Get search path.
-
template<typename SIGNATURE>
class Delegate
-
explicit DynamicLibrary(String lib_name)