Commit | Line | Data |
---|---|---|
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 | ||
3fadfbc0 | 18 | #include <babeltrace2/babeltrace.h> |
578e048b | 19 | #include "common/assert.h" |
cbb9e0b1 | 20 | |
d24d5663 | 21 | static bt_component_class_sink_consume_method_status sink_consume( |
b19ff26f | 22 | bt_self_component_sink *self_comp) |
cbb9e0b1 | 23 | { |
d24d5663 | 24 | return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; |
cbb9e0b1 PP |
25 | } |
26 | ||
a3f0c7db | 27 | static bt_message_iterator_class_initialize_method_status |
d24d5663 | 28 | src_dummy_iterator_init_method( |
d6e69534 | 29 | bt_self_message_iterator *self_msg_iter, |
8d8b141d | 30 | bt_self_message_iterator_configuration *config, |
b19ff26f | 31 | bt_self_component_port_output *self_port) |
cbb9e0b1 | 32 | { |
a3f0c7db | 33 | return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; |
d94d92ac PP |
34 | } |
35 | ||
a3f0c7db | 36 | static bt_message_iterator_class_initialize_method_status |
d24d5663 | 37 | flt_dummy_iterator_init_method( |
d6e69534 | 38 | bt_self_message_iterator *self_msg_iter, |
8d8b141d | 39 | bt_self_message_iterator_configuration *config, |
b19ff26f | 40 | bt_self_component_port_output *self_port) |
d94d92ac | 41 | { |
a3f0c7db | 42 | return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; |
d3eb6e8f PP |
43 | } |
44 | ||
64cadc66 | 45 | static void dummy_iterator_finalize_method( |
d6e69534 | 46 | bt_self_message_iterator *self_msg_iter) |
d3eb6e8f PP |
47 | { |
48 | } | |
49 | ||
a3f0c7db | 50 | static bt_message_iterator_class_next_method_status |
d24d5663 | 51 | dummy_iterator_next_method( |
d6e69534 PP |
52 | bt_self_message_iterator *self_msg_iter, |
53 | bt_message_array_const msgs, uint64_t capacity, | |
d4393e08 | 54 | uint64_t *count) |
d3eb6e8f | 55 | { |
a3f0c7db | 56 | return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; |
d3eb6e8f PP |
57 | } |
58 | ||
d24d5663 | 59 | static bt_component_class_query_method_status flt_query_method( |
b19ff26f | 60 | bt_self_component_class_filter *component_class, |
3c729b9a | 61 | bt_private_query_executor *priv_query_exec, |
b19ff26f | 62 | const char *object, const bt_value *params, |
7c14d641 | 63 | __attribute__((unused)) void *method_data, |
b19ff26f | 64 | const bt_value **result) |
5933c0f2 | 65 | { |
b19ff26f PP |
66 | bt_value *res = bt_value_array_create(); |
67 | bt_value *val; | |
05e21286 | 68 | *result = res; |
c7eee084 | 69 | int iret; |
5933c0f2 | 70 | |
d94d92ac | 71 | BT_ASSERT(*result); |
05e21286 PP |
72 | iret = bt_value_array_append_string_element(res, object); |
73 | BT_ASSERT(iret == 0); | |
6be5a99e | 74 | iret = bt_value_copy(params, &val); |
25583cd0 | 75 | BT_ASSERT(iret == 0); |
05e21286 | 76 | iret = bt_value_array_append_element(res, val); |
25583cd0 | 77 | BT_ASSERT(iret == 0); |
c5b9b441 | 78 | bt_value_put_ref(val); |
d24d5663 | 79 | return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK; |
5933c0f2 PP |
80 | } |
81 | ||
df5b5d01 | 82 | BT_PLUGIN_MODULE(); |
6ba0b073 | 83 | BT_PLUGIN(test_sfs); |
cbb9e0b1 PP |
84 | BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes"); |
85 | BT_PLUGIN_AUTHOR("Janine Sutto"); | |
86 | BT_PLUGIN_LICENSE("Beerware"); | |
458e8e1d | 87 | BT_PLUGIN_VERSION(1, 2, 3, "yes"); |
cbb9e0b1 | 88 | |
41a2b7ae | 89 | BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method); |
d3e4dcd8 | 90 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source."); |
8e1fe2a4 | 91 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(source, |
d94d92ac | 92 | src_dummy_iterator_init_method); |
8e1fe2a4 | 93 | BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(source, |
64cadc66 | 94 | dummy_iterator_finalize_method); |
6ba0b073 | 95 | |
d3e4dcd8 PP |
96 | BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume); |
97 | BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink."); | |
a889b89f PP |
98 | BT_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 | ); | |
6ba0b073 | 104 | |
41a2b7ae | 105 | BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method); |
d3e4dcd8 | 106 | BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter."); |
8e1fe2a4 | 107 | BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(filter, |
d94d92ac | 108 | flt_dummy_iterator_init_method); |
8e1fe2a4 | 109 | BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(filter, |
64cadc66 | 110 | dummy_iterator_finalize_method); |
d94d92ac | 111 | BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method); |