LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
plugin::FunctionRegistry< FnType > Class Template Reference

Type-safe wrapper for dynamically loaded functions. More...

#include <PluginFunctionRegistry.hpp>

Collaboration diagram for plugin::FunctionRegistry< FnType >:
Collaboration graph

Public Member Functions

 FunctionRegistry (void *handle, const std::string &symbolName)
 Constructs registry and attempts to resolve symbol.
 
 operator bool () const
 Checks if symbol was successfully resolved.
 
FnType get () const
 Gets raw function pointer.
 
template<typename... Args>
requires std::invocable<FnType, Args...>
auto call (Args &&... args) const
 Calls the resolved function with type checking via concepts.
 

Private Member Functions

FnType ResolveSymbol () const
 Resolves symbol from dynamic library.
 

Private Attributes

void * m_handle
 
std::string m_symbolName
 
FnType m_function
 

Detailed Description

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
FnTypeFunction pointer type (e.g., void(*)(int, const char*))
Usage Example
using CreatePanelFn = void*(*)(void*, void*, const char*);
if (creator) { // operator bool checks if symbol was found
auto* widget = creator.call(handle, parent, settings);
}
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

Constructor & Destructor Documentation

◆ FunctionRegistry()

template<typename FnType >
plugin::FunctionRegistry< FnType >::FunctionRegistry ( void *  handle,
const std::string &  symbolName 
)
inline

Constructs registry and attempts to resolve symbol.

Parameters
handleDynamic library handle from dlopen/LoadLibrary
symbolNameC-string name of the symbol to resolve
Here is the call graph for this function:

Member Function Documentation

◆ call()

template<typename FnType >
template<typename... Args>
requires std::invocable<FnType, Args...>
auto plugin::FunctionRegistry< FnType >::call ( Args &&...  args) const
inline

Calls the resolved function with type checking via concepts.

Template Parameters
ArgsArgument types (deduced)
Parameters
argsArguments to pass to function
Returns
Function return value
Exceptions
std::runtime_errorif function not resolved
std::exceptionfrom invoked function
Example
if (auto creator = registry) {
auto result = creator.call(arg1, arg2, arg3);
}
Here is the call graph for this function:

◆ get()

template<typename FnType >
FnType plugin::FunctionRegistry< FnType >::get ( ) const
inline

Gets raw function pointer.

Returns
Raw function pointer or nullptr
Here is the caller graph for this function:

◆ operator bool()

template<typename FnType >
plugin::FunctionRegistry< FnType >::operator bool ( ) const
inlineexplicit

Checks if symbol was successfully resolved.

Returns
true if function symbol is available, false otherwise

◆ ResolveSymbol()

template<typename FnType >
FnType plugin::FunctionRegistry< FnType >::ResolveSymbol ( ) const
inlineprivate

Resolves symbol from dynamic library.

Returns
Function pointer if found, nullptr otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_function

template<typename FnType >
FnType plugin::FunctionRegistry< FnType >::m_function
private

◆ m_handle

template<typename FnType >
void* plugin::FunctionRegistry< FnType >::m_handle
private

◆ m_symbolName

template<typename FnType >
std::string plugin::FunctionRegistry< FnType >::m_symbolName
private

The documentation for this class was generated from the following file: