cpp-common/bt2: move `ConstPluginSet` to `plugin-set.hpp`
[babeltrace.git] / src / cpp-common / bt2 / plugin.hpp
CommitLineData
785712e1
SM
1/*
2 * Copyright (c) 2024 EfficiOS, Inc.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#ifndef BABELTRACE_CPP_COMMON_BT2_PLUGIN_HPP
8#define BABELTRACE_CPP_COMMON_BT2_PLUGIN_HPP
9
10#include <babeltrace2/babeltrace.h>
11
12#include "common/common.h"
785712e1
SM
13#include "cpp-common/bt2c/c-string-view.hpp"
14
4993dc41
SM
15#include "exc.hpp"
16#include "plugin-set.hpp"
785712e1 17
4993dc41 18namespace bt2 {
785712e1
SM
19
20inline ConstPluginSet::Shared findAllPluginsFromDir(const bt2c::CStringView path,
21 const bool recurse, const bool failOnLoadError)
22{
23 const bt_plugin_set *pluginSet;
24
25 switch (bt_plugin_find_all_from_dir(path, recurse, failOnLoadError, &pluginSet)) {
26 case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_OK:
27 return ConstPluginSet::Shared::createWithoutRef(pluginSet);
28 case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_NOT_FOUND:
29 return ConstPluginSet::Shared {};
30 case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_MEMORY_ERROR:
31 throw MemoryError {};
32 case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_ERROR:
33 throw Error {};
34 }
35
36 bt_common_abort();
37}
38
39} /* namespace bt2 */
40
41#endif /* BABELTRACE_CPP_COMMON_BT2_PLUGIN_HPP */
This page took 0.025434 seconds and 4 git commands to generate.