lib: bt_object_{get,put}_ref(): accept a `const` parameter
[babeltrace.git] / tests / lib / test-plugin-plugins / sfs.c
... / ...
CommitLineData
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/private-values.h>
22#include <babeltrace/object.h>
23#include <babeltrace/assert-internal.h>
24#include <babeltrace/assert-internal.h>
25
26static enum bt_self_component_status sink_consume(
27 struct bt_self_component_sink *self_comp)
28{
29 return BT_SELF_COMPONENT_STATUS_OK;
30}
31
32static enum bt_self_notification_iterator_status src_dummy_iterator_init_method(
33 struct bt_self_notification_iterator *self_notif_iter,
34 struct bt_self_component_source *self_comp,
35 struct bt_self_component_port_output *self_port)
36{
37 return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
38}
39
40static enum bt_self_notification_iterator_status flt_dummy_iterator_init_method(
41 struct bt_self_notification_iterator *self_notif_iter,
42 struct bt_self_component_filter *self_comp,
43 struct bt_self_component_port_output *self_port)
44{
45 return BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK;
46}
47
48static void dummy_iterator_finalize_method(
49 struct bt_self_notification_iterator *self_notif_iter)
50{
51}
52
53static enum bt_self_notification_iterator_status dummy_iterator_next_method(
54 struct bt_self_notification_iterator *self_notif_iter,
55 bt_notification_array notifs, uint64_t capacity,
56 uint64_t *count)
57{
58 return BT_SELF_NOTIFICATION_ITERATOR_STATUS_ERROR;
59}
60
61static enum bt_query_status flt_query_method(
62 struct bt_self_component_class_filter *component_class,
63 struct bt_query_executor *query_exec,
64 const char *object, struct bt_value *params,
65 struct bt_value **result)
66{
67 struct bt_private_value *res = bt_private_value_array_create();
68 *result = bt_private_value_as_value(res);
69 int iret;
70
71 BT_ASSERT(*result);
72 iret = bt_private_value_array_append_string_element(res, object);
73 BT_ASSERT(iret == 0);
74 iret = bt_private_value_array_append_element(res, params);
75 BT_ASSERT(iret == 0);
76 return BT_QUERY_STATUS_OK;
77}
78
79BT_PLUGIN_MODULE();
80BT_PLUGIN(test_sfs);
81BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
82BT_PLUGIN_AUTHOR("Janine Sutto");
83BT_PLUGIN_LICENSE("Beerware");
84BT_PLUGIN_VERSION(1, 2, 3, "yes");
85
86BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
87BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
88BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(source,
89 src_dummy_iterator_init_method);
90BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(source,
91 dummy_iterator_finalize_method);
92
93BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
94BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
95BT_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
102BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
103BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
104BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(filter,
105 flt_dummy_iterator_init_method);
106BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD(filter,
107 dummy_iterator_finalize_method);
108BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method);
This page took 0.022362 seconds and 4 git commands to generate.