Commit | Line | Data |
---|---|---|
484a3024 SM |
1 | /* |
2 | * SPDX-License-Identifier: GPL-2.0-only | |
3 | * | |
4 | * Copyright (C) 2020-2023 EfficiOS, inc. | |
5 | */ | |
6 | ||
7 | #ifndef TESTS_LIB_UTILS_H | |
8 | #define TESTS_LIB_UTILS_H | |
9 | ||
10 | #include <babeltrace2/babeltrace.h> | |
11 | #include <functional> | |
12 | ||
13 | using RunInCompClsQueryFunc = std::function<void(bt_self_component_class *)>; | |
14 | using RunInCompClsInitFunc = std::function<void(bt_self_component *)>; | |
15 | using RunInMsgIterClsInitFunc = std::function<void(bt_self_message_iterator *)>; | |
16 | ||
17 | /* | |
18 | * Runs: | |
19 | * | |
20 | * • `compClsCtxFunc` in the context of a component class method, | |
21 | * if not `nullptr`. | |
22 | * | |
23 | * • `compCtxFunc` in the context of a component method, if not | |
24 | * `nullptr`. | |
25 | * | |
26 | * • `msgIterCtxFunc` in the context of a message iterator method, if | |
27 | * not `nullptr`. | |
28 | */ | |
29 | void runIn(RunInCompClsQueryFunc compClsCtxFunc, RunInCompClsInitFunc compCtxFunc, | |
30 | RunInMsgIterClsInitFunc msgIterCtxFunc); | |
31 | ||
32 | /* | |
33 | * Runs `func` in the context of a component class method. | |
34 | */ | |
35 | void runInCompClsQuery(RunInCompClsQueryFunc func); | |
36 | ||
37 | /* | |
38 | * Runs `func` in the context of a component method. | |
39 | */ | |
40 | void runInCompClsInit(RunInCompClsInitFunc func); | |
41 | ||
42 | /* | |
43 | * Runs `func` in the context of a message iterator method. | |
44 | */ | |
45 | void runInMsgIterClsInit(RunInMsgIterClsInitFunc func); | |
46 | ||
47 | #endif /* TESTS_LIB_UTILS_H */ |