Type-safe wrapper for dynamically loaded functions.
More...
#include <PluginFunctionRegistry.hpp>
template<
typename FnType>
class plugin::FunctionRegistry< FnType >
Type-safe wrapper for dynamically loaded functions.
Provides compile-time type safety for C-style function pointers loaded from dynamic libraries via dlsym/GetProcAddress.
- Template Parameters
-
| FnType | Function pointer type (e.g., void(*)(int, const char*)) |
- Usage Example
}
Type-safe wrapper for dynamically loaded functions.
Definition PluginFunctionRegistry.hpp:51
FnType get() const
Gets raw function pointer.
Definition PluginFunctionRegistry.hpp:80
- Benefits
- Compile-time function signature verification
- No manual reinterpret_cast needed
- Clear error handling
- Type-safe invocation with concepts
◆ FunctionRegistry()
Constructs registry and attempts to resolve symbol.
- Parameters
-
| handle | Dynamic library handle from dlopen/LoadLibrary |
| symbolName | C-string name of the symbol to resolve |
◆ call()
template<typename... Args>
requires std::invocable<FnType, Args...>
Calls the resolved function with type checking via concepts.
- Template Parameters
-
| Args | Argument types (deduced) |
- Parameters
-
| args | Arguments to pass to function |
- Returns
- Function return value
- Exceptions
-
| std::runtime_error | if function not resolved |
| std::exception | from invoked function |
- Example
-
◆ get()
template<typename FnType >
Gets raw function pointer.
- Returns
- Raw function pointer or nullptr
◆ operator bool()
Checks if symbol was successfully resolved.
- Returns
- true if function symbol is available, false otherwise
◆ ResolveSymbol()
Resolves symbol from dynamic library.
- Returns
- Function pointer if found, nullptr otherwise
◆ m_function
◆ m_handle
◆ m_symbolName
The documentation for this class was generated from the following file: