Async 1.7.0
Async::Plugin Class Reference

A base class for making a class into a dynamic loadable plugin. More...

#include <AsyncPlugin.h>

Inheritance diagram for Async::Plugin:
Async::PluginBase

Public Member Functions

 Plugin (void)
 Default constructor.
 
 Plugin (const Plugin &)=delete
 Disallow copy construction.
 
Pluginoperator= (const Plugin &)=delete
 Disallow copy assignment.
 
void * pluginHandle (void) const
 Retrieve the handle returned from the dlopen function.
 
const std::string & pluginPath (void) const
 Retrieve the path used to find the plugin.
 

Static Public Member Functions

static Pluginload (const std::string &path)
 Load the plugin from the specified path.
 
template<class T>
static T * load (const std::string &path)
 Load the plugin from the specified path returning correct type.
 
static void unload (Plugin *p)
 

Protected Member Functions

virtual ~Plugin (void)
 Destructor.
 

Detailed Description

A base class for making a class into a dynamic loadable plugin.

Author
Tobias Blomberg / SM0SVX
Date
2022-08-23

A_detailed_class_description

#include <iostream>
#include "DemoPluginBase.h"
int main(void)
{
auto p = Async::Plugin::load<DemoPluginBase>("DemoPlugin.so");
if (p == nullptr)
{
exit(1);
}
std::cout << "Found plugin " << p->pluginPath() << std::endl;
p->initialize("hello");
p = nullptr;
return 0;
}
static void unload(Plugin *p)
static Plugin * load(const std::string &path)
Load the plugin from the specified path.

Definition at line 121 of file AsyncPlugin.h.

Constructor & Destructor Documentation

◆ Plugin() [1/2]

Async::Plugin::Plugin ( void )

Default constructor.

Referenced by load(), operator=(), Plugin(), unload(), and ~Plugin().

◆ Plugin() [2/2]

Async::Plugin::Plugin ( const Plugin & )
delete

Disallow copy construction.

References Plugin().

◆ ~Plugin()

virtual Async::Plugin::~Plugin ( void )
protectedvirtual

Destructor.

References Plugin().

Member Function Documentation

◆ load() [1/2]

static Plugin * Async::Plugin::load ( const std::string & path)
static

Load the plugin from the specified path.

Parameters
pathThe file path
Examples
AsyncPlugin_demo.cpp.

References Plugin().

Referenced by load().

◆ load() [2/2]

template<class T>
static T * Async::Plugin::load ( const std::string & path)
inlinestatic

Load the plugin from the specified path returning correct type.

Parameters
pathThe file path

The plugin may use this function to load the plugin, check that it is of the correct type and then return a pointer to that type.

Definition at line 138 of file AsyncPlugin.h.

References load(), and Plugin().

◆ operator=()

Plugin & Async::Plugin::operator= ( const Plugin & )
delete

Disallow copy assignment.

References Plugin().

◆ pluginHandle()

void * Async::Plugin::pluginHandle ( void ) const
inline

Retrieve the handle returned from the dlopen function.

Returns
Returns a handle from dlopen (
See also
man 3 dlopen)

Definition at line 177 of file AsyncPlugin.h.

◆ pluginPath()

const std::string & Async::Plugin::pluginPath ( void ) const
inline

Retrieve the path used to find the plugin.

Returns
Returns the path to the plugin

This function can be called to find out which path was used to load the plugin.

Definition at line 186 of file AsyncPlugin.h.

◆ unload()

static void Async::Plugin::unload ( Plugin * p)
static
Examples
AsyncPlugin_demo.cpp.

References Plugin().


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