8#ifndef MALENA_PLUGINHOST_H
9#define MALENA_PLUGINHOST_H
19 #define LIB_HANDLE HMODULE
20 #define LOAD_LIB(path) LoadLibraryA(path)
21 #define GET_FUNC(handle,name) GetProcAddress(handle, name)
22 #define CLOSE_LIB(handle) FreeLibrary(static_cast<HMODULE>(handle))
25 #define LIB_HANDLE void*
26 #define LOAD_LIB(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
27 #define GET_FUNC(handle,name) dlsym(handle, name)
28 #define CLOSE_LIB(handle) dlclose(handle)
31namespace fs = std::filesystem;
90 std::vector<PluginData> _plugins;
92 std::vector<std::string> getPluginFiles(
const std::string& directory);
93 std::vector<std::string> getFilesInDirectory(
const std::string& directory,
94 const std::string& extension =
"");
181 void doUnloadPlugin(
Plugin* plugin);
CRTP base that gives a manager safe deferred-operation support.
Abstract base class for all Malena plugins.
void unloadPlugin(Plugin *plugin)
Unload a plugin and close its shared library.
Plugin * loadPlugin(const std::string &path)
Load a single plugin from a shared library path.
void loadPluginsFromDirectory(const std::string &dir)
Load all plugin libraries found in a directory.
std::vector< Plugin * > getPlugins()
Return all currently loaded plugins.
PluginManager(const std::string &pluginPath="")
Construct a PluginManager with a default plugin search path.
std::vector< PluginInfo > scanPlugins(const std::string &dir)
Probe a directory for plugins without keeping them loaded.