Move enum bt_component_type to component.h
[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
18#include <babeltrace/plugin/plugin-dev.h>
19#include <babeltrace/component/component.h>
20
21static int sink_value = 42;
22
23static enum bt_component_status sink_run(struct bt_component *component)
24{
25 return BT_COMPONENT_STATUS_OK;
26}
27
28static enum bt_component_status comp_class_sink_init(
29 struct bt_component *component, struct bt_value *params)
30{
31 enum bt_component_status ret;
32
33 ret = bt_component_set_private_data(component, &sink_value);
34 if (ret != BT_COMPONENT_STATUS_OK) {
35 return BT_COMPONENT_STATUS_ERROR;
36 }
37
38 ret = bt_component_sink_set_consume_cb(component, sink_run);
39 if (ret != BT_COMPONENT_STATUS_OK) {
40 return BT_COMPONENT_STATUS_ERROR;
41 }
42
43 return BT_COMPONENT_STATUS_OK;
44}
45
46static enum bt_component_status comp_class_dummy_init(
47 struct bt_component *component, struct bt_value *params)
48{
49 return BT_COMPONENT_STATUS_OK;
50}
51
6ba0b073 52BT_PLUGIN(test_sfs);
cbb9e0b1
PP
53BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
54BT_PLUGIN_AUTHOR("Janine Sutto");
55BT_PLUGIN_LICENSE("Beerware");
56
6ba0b073
PP
57BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_SOURCE, source, comp_class_dummy_init);
58BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_SOURCE, source, "A source.");
59
60BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_SINK, sink, comp_class_sink_init);
61BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_SINK, sink, "A sink.");
62
63BT_PLUGIN_COMPONENT_CLASS(BT_COMPONENT_TYPE_FILTER, filter, comp_class_dummy_init);
64BT_PLUGIN_COMPONENT_CLASS_DESCRIPTION(BT_COMPONENT_TYPE_FILTER, filter, "A filter.");
This page took 0.024904 seconds and 4 git commands to generate.