configure: re-enable '-Wunused-parameter'
[babeltrace.git] / src / lib / graph / component-sink.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8 #define BT_LOG_TAG "LIB/COMPONENT-SINK"
9 #include "lib/logging.h"
10
11 #include "common/assert.h"
12 #include "lib/assert-cond.h"
13 #include "compat/compiler.h"
14 #include <babeltrace2/value.h>
15 #include <babeltrace2/graph/self-component.h>
16 #include <babeltrace2/graph/component.h>
17 #include <babeltrace2/graph/graph.h>
18
19 #include "component-sink.h"
20 #include "component.h"
21 #include "graph.h"
22 #include "lib/func-status.h"
23
24 void bt_component_sink_destroy(
25 struct bt_component *component __attribute__((unused)))
26 {
27 }
28
29 struct bt_component *bt_component_sink_create(
30 const struct bt_component_class *class __attribute__((unused)))
31 {
32 struct bt_component_sink *sink = NULL;
33
34 sink = g_new0(struct bt_component_sink, 1);
35 if (!sink) {
36 BT_LIB_LOGE_APPEND_CAUSE(
37 "Failed to allocate one sink component.");
38 goto end;
39 }
40
41 end:
42 return (void *) sink;
43 }
44
45 BT_EXPORT
46 const bt_component_class_sink *
47 bt_component_sink_borrow_class_const(
48 const bt_component_sink *component)
49 {
50 struct bt_component_class *cls;
51
52 BT_ASSERT_PRE_DEV_COMP_NON_NULL(component);
53
54 cls = component->parent.class;
55
56 BT_ASSERT_DBG(cls);
57 BT_ASSERT_DBG(cls->type == BT_COMPONENT_CLASS_TYPE_SINK);
58
59 return (bt_component_class_sink *) cls;
60 }
61
62 BT_EXPORT
63 uint64_t bt_component_sink_get_input_port_count(
64 const struct bt_component_sink *component)
65 {
66 /* bt_component_get_input_port_count() checks preconditions */
67 return bt_component_get_input_port_count((void *) component, __func__);
68 }
69
70 BT_EXPORT
71 const struct bt_port_input *
72 bt_component_sink_borrow_input_port_by_name_const(
73 const struct bt_component_sink *component, const char *name)
74 {
75 /*
76 * bt_component_borrow_input_port_by_name() logs details/errors
77 * and checks preconditions.
78 */
79 return bt_component_borrow_input_port_by_name((void *) component, name,
80 __func__);
81 }
82
83 BT_EXPORT
84 struct bt_self_component_port_input *
85 bt_self_component_sink_borrow_input_port_by_name(
86 struct bt_self_component_sink *component, const char *name)
87 {
88 /*
89 * bt_component_borrow_input_port_by_name() logs details/errors
90 * and checks preconditions.
91 */
92 return (void *) bt_component_borrow_input_port_by_name(
93 (void *) component, name, __func__);
94 }
95
96 BT_EXPORT
97 const struct bt_port_input *bt_component_sink_borrow_input_port_by_index_const(
98 const struct bt_component_sink *component, uint64_t index)
99 {
100 /*
101 * bt_component_borrow_input_port_by_index() logs details/errors
102 * and checks preconditions.
103 */
104 return bt_component_borrow_input_port_by_index(
105 (void *) component, index, __func__);
106 }
107
108 BT_EXPORT
109 struct bt_self_component_port_input *
110 bt_self_component_sink_borrow_input_port_by_index(
111 struct bt_self_component_sink *component, uint64_t index)
112 {
113 /*
114 * bt_component_borrow_input_port_by_index() logs details/errors
115 * and checks preconditions.
116 */
117 return (void *) bt_component_borrow_input_port_by_index(
118 (void *) component, index, __func__);
119 }
120
121 BT_EXPORT
122 enum bt_self_component_add_port_status bt_self_component_sink_add_input_port(
123 struct bt_self_component_sink *self_comp,
124 const char *name, void *user_data,
125 struct bt_self_component_port_input **self_port)
126 {
127 enum bt_self_component_add_port_status status;
128 struct bt_port *port = NULL;
129 struct bt_component *comp = (void *) self_comp;
130
131 /*
132 * bt_component_add_input_port() logs details/errors and checks
133 * preconditions.
134 */
135 status = bt_component_add_input_port(comp, name, user_data, &port,
136 __func__);
137 if (status != BT_FUNC_STATUS_OK) {
138 goto end;
139 }
140
141 if (self_port) {
142 /* Move reference to user */
143 *self_port = (void *) port;
144 }
145
146 end:
147 bt_object_put_ref(port);
148 return status;
149 }
150
151 BT_EXPORT
152 bt_bool bt_self_component_sink_is_interrupted(
153 const struct bt_self_component_sink *self_comp)
154 {
155 struct bt_component *comp = (void *) self_comp;
156
157 BT_ASSERT_PRE_COMP_NON_NULL(comp);
158 return (bt_bool) bt_graph_is_interrupted(
159 bt_component_borrow_graph(comp));
160 }
161
162 BT_EXPORT
163 void bt_component_sink_get_ref(
164 const struct bt_component_sink *component_sink)
165 {
166 bt_object_get_ref(component_sink);
167 }
168
169 BT_EXPORT
170 void bt_component_sink_put_ref(
171 const struct bt_component_sink *component_sink)
172 {
173 bt_object_put_ref(component_sink);
174 }
This page took 0.034893 seconds and 4 git commands to generate.