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