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