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