tests: add framework to run code in comp cls / comp / msg iter context
[babeltrace.git] / tests / lib / utils / run-in.hpp
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 */
This page took 0.030755 seconds and 4 git commands to generate.