configure: re-enable '-Wunused-parameter'
[babeltrace.git] / src / lib / graph / component-filter.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8 #define BT_LOG_TAG "LIB/COMPONENT-FILTER"
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-filter.h"
20 #include "component.h"
21 #include "component-class.h"
22 #include "lib/func-status.h"
23
24 void bt_component_filter_destroy(
25 struct bt_component *component __attribute__((unused)))
26 {
27 }
28
29 struct bt_component *bt_component_filter_create(
30 const struct bt_component_class *class __attribute__((unused)))
31 {
32 struct bt_component_filter *filter = NULL;
33
34 filter = g_new0(struct bt_component_filter, 1);
35 if (!filter) {
36 BT_LIB_LOGE_APPEND_CAUSE(
37 "Failed to allocate one filter component.");
38 goto end;
39 }
40
41 end:
42 return (void *) filter;
43 }
44
45 BT_EXPORT
46 const bt_component_class_filter *
47 bt_component_filter_borrow_class_const(
48 const bt_component_filter *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_FILTER);
58
59 return (bt_component_class_filter *) cls;
60 }
61
62 BT_EXPORT
63 uint64_t bt_component_filter_get_output_port_count(
64 const struct bt_component_filter *comp)
65 {
66 /* bt_component_get_output_port_count() checks preconditions */
67 return bt_component_get_output_port_count((void *) comp, __func__);
68 }
69
70 BT_EXPORT
71 const struct bt_port_output *
72 bt_component_filter_borrow_output_port_by_name_const(
73 const struct bt_component_filter *comp, const char *name)
74 {
75 /*
76 * bt_component_borrow_output_port_by_name() logs details/errors
77 * and checks preconditions.
78 */
79 return bt_component_borrow_output_port_by_name(
80 (void *) comp, name, __func__);
81 }
82
83 BT_EXPORT
84 struct bt_self_component_port_output *
85 bt_self_component_filter_borrow_output_port_by_name(
86 struct bt_self_component_filter *comp, const char *name)
87 {
88 /*
89 * bt_component_borrow_output_port_by_name() logs details/errors
90 * and checks preconditions.
91 */
92 return (void *) bt_component_borrow_output_port_by_name(
93 (void *) comp, name, __func__);
94 }
95
96 BT_EXPORT
97 const struct bt_port_output *
98 bt_component_filter_borrow_output_port_by_index_const(
99 const struct bt_component_filter *comp, uint64_t index)
100 {
101 /*
102 * bt_component_borrow_output_port_by_index() logs
103 * details/errors and checks preconditions.
104 */
105 return bt_component_borrow_output_port_by_index(
106 (void *) comp, index, __func__);
107 }
108
109 BT_EXPORT
110 struct bt_self_component_port_output *
111 bt_self_component_filter_borrow_output_port_by_index(
112 struct bt_self_component_filter *comp, uint64_t index)
113 {
114 /*
115 * bt_component_borrow_output_port_by_index() logs
116 * details/errors and checks preconditions.
117 */
118 return (void *) bt_component_borrow_output_port_by_index(
119 (void *) comp, index, __func__);
120 }
121
122 BT_EXPORT
123 enum bt_self_component_add_port_status bt_self_component_filter_add_output_port(
124 struct bt_self_component_filter *self_comp,
125 const char *name, void *user_data,
126 struct bt_self_component_port_output **self_port)
127 {
128 struct bt_component *comp = (void *) self_comp;
129 enum bt_self_component_add_port_status status;
130 struct bt_port *port = NULL;
131
132 /*
133 * bt_component_add_output_port() logs details/errors and checks
134 * preconditions.
135 */
136 status = bt_component_add_output_port(comp, name, user_data, &port,
137 __func__);
138 if (status != BT_FUNC_STATUS_OK) {
139 goto end;
140 }
141
142 if (self_port) {
143 /* Move reference to user */
144 *self_port = (void *) port;
145 }
146
147 end:
148 bt_object_put_ref(port);
149 return status;
150 }
151
152 BT_EXPORT
153 uint64_t bt_component_filter_get_input_port_count(
154 const struct bt_component_filter *component)
155 {
156 /* bt_component_get_input_port_count() checks preconditions */
157 return bt_component_get_input_port_count((void *) component, __func__);
158 }
159
160 BT_EXPORT
161 const struct bt_port_input *bt_component_filter_borrow_input_port_by_name_const(
162 const struct bt_component_filter *component, const char *name)
163 {
164 /*
165 * bt_component_borrow_input_port_by_name() logs details/errors
166 * and checks preconditions.
167 */
168 return bt_component_borrow_input_port_by_name(
169 (void *) component, name, __func__);
170 }
171
172 BT_EXPORT
173 struct bt_self_component_port_input *
174 bt_self_component_filter_borrow_input_port_by_name(
175 struct bt_self_component_filter *component, const char *name)
176 {
177 /*
178 * bt_component_borrow_input_port_by_name() logs details/errors
179 * and checks preconditions.
180 */
181 return (void *) bt_component_borrow_input_port_by_name(
182 (void *) component, name, __func__);
183 }
184
185 BT_EXPORT
186 const struct bt_port_input *
187 bt_component_filter_borrow_input_port_by_index_const(
188 const struct bt_component_filter *component, uint64_t index)
189 {
190 /*
191 * bt_component_borrow_input_port_by_index() logs details/errors
192 * and checks preconditions.
193 */
194 return bt_component_borrow_input_port_by_index(
195 (void *) component, index, __func__);
196 }
197
198 BT_EXPORT
199 struct bt_self_component_port_input *
200 bt_self_component_filter_borrow_input_port_by_index(
201 struct bt_self_component_filter *component, uint64_t index)
202 {
203 /*
204 * bt_component_borrow_input_port_by_index() logs details/errors
205 * and checks preconditions.
206 */
207 return (void *) bt_component_borrow_input_port_by_index(
208 (void *) component, index, __func__);
209 }
210
211 BT_EXPORT
212 enum bt_self_component_add_port_status bt_self_component_filter_add_input_port(
213 struct bt_self_component_filter *self_comp,
214 const char *name, void *user_data,
215 struct bt_self_component_port_input **self_port)
216 {
217 enum bt_self_component_add_port_status status;
218 struct bt_port *port = NULL;
219 struct bt_component *comp = (void *) self_comp;
220
221 /*
222 * bt_component_add_input_port() logs details/errors and checks
223 * preconditions.
224 */
225 status = bt_component_add_input_port(comp, name, user_data, &port,
226 __func__);
227 if (status != BT_FUNC_STATUS_OK) {
228 goto end;
229 }
230
231 if (self_port) {
232 /* Move reference to user */
233 *self_port = (void *) port;
234 }
235
236 end:
237 bt_object_put_ref(port);
238 return status;
239 }
240
241 BT_EXPORT
242 void bt_component_filter_get_ref(
243 const struct bt_component_filter *component_filter)
244 {
245 bt_object_get_ref(component_filter);
246 }
247
248 BT_EXPORT
249 void bt_component_filter_put_ref(
250 const struct bt_component_filter *component_filter)
251 {
252 bt_object_put_ref(component_filter);
253 }
This page took 0.051891 seconds and 4 git commands to generate.