cpp-common/bt2: add `findAllPluginsFromFile()`
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 31 May 2024 17:01:46 +0000 (13:01 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
Add `findAllPluginsFromFile()`, a wrapper around
`bt_plugin_find_all_from_file()`.

Change-Id: I4794afe368dcb99c4c2441de58d9497d2cf40f38
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12830
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cpp-common/bt2/plugin-load.hpp

index 00b0510c70a47729456e335e8e0575dab3c98960..c1808d349ae21dff04f2e0c1aadb2f441787bb01 100644 (file)
@@ -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)
 {
This page took 0.024685 seconds and 4 git commands to generate.