From 44f12d22f441b3a17864bb0512cf317755478ba9 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 31 May 2024 13:01:46 -0400 Subject: [PATCH] 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 --- src/cpp-common/bt2/plugin-load.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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) { -- 2.34.1