A base class for making a class into a dynamic loadable plugin.
More...
#include <AsyncPlugin.h>
|
| Plugin (void) |
| Default constructor.
|
|
| Plugin (const Plugin &)=delete |
| Disallow copy construction.
|
|
Plugin & | operator= (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 Plugin * | load (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) |
|
A base class for making a class into a dynamic loadable plugin.
- Author
- Tobias Blomberg / SM0SVX
- Date
- 2022-08-23
#include <iostream>
#include "DemoPluginBase.h"
int main(void)
{
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 115 of file AsyncPlugin.h.
◆ Plugin() [1/2]
Async::Plugin::Plugin |
( |
void | | ) |
|
◆ Plugin() [2/2]
Async::Plugin::Plugin |
( |
const Plugin & | | ) |
|
|
delete |
Disallow copy construction.
◆ ~Plugin()
virtual Async::Plugin::~Plugin |
( |
void | | ) |
|
|
protectedvirtual |
◆ load() [1/2]
static Plugin * Async::Plugin::load |
( |
const std::string & | path | ) |
|
|
static |
◆ 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
-
The application 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 132 of file AsyncPlugin.h.
References load().
◆ operator=()
Disallow copy assignment.
◆ 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 171 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 180 of file AsyncPlugin.h.
◆ unload()
static void Async::Plugin::unload |
( |
Plugin * | p | ) |
|
|
static |
The documentation for this class was generated from the following file: