Manage plugins.
More...
#include <plugin_service.hpp>
◆ plugin_loaders
◆ plugins
◆ plugin_service()
irccd::daemon::plugin_service::plugin_service |
( |
bot & |
bot | ) |
|
|
noexcept |
Create the plugin service.
- Parameters
-
◆ ~plugin_service()
virtual irccd::daemon::plugin_service::~plugin_service |
( |
| ) |
|
|
virtual |
◆ add()
void irccd::daemon::plugin_service::add |
( |
std::shared_ptr< plugin > |
plg | ) |
|
Add the specified plugin to the registry.
- Precondition
- plg != nullptr
- Parameters
-
- Note
- the plugin is only added to the list, no action is performed on it
◆ add_loader()
void irccd::daemon::plugin_service::add_loader |
( |
std::unique_ptr< plugin_loader > |
loader | ) |
|
Add a loader.
- Precondition
- loader != nullptr
- Parameters
-
◆ clear()
void irccd::daemon::plugin_service::clear |
( |
| ) |
|
|
noexcept |
◆ exec() [1/2]
template<typename Func , typename... Args>
void irccd::daemon::plugin_service::exec |
( |
std::shared_ptr< plugin > |
plugin, |
|
|
Func && |
fn, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Call a plugin function and throw an exception with the following errors:
- Precondition
- plugin != nullptr
- Parameters
-
plugin | the plugin |
fn | the plugin member function (pointer to member) |
args | the arguments to pass |
◆ exec() [2/2]
template<typename Func , typename... Args>
void irccd::daemon::plugin_service::exec |
( |
std::string_view |
name, |
|
|
Func && |
fn, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Overloaded function.
- Parameters
-
name | the plugin name |
fn | the plugin member function (pointer to member) |
args | the arguments to pass |
◆ find()
auto irccd::daemon::plugin_service::find |
( |
std::string_view |
id | ) |
-> std::shared_ptr< plugin > |
Generic function for finding a plugin.
- Parameters
-
- Returns
- the plugin or nullptr on failures
◆ get()
auto irccd::daemon::plugin_service::get |
( |
std::string_view |
id | ) |
const -> std::shared_ptr< plugin > |
|
noexcept |
Get a loaded plugin or null if not found.
- Parameters
-
- Returns
- the plugin or empty one if not found
◆ get_options()
auto irccd::daemon::plugin_service::get_options |
( |
std::string_view |
id | ) |
-> plugin::map |
Get the configuration for the specified plugin.
- Parameters
-
- Returns
- the configuration
◆ get_paths()
auto irccd::daemon::plugin_service::get_paths |
( |
std::string_view |
id | ) |
-> plugin::map |
Get the paths for the specified plugin.
If none is defined, return the default ones.
- Parameters
-
- Returns
- the paths
◆ get_templates()
auto irccd::daemon::plugin_service::get_templates |
( |
std::string_view |
id | ) |
-> plugin::map |
Get the templates for the specified plugin.
- Parameters
-
- Returns
- the formats
◆ has()
auto irccd::daemon::plugin_service::has |
( |
std::string_view |
id | ) |
const -> bool |
|
noexcept |
Check if a plugin is loaded.
- Parameters
-
- Returns
- true if has plugin
◆ list()
auto irccd::daemon::plugin_service::list |
( |
| ) |
const -> plugins |
|
noexcept |
Get the list of plugins.
- Returns
- the list of plugins
◆ load() [1/2]
void irccd::daemon::plugin_service::load |
( |
const config & |
cfg | ) |
|
|
noexcept |
Load all plugins.
- Parameters
-
◆ load() [2/2]
void irccd::daemon::plugin_service::load |
( |
std::string_view |
id, |
|
|
std::string_view |
path = "" |
|
) |
| |
Convenient wrapper that loads a plugin, call handle_load and add it to the registry.
Any errors are printed using logger.
- Parameters
-
id | the plugin id |
path | the optional path (searched if empty) |
◆ open()
auto irccd::daemon::plugin_service::open |
( |
std::string_view |
id, |
|
|
std::string_view |
path |
|
) |
| -> std::shared_ptr< plugin > |
Generic function for opening the plugin at the given path.
This function will search for every plugin_loader and call open() on it the first one that success will be returned.
- Parameters
-
id | the plugin id |
path | the path to the file |
- Returns
- the plugin or nullptr on failures
◆ reload()
void irccd::daemon::plugin_service::reload |
( |
std::string_view |
id | ) |
|
Reload a plugin by calling onReload.
- Parameters
-
- Exceptions
-
std::exception | on failures |
◆ require()
auto irccd::daemon::plugin_service::require |
( |
std::string_view |
id | ) |
const -> std::shared_ptr< plugin > |
Find a loaded plugin.
- Parameters
-
- Returns
- the plugin
- Exceptions
-
◆ unload()
void irccd::daemon::plugin_service::unload |
( |
std::string_view |
id | ) |
|
Unload a plugin and remove it.
- Parameters
-
The documentation for this class was generated from the following file: