lib: introduce bt_message_iterator_class
[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
71c5da58 18#include <babeltrace2/babeltrace.h>
57952005 19#include "common/assert.h"
cbb9e0b1 20
fb25b9e3 21static bt_component_class_sink_consume_method_status sink_consume(
8eee8ea2 22 bt_self_component_sink *self_comp)
cbb9e0b1 23{
fb25b9e3 24 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
cbb9e0b1
PP
25}
26
68e2deed 27static bt_message_iterator_class_initialize_method_status
fb25b9e3 28src_dummy_iterator_init_method(
b09a5592 29 bt_self_message_iterator *self_msg_iter,
9415de1c 30 bt_self_message_iterator_configuration *config,
68e2deed 31 bt_self_component *self_comp,
8eee8ea2 32 bt_self_component_port_output *self_port)
cbb9e0b1 33{
68e2deed 34 return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
834e9996
PP
35}
36
68e2deed 37static bt_message_iterator_class_initialize_method_status
fb25b9e3 38flt_dummy_iterator_init_method(
b09a5592 39 bt_self_message_iterator *self_msg_iter,
9415de1c 40 bt_self_message_iterator_configuration *config,
68e2deed 41 bt_self_component *self_comp,
8eee8ea2 42 bt_self_component_port_output *self_port)
834e9996 43{
68e2deed 44 return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
d3eb6e8f
PP
45}
46
64cadc66 47static void dummy_iterator_finalize_method(
b09a5592 48 bt_self_message_iterator *self_msg_iter)
d3eb6e8f
PP
49{
50}
51
68e2deed 52static bt_message_iterator_class_next_method_status
fb25b9e3 53dummy_iterator_next_method(
b09a5592
PP
54 bt_self_message_iterator *self_msg_iter,
55 bt_message_array_const msgs, uint64_t capacity,
3fd7b79d 56 uint64_t *count)
d3eb6e8f 57{
68e2deed 58 return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
d3eb6e8f
PP
59}
60
fb25b9e3 61static bt_component_class_query_method_status flt_query_method(
8eee8ea2 62 bt_self_component_class_filter *component_class,
bf403eb2 63 bt_private_query_executor *priv_query_exec,
8eee8ea2 64 const char *object, const bt_value *params,
f6e305ce 65 __attribute__((unused)) void *method_data,
8eee8ea2 66 const bt_value **result)
5933c0f2 67{
8eee8ea2
PP
68 bt_value *res = bt_value_array_create();
69 bt_value *val;
ce141536 70 *result = res;
1286dcbb 71 int iret;
5933c0f2 72
834e9996 73 BT_ASSERT(*result);
ce141536
PP
74 iret = bt_value_array_append_string_element(res, object);
75 BT_ASSERT(iret == 0);
6284461f 76 iret = bt_value_copy(params, &val);
b8f13b8b 77 BT_ASSERT(iret == 0);
ce141536 78 iret = bt_value_array_append_element(res, val);
b8f13b8b 79 BT_ASSERT(iret == 0);
8c6884d9 80 bt_value_put_ref(val);
fb25b9e3 81 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK;
5933c0f2
PP
82}
83
edb2ec3c 84BT_PLUGIN_MODULE();
6ba0b073 85BT_PLUGIN(test_sfs);
cbb9e0b1
PP
86BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
87BT_PLUGIN_AUTHOR("Janine Sutto");
88BT_PLUGIN_LICENSE("Beerware");
458e8e1d 89BT_PLUGIN_VERSION(1, 2, 3, "yes");
cbb9e0b1 90
41a2b7ae 91BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
d3e4dcd8 92BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
4175c1d5 93BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD(source,
834e9996 94 src_dummy_iterator_init_method);
b09a5592 95BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(source,
64cadc66 96 dummy_iterator_finalize_method);
6ba0b073 97
d3e4dcd8
PP
98BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
99BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
a889b89f
PP
100BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink,
101 "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
102 "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
103 "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
104 "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n"
105);
6ba0b073 106
41a2b7ae 107BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
d3e4dcd8 108BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
4175c1d5 109BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD(filter,
834e9996 110 flt_dummy_iterator_init_method);
b09a5592 111BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(filter,
64cadc66 112 dummy_iterator_finalize_method);
834e9996 113BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method);
This page took 0.061122 seconds and 4 git commands to generate.