2 * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
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.
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.
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.
18 #include <babeltrace2/babeltrace.h>
19 #include "common/assert.h"
21 static bt_component_class_sink_consume_method_status
sink_consume(
22 bt_self_component_sink
*self_comp
)
24 return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK
;
27 static bt_component_class_message_iterator_initialize_method_status
28 src_dummy_iterator_init_method(
29 bt_self_message_iterator
*self_msg_iter
,
30 bt_self_message_iterator_configuration
*config
,
31 bt_self_component_source
*self_comp
,
32 bt_self_component_port_output
*self_port
)
34 return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK
;
37 static bt_component_class_message_iterator_initialize_method_status
38 flt_dummy_iterator_init_method(
39 bt_self_message_iterator
*self_msg_iter
,
40 bt_self_message_iterator_configuration
*config
,
41 bt_self_component_filter
*self_comp
,
42 bt_self_component_port_output
*self_port
)
44 return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK
;
47 static void dummy_iterator_finalize_method(
48 bt_self_message_iterator
*self_msg_iter
)
52 static bt_component_class_message_iterator_next_method_status
53 dummy_iterator_next_method(
54 bt_self_message_iterator
*self_msg_iter
,
55 bt_message_array_const msgs
, uint64_t capacity
,
58 return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK
;
61 static bt_component_class_query_method_status
flt_query_method(
62 bt_self_component_class_filter
*component_class
,
63 bt_private_query_executor
*priv_query_exec
,
64 const char *object
, const bt_value
*params
,
65 __attribute__((unused
)) void *method_data
,
66 const bt_value
**result
)
68 bt_value
*res
= bt_value_array_create();
74 iret
= bt_value_array_append_string_element(res
, object
);
76 iret
= bt_value_copy(params
, &val
);
78 iret
= bt_value_array_append_element(res
, val
);
80 bt_value_put_ref(val
);
81 return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK
;
86 BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
87 BT_PLUGIN_AUTHOR("Janine Sutto");
88 BT_PLUGIN_LICENSE("Beerware");
89 BT_PLUGIN_VERSION(1, 2, 3, "yes");
91 BT_PLUGIN_SOURCE_COMPONENT_CLASS(source
, dummy_iterator_next_method
);
92 BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source
, "A source.");
93 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD(source
,
94 src_dummy_iterator_init_method
);
95 BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(source
,
96 dummy_iterator_finalize_method
);
98 BT_PLUGIN_SINK_COMPONENT_CLASS(sink
, sink_consume
);
99 BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink
, "A sink.");
100 BT_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"
107 BT_PLUGIN_FILTER_COMPONENT_CLASS(filter
, dummy_iterator_next_method
);
108 BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter
, "A filter.");
109 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD(filter
,
110 flt_dummy_iterator_init_method
);
111 BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD(filter
,
112 dummy_iterator_finalize_method
);
113 BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter
, flt_query_method
);