Commit | Line | Data |
---|---|---|
cbb9e0b1 PP |
1 | /* |
2 | * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; under version 2 of the License. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along | |
14 | * with this program; if not, write to the Free Software Foundation, Inc., | |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
16 | */ | |
17 | ||
05e21286 | 18 | #include <babeltrace/babeltrace.h> |
25583cd0 | 19 | #include <babeltrace/assert-internal.h> |
cbb9e0b1 | 20 | |
d94d92ac PP |
21 | static enum bt_self_component_status sink_consume( |
22 | struct bt_self_component_sink *self_comp) | |
cbb9e0b1 | 23 | { |
d94d92ac | 24 | return BT_SELF_COMPONENT_STATUS_OK; |
cbb9e0b1 PP |
25 | } |
26 | ||
d94d92ac PP |
27 | static enum bt_self_notification_iterator_status src_dummy_iterator_init_method( |
28 | struct bt_self_notification_iterator *self_notif_iter, | |
29 | struct bt_self_component_source *self_comp, | |
30 | struct bt_self_component_port_output *self_port) | |
cbb9e0b1 | 31 | { |
d94d92ac PP |
32 | return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; |
33 | } | |
34 | ||
35 | static enum bt_self_notification_iterator_status flt_dummy_iterator_init_method( | |
36 | struct bt_self_notification_iterator *self_notif_iter, | |
37 | struct bt_self_component_filter *self_comp, | |
38 | struct bt_self_component_port_output *self_port) | |
39 | { | |
40 | return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK; | |
d3eb6e8f PP |
41 | } |
42 | ||
64cadc66 | 43 | static void dummy_iterator_finalize_method( |
d94d92ac | 44 | struct bt_self_notification_iterator *self_notif_iter) |
d3eb6e8f PP |
45 | { |
46 | } | |
47 | ||
d94d92ac PP |
48 | static enum bt_self_notification_iterator_status dummy_iterator_next_method( |
49 | struct bt_self_notification_iterator *self_notif_iter, | |
0d72b8c3 | 50 | bt_notification_array_const notifs, uint64_t capacity, |
d4393e08 | 51 | uint64_t *count) |
d3eb6e8f | 52 | { |
d94d92ac | 53 | return BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR; |
d3eb6e8f PP |
54 | } |
55 | ||
d94d92ac PP |
56 | static enum bt_query_status flt_query_method( |
57 | struct bt_self_component_class_filter *component_class, | |
0d72b8c3 | 58 | const struct bt_query_executor *query_exec, |
05e21286 PP |
59 | const char *object, const struct bt_value *params, |
60 | const struct bt_value **result) | |
5933c0f2 | 61 | { |
05e21286 PP |
62 | struct bt_value *res = bt_value_array_create(); |
63 | struct bt_value *val; | |
64 | *result = res; | |
c7eee084 | 65 | int iret; |
5933c0f2 | 66 | |
d94d92ac | 67 | BT_ASSERT(*result); |
05e21286 PP |
68 | iret = bt_value_array_append_string_element(res, object); |
69 | BT_ASSERT(iret == 0); | |
70 | iret = bt_value_copy(&val, params); | |
25583cd0 | 71 | BT_ASSERT(iret == 0); |
05e21286 | 72 | iret = bt_value_array_append_element(res, val); |
25583cd0 | 73 | BT_ASSERT(iret == 0); |
05e21286 | 74 | bt_object_put_ref(val); |
d94d92ac | 75 | return BT_QUERY_STATUS_OK; |
5933c0f2 PP |
76 | } |
77 | ||
df5b5d01 | 78 | BT_PLUGIN_MODULE(); |
6ba0b073 | 79 | BT_PLUGIN(test_sfs); |
cbb9e0b1 PP |
80 | BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes"); |
81 | BT_PLUGIN_AUTHOR("Janine Sutto"); | |
82 | BT_PLUGIN_LICENSE("Beerware"); | |
458e8e1d | 83 | BT_PLUGIN_VERSION(1, 2, 3, "yes"); |
cbb9e0b1 | 84 | |
41a2b7ae | 85 | BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method); |
d3e4dcd8 | 86 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source."); |
d3eb6e8f | 87 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(source, |
d94d92ac | 88 | src_dummy_iterator_init_method); |
64cadc66 PP |
89 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(source, |
90 | dummy_iterator_finalize_method); | |
6ba0b073 | 91 | |
d3e4dcd8 PP |
92 | BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume); |
93 | BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink."); | |
a889b89f PP |
94 | BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink, |
95 | "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n" | |
96 | "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n" | |
97 | "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n" | |
98 | "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n" | |
99 | ); | |
6ba0b073 | 100 | |
41a2b7ae | 101 | BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method); |
d3e4dcd8 | 102 | BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter."); |
d3eb6e8f | 103 | BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(filter, |
d94d92ac | 104 | flt_dummy_iterator_init_method); |
64cadc66 PP |
105 | BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(filter, |
106 | dummy_iterator_finalize_method); | |
d94d92ac | 107 | BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method); |