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 | ||
18 | #include <babeltrace/plugin/plugin-dev.h> | |
5933c0f2 PP |
19 | #include <babeltrace/component/component-class.h> |
20 | #include <babeltrace/values.h> | |
21 | #include <babeltrace/ref.h> | |
22 | #include <assert.h> | |
cbb9e0b1 | 23 | |
890882ef PP |
24 | static enum bt_component_status sink_consume( |
25 | struct bt_private_component *private_component) | |
cbb9e0b1 | 26 | { |
cbb9e0b1 PP |
27 | return BT_COMPONENT_STATUS_OK; |
28 | } | |
29 | ||
d3eb6e8f | 30 | static enum bt_notification_iterator_status dummy_iterator_init_method( |
890882ef PP |
31 | struct bt_private_component *private_component, |
32 | struct bt_private_port *private_port, | |
33 | struct bt_private_notification_iterator *private_iterator) | |
cbb9e0b1 | 34 | { |
d3eb6e8f PP |
35 | return BT_NOTIFICATION_ITERATOR_STATUS_OK; |
36 | } | |
37 | ||
64cadc66 | 38 | static void dummy_iterator_finalize_method( |
890882ef | 39 | struct bt_private_notification_iterator *private_iterator) |
d3eb6e8f PP |
40 | { |
41 | } | |
42 | ||
41a2b7ae | 43 | static struct bt_notification_iterator_next_return dummy_iterator_next_method( |
890882ef | 44 | struct bt_private_notification_iterator *private_iterator) |
d3eb6e8f | 45 | { |
41a2b7ae PP |
46 | struct bt_notification_iterator_next_return next_return = { |
47 | .notification = NULL, | |
48 | .status = BT_NOTIFICATION_ITERATOR_STATUS_OK, | |
49 | }; | |
d3eb6e8f | 50 | |
41a2b7ae | 51 | return next_return; |
d3eb6e8f PP |
52 | } |
53 | ||
54 | static enum bt_notification_iterator_status dummy_iterator_seek_time_method( | |
890882ef PP |
55 | struct bt_private_notification_iterator *private_iterator, |
56 | int64_t time) | |
d3eb6e8f PP |
57 | { |
58 | return BT_NOTIFICATION_ITERATOR_STATUS_OK; | |
cbb9e0b1 PP |
59 | } |
60 | ||
a67681c1 | 61 | static struct bt_value *query_method( |
5933c0f2 | 62 | struct bt_component_class *component_class, |
a67681c1 | 63 | const char *object, struct bt_value *params) |
5933c0f2 PP |
64 | { |
65 | int ret; | |
66 | struct bt_value *results = bt_value_array_create(); | |
67 | ||
68 | assert(results); | |
a67681c1 | 69 | ret = bt_value_array_append_string(results, object); |
5933c0f2 PP |
70 | assert(ret == 0); |
71 | ret = bt_value_array_append(results, params); | |
72 | assert(ret == 0); | |
73 | return results; | |
74 | } | |
75 | ||
6ba0b073 | 76 | BT_PLUGIN(test_sfs); |
cbb9e0b1 PP |
77 | BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes"); |
78 | BT_PLUGIN_AUTHOR("Janine Sutto"); | |
79 | BT_PLUGIN_LICENSE("Beerware"); | |
458e8e1d | 80 | BT_PLUGIN_VERSION(1, 2, 3, "yes"); |
cbb9e0b1 | 81 | |
41a2b7ae | 82 | BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method); |
d3e4dcd8 | 83 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source."); |
d3eb6e8f PP |
84 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(source, |
85 | dummy_iterator_init_method); | |
64cadc66 PP |
86 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(source, |
87 | dummy_iterator_finalize_method); | |
d3eb6e8f PP |
88 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(source, |
89 | dummy_iterator_seek_time_method); | |
6ba0b073 | 90 | |
d3e4dcd8 PP |
91 | BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume); |
92 | BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink."); | |
a889b89f PP |
93 | BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink, |
94 | "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n" | |
95 | "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n" | |
96 | "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n" | |
97 | "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n" | |
98 | ); | |
6ba0b073 | 99 | |
41a2b7ae | 100 | BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method); |
d3e4dcd8 | 101 | BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter."); |
d3eb6e8f PP |
102 | BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(filter, |
103 | dummy_iterator_init_method); | |
64cadc66 PP |
104 | BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(filter, |
105 | dummy_iterator_finalize_method); | |
d3eb6e8f PP |
106 | BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(filter, |
107 | dummy_iterator_seek_time_method); | |
a67681c1 | 108 | BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, query_method); |