lib: strictly type function return status enumerations
[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 <babeltrace2/babeltrace.h>
19#include "common/assert.h"
20
21static bt_component_class_sink_consume_method_status sink_consume(
22 bt_self_component_sink *self_comp)
23{
24 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
25}
26
27static bt_component_class_message_iterator_init_method_status
28src_dummy_iterator_init_method(
29 bt_self_message_iterator *self_msg_iter,
30 bt_self_component_source *self_comp,
31 bt_self_component_port_output *self_port)
32{
33 return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK;
34}
35
36static bt_component_class_message_iterator_init_method_status
37flt_dummy_iterator_init_method(
38 bt_self_message_iterator *self_msg_iter,
39 bt_self_component_filter *self_comp,
40 bt_self_component_port_output *self_port)
41{
42 return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK;
43}
44
45static void dummy_iterator_finalize_method(
46 bt_self_message_iterator *self_msg_iter)
47{
48}
49
50static bt_component_class_message_iterator_next_method_status
51dummy_iterator_next_method(
52 bt_self_message_iterator *self_msg_iter,
53 bt_message_array_const msgs, uint64_t capacity,
54 uint64_t *count)
55{
56 return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK;
57}
58
59static bt_component_class_query_method_status flt_query_method(
60 bt_self_component_class_filter *component_class,
61 const bt_query_executor *query_exec,
62 const char *object, const bt_value *params,
63 __attribute__((unused)) bt_logging_level log_level,
64 const bt_value **result)
65{
66 bt_value *res = bt_value_array_create();
67 bt_value *val;
68 *result = res;
69 int iret;
70
71 BT_ASSERT(*result);
72 iret = bt_value_array_append_string_element(res, object);
73 BT_ASSERT(iret == 0);
74 iret = bt_value_copy(params, &val);
75 BT_ASSERT(iret == 0);
76 iret = bt_value_array_append_element(res, val);
77 BT_ASSERT(iret == 0);
78 bt_value_put_ref(val);
79 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK;
80}
81
82BT_PLUGIN_MODULE();
83BT_PLUGIN(test_sfs);
84BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
85BT_PLUGIN_AUTHOR("Janine Sutto");
86BT_PLUGIN_LICENSE("Beerware");
87BT_PLUGIN_VERSION(1, 2, 3, "yes");
88
89BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
90BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
91BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(source,
92 src_dummy_iterator_init_method);
93BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(source,
94 dummy_iterator_finalize_method);
95
96BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
97BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
98BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink,
99 "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
100 "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
101 "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
102 "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n"
103);
104
105BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
106BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
107BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(filter,
108 flt_dummy_iterator_init_method);
109BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(filter,
110 dummy_iterator_finalize_method);
111BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method);
This page took 0.023466 seconds and 4 git commands to generate.