Commit | Line | Data |
---|---|---|
484a3024 SM |
1 | /* |
2 | * SPDX-License-Identifier: GPL-2.0-only | |
3 | * | |
4 | * Copyright (C) 2020-2023 EfficiOS, inc. | |
5 | */ | |
6 | ||
ae2be88d SM |
7 | #ifndef BABELTRACE_TESTS_LIB_UTILS_RUN_IN_HPP |
8 | #define BABELTRACE_TESTS_LIB_UTILS_RUN_IN_HPP | |
484a3024 | 9 | |
c802cacb SM |
10 | #include <babeltrace2/babeltrace.h> |
11 | ||
5d15e4ca SM |
12 | #include "cpp-common/bt2/self-component-class.hpp" |
13 | #include "cpp-common/bt2/self-component-port.hpp" | |
14 | #include "cpp-common/bt2/self-message-iterator.hpp" | |
15 | ||
484a3024 | 16 | /* |
5d7e57e8 | 17 | * Base class from which to inherit to call runIn(). |
484a3024 | 18 | * |
5d7e57e8 SM |
19 | * Override any of the on*() methods to get your statements executed in |
20 | * a specific context. | |
484a3024 | 21 | */ |
5d7e57e8 SM |
22 | class RunIn |
23 | { | |
24 | public: | |
25 | virtual ~RunIn() = default; | |
26 | ||
27 | /* | |
28 | * Called when querying the component class `self`. | |
29 | */ | |
30 | virtual void onQuery(bt2::SelfComponentClass self); | |
31 | ||
32 | /* | |
33 | * Called when initializing the component `self`. | |
34 | */ | |
35 | virtual void onCompInit(bt2::SelfComponent self); | |
36 | ||
37 | /* | |
38 | * Called when initializing the message iterator `self`. | |
39 | */ | |
40 | virtual void onMsgIterInit(bt2::SelfMessageIterator self); | |
a72c7ff6 SM |
41 | |
42 | /* | |
43 | * Called within the "next" method of `self` to return the messages | |
44 | * `msgs`. | |
45 | */ | |
46 | virtual void onMsgIterNext(bt2::SelfMessageIterator self, bt2::ConstMessageArray& msgs); | |
5d7e57e8 | 47 | }; |
484a3024 SM |
48 | |
49 | /* | |
5d7e57e8 SM |
50 | * Runs a simple graph (one source and one sink component), calling the |
51 | * `on*()` methods of `runIn` along the way. | |
484a3024 | 52 | */ |
5d7e57e8 | 53 | void runIn(RunIn& runIn); |
484a3024 | 54 | |
ae2be88d | 55 | #endif /* BABELTRACE_TESTS_LIB_UTILS_RUN_IN_HPP */ |