From: Simon Marchi Date: Fri, 31 May 2024 17:01:46 +0000 (-0400) Subject: cpp-common/bt2: add `findAllPluginsFromFile()` X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=44f12d22f441b3a17864bb0512cf317755478ba9;p=babeltrace.git cpp-common/bt2: add `findAllPluginsFromFile()` Add `findAllPluginsFromFile()`, a wrapper around `bt_plugin_find_all_from_file()`. Change-Id: I4794afe368dcb99c4c2441de58d9497d2cf40f38 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/12830 Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/src/cpp-common/bt2/plugin-load.hpp b/src/cpp-common/bt2/plugin-load.hpp index 00b0510c..c1808d34 100644 --- a/src/cpp-common/bt2/plugin-load.hpp +++ b/src/cpp-common/bt2/plugin-load.hpp @@ -38,6 +38,25 @@ findPlugin(const bt2c::CStringView name, const bool findInStdEnvVar = true, return ConstPlugin::Shared::createWithoutRef(plugin); } +inline ConstPluginSet::Shared findAllPluginsFromFile(const bt2c::CStringView path, + const bool failOnLoadError) +{ + const bt_plugin_set *pluginSet; + + switch (bt_plugin_find_all_from_file(path, failOnLoadError, &pluginSet)) { + case BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_OK: + return ConstPluginSet::Shared::createWithoutRef(pluginSet); + case BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_NOT_FOUND: + return ConstPluginSet::Shared {}; + case BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_MEMORY_ERROR: + throw MemoryError {}; + case BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_ERROR: + throw Error {}; + } + + bt_common_abort(); +} + inline ConstPluginSet::Shared findAllPluginsFromDir(const bt2c::CStringView path, const bool recurse, const bool failOnLoadError) {