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 | ||
484a3024 SM |
10 | #include <functional> |
11 | ||
c802cacb SM |
12 | #include <babeltrace2/babeltrace.h> |
13 | ||
484a3024 SM |
14 | using RunInCompClsQueryFunc = std::function<void(bt_self_component_class *)>; |
15 | using RunInCompClsInitFunc = std::function<void(bt_self_component *)>; | |
16 | using RunInMsgIterClsInitFunc = std::function<void(bt_self_message_iterator *)>; | |
17 | ||
18 | /* | |
19 | * Runs: | |
20 | * | |
21 | * • `compClsCtxFunc` in the context of a component class method, | |
22 | * if not `nullptr`. | |
23 | * | |
24 | * • `compCtxFunc` in the context of a component method, if not | |
25 | * `nullptr`. | |
26 | * | |
27 | * • `msgIterCtxFunc` in the context of a message iterator method, if | |
28 | * not `nullptr`. | |
29 | */ | |
30 | void runIn(RunInCompClsQueryFunc compClsCtxFunc, RunInCompClsInitFunc compCtxFunc, | |
31 | RunInMsgIterClsInitFunc msgIterCtxFunc); | |
32 | ||
33 | /* | |
34 | * Runs `func` in the context of a component class method. | |
35 | */ | |
36 | void runInCompClsQuery(RunInCompClsQueryFunc func); | |
37 | ||
38 | /* | |
39 | * Runs `func` in the context of a component method. | |
40 | */ | |
41 | void runInCompClsInit(RunInCompClsInitFunc func); | |
42 | ||
43 | /* | |
44 | * Runs `func` in the context of a message iterator method. | |
45 | */ | |
46 | void runInMsgIterClsInit(RunInMsgIterClsInitFunc func); | |
47 | ||
48 | #endif /* TESTS_LIB_UTILS_H */ |