4d0357c604a76f81beae6108e4a9bb7c2f023e35
[babeltrace.git] / tests / lib / test-plugin-plugins / sfs.c
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>
19 #include <babeltrace/graph/component-class.h>
20 #include <babeltrace/values.h>
21 #include <babeltrace/ref.h>
22 #include <babeltrace/assert-internal.h>
23 #include <babeltrace/assert-internal.h>
24
25 static enum bt_component_status sink_consume(
26 struct bt_private_component *private_component)
27 {
28 return BT_COMPONENT_STATUS_OK;
29 }
30
31 static enum bt_notification_iterator_status dummy_iterator_init_method(
32 struct bt_private_connection_private_notification_iterator *private_iterator,
33 struct bt_private_port *private_port)
34 {
35 return BT_NOTIFICATION_ITERATOR_STATUS_OK;
36 }
37
38 static void dummy_iterator_finalize_method(
39 struct bt_private_connection_private_notification_iterator *private_iterator)
40 {
41 }
42
43 static enum bt_notification_iterator_status dummy_iterator_next_method(
44 struct bt_private_connection_private_notification_iterator *private_iterator,
45 bt_notification_array notifs, uint64_t capacity,
46 uint64_t *count)
47 {
48 return BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
49 }
50
51 static struct bt_component_class_query_method_return query_method(
52 struct bt_component_class *component_class,
53 struct bt_query_executor *query_exec,
54 const char *object, struct bt_value *params)
55 {
56 struct bt_component_class_query_method_return ret = {
57 .status = BT_QUERY_STATUS_OK,
58 .result = bt_value_array_create(),
59 };
60 int iret;
61
62 BT_ASSERT(ret.result);
63 iret = bt_value_array_append_string(ret.result, object);
64 BT_ASSERT(iret == 0);
65 iret = bt_value_array_append(ret.result, params);
66 BT_ASSERT(iret == 0);
67 return ret;
68 }
69
70 BT_PLUGIN_MODULE();
71 BT_PLUGIN(test_sfs);
72 BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
73 BT_PLUGIN_AUTHOR("Janine Sutto");
74 BT_PLUGIN_LICENSE("Beerware");
75 BT_PLUGIN_VERSION(1, 2, 3, "yes");
76
77 BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
78 BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
79 BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(source,
80 dummy_iterator_init_method);
81 BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(source,
82 dummy_iterator_finalize_method);
83
84 BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
85 BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
86 BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink,
87 "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
88 "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
89 "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
90 "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n"
91 );
92
93 BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
94 BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
95 BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(filter,
96 dummy_iterator_init_method);
97 BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(filter,
98 dummy_iterator_finalize_method);
99 BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, query_method);
This page took 0.030899 seconds and 3 git commands to generate.