The method can be used to register and load user-defined plugins. All other previously loaded plugins will be reinitialized and the data will be reloaded. Signed-off-by: Yordan Karadzhov <ykaradzhov@xxxxxxxxxx> --- kernel-shark/src/KsUtils.cpp | 23 +++++++++++++++++++++++ kernel-shark/src/KsUtils.hpp | 3 +++ 2 files changed, 26 insertions(+) diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp index 3585cca..6af0c66 100644 --- a/kernel-shark/src/KsUtils.cpp +++ b/kernel-shark/src/KsUtils.cpp @@ -596,6 +596,29 @@ void KsPluginManager::unregisterPlugin(const QString &plugin) } } +/** @brief Add to the list and initialize user-provided plugins. All other + * previously loaded plugins will be reinitialized and the data will be + * reloaded. + * + * @param fileNames: the library files (.so) of the plugins. +*/ +void KsPluginManager::addPlugins(const QStringList &fileNames) +{ + kshark_context *kshark_ctx(nullptr); + + if (!kshark_instance(&kshark_ctx)) + return; + + kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_CLOSE); + + for (auto const &p: fileNames) + registerPlugin(p); + + kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_INIT); + + emit dataReload(); +} + /** Unload all plugins. */ void KsPluginManager::unloadAll() { diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp index cb95b4f..c8b5e88 100644 --- a/kernel-shark/src/KsUtils.hpp +++ b/kernel-shark/src/KsUtils.hpp @@ -210,6 +210,9 @@ public: void registerPlugin(const QString &plugin); void unregisterPlugin(const QString &plugin); + + void addPlugins(const QStringList &fileNames); + void unloadAll(); void updatePlugins(QVector<int> pluginId); -- 2.19.1