19 #ifndef IRCCD_DAEMON_PLUGIN_SERVICE_HPP
20 #define IRCCD_DAEMON_PLUGIN_SERVICE_HPP
27 #include <irccd/sysconfig.hpp>
33 #include <string_view>
55 using plugins = std::vector<std::shared_ptr<plugin>>;
93 auto
has(
std::string_view
id) const noexcept ->
bool;
212 template <typename Func, typename... Args>
218 std::invoke(std::forward<Func>(fn), *
plugin, std::forward<Args>(args)...);
219 }
catch (
const std::exception& ex) {
233 template <
typename Func,
typename... Args>
234 void exec(std::string_view name, Func&& fn, Args&&... args)
241 exec(std::move(
plugin), std::forward<Func>(fn), std::forward<Args>(args)...);
259 template <
typename T>
291 #endif // !IRCCD_DAEMON_PLUGIN_SERVICE_HPP
void add(std::shared_ptr< plugin > plg)
Manage plugins.
Definition: plugin_service.hpp:50
Traits for loggable objects.
Definition: logger.hpp:78
auto get_id() const noexcept -> const std::string &
auto require(std::string_view id) const -> std::shared_ptr< plugin >
Read .ini configuration file for irccd.
Definition: config.hpp:39
auto open(std::string_view id, std::string_view path) -> std::shared_ptr< plugin >
Abstract plugin.
Definition: plugin.hpp:61
auto get_paths(std::string_view id) -> plugin::map
virtual ~plugin_service()
void add_loader(std::unique_ptr< plugin_loader > loader)
void unload(std::string_view id)
auto find(std::string_view id) -> std::shared_ptr< plugin >
void load(std::string_view id, std::string_view path="")
auto get_options(std::string_view id) -> plugin::map
auto list() const noexcept -> plugins
Irccd main instance.
Definition: bot.hpp:58
@ not_found
The plugin was unable to run the function.
Definition: plugin.hpp:401
static auto get_category(const plugin &plugin) -> std::string_view
auto get_templates(std::string_view id) -> plugin::map
void reload(std::string_view id)
std::vector< std::unique_ptr< plugin_loader > > plugin_loaders
List of loaders.
Definition: plugin_service.hpp:60
Parent namespace.
Definition: acceptor.hpp:43
Plugin error.
Definition: plugin.hpp:388
static auto get_component(const plugin &plugin) -> std::string_view
Abstract interface for searching plugins.
Definition: plugin.hpp:328
auto get(std::string_view id) const noexcept -> std::shared_ptr< plugin >
@ exec_error
The plugin is already loaded.
Definition: plugin.hpp:404
void exec(std::shared_ptr< plugin > plugin, Func &&fn, Args &&... args)
Definition: plugin_service.hpp:213
std::vector< std::shared_ptr< plugin > > plugins
Map of plugins.
Definition: plugin_service.hpp:55
auto has(std::string_view id) const noexcept -> bool
plugin_service(bot &bot) noexcept
void exec(std::string_view name, Func &&fn, Args &&... args)
Definition: plugin_service.hpp:234