Fix: macro name for "get supported mip versions method" attribute descriptor
[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 <babeltrace2/babeltrace.h>
19 #include "common/assert.h"
20
21 static 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
27 static bt_component_class_get_supported_mip_versions_method_status
28 sink_get_supported_mip_versions(
29 bt_self_component_class_sink *source_component_class,
30 const bt_value *params, void *initialize_method_data,
31 bt_logging_level logging_level,
32 bt_integer_range_set_unsigned *supported_versions)
33 {
34 return (int) bt_integer_range_set_unsigned_add_range(
35 supported_versions, 0, 0);
36 }
37
38 static bt_message_iterator_class_initialize_method_status
39 src_dummy_iterator_init_method(
40 bt_self_message_iterator *self_msg_iter,
41 bt_self_message_iterator_configuration *config,
42 bt_self_component_port_output *self_port)
43 {
44 return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
45 }
46
47 static bt_message_iterator_class_initialize_method_status
48 flt_dummy_iterator_init_method(
49 bt_self_message_iterator *self_msg_iter,
50 bt_self_message_iterator_configuration *config,
51 bt_self_component_port_output *self_port)
52 {
53 return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
54 }
55
56 static void dummy_iterator_finalize_method(
57 bt_self_message_iterator *self_msg_iter)
58 {
59 }
60
61 static bt_message_iterator_class_next_method_status
62 dummy_iterator_next_method(
63 bt_self_message_iterator *self_msg_iter,
64 bt_message_array_const msgs, uint64_t capacity,
65 uint64_t *count)
66 {
67 return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
68 }
69
70 static bt_component_class_query_method_status flt_query_method(
71 bt_self_component_class_filter *component_class,
72 bt_private_query_executor *priv_query_exec,
73 const char *object, const bt_value *params,
74 __attribute__((unused)) void *method_data,
75 const bt_value **result)
76 {
77 bt_value *res = bt_value_array_create();
78 bt_value *val;
79 *result = res;
80 int iret;
81
82 BT_ASSERT(*result);
83 iret = bt_value_array_append_string_element(res, object);
84 BT_ASSERT(iret == 0);
85 iret = bt_value_copy(params, &val);
86 BT_ASSERT(iret == 0);
87 iret = bt_value_array_append_element(res, val);
88 BT_ASSERT(iret == 0);
89 bt_value_put_ref(val);
90 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK;
91 }
92
93 BT_PLUGIN_MODULE();
94 BT_PLUGIN(test_sfs);
95 BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
96 BT_PLUGIN_AUTHOR("Janine Sutto");
97 BT_PLUGIN_LICENSE("Beerware");
98 BT_PLUGIN_VERSION(1, 2, 3, "yes");
99
100 BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
101 BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
102 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(source,
103 src_dummy_iterator_init_method);
104 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(source,
105 dummy_iterator_finalize_method);
106
107 BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
108 BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
109 BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink,
110 "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
111 "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
112 "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
113 "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n"
114 );
115 BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD(sink,
116 sink_get_supported_mip_versions);
117
118 BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
119 BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
120 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(filter,
121 flt_dummy_iterator_init_method);
122 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(filter,
123 dummy_iterator_finalize_method);
124 BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method);
This page took 0.03132 seconds and 4 git commands to generate.