Fix: lib: add NULL check for destroy_listeners in destroy_component_class
[babeltrace.git] / src / lib / graph / component-class.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-CLASS"
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/graph/component-class.h>
15 #include <babeltrace2/types.h>
16 #include <glib.h>
17
18 #include "component-class.h"
19 #include "lib/func-status.h"
20 #include "lib/graph/message-iterator-class.h"
21
22 #define BT_ASSERT_PRE_DEV_COMP_CLS_HOT(_cc) \
23 BT_ASSERT_PRE_DEV_HOT("component-class", \
24 ((const struct bt_component_class *) (_cc)), \
25 "Component class", ": %!+C", (_cc))
26
27 static
28 void destroy_component_class(struct bt_object *obj)
29 {
30 struct bt_component_class *class;
31 int i;
32
33 BT_ASSERT(obj);
34 class = container_of(obj, struct bt_component_class, base);
35
36 BT_LIB_LOGI("Destroying component class: %!+C", class);
37
38 /* Call destroy listeners in reverse registration order */
39 if (class->destroy_listeners) {
40 for (i = class->destroy_listeners->len - 1; i >= 0; i--) {
41 struct bt_component_class_destroy_listener *listener =
42 &g_array_index(class->destroy_listeners,
43 struct bt_component_class_destroy_listener,
44 i);
45
46 BT_LOGD("Calling destroy listener: func-addr=%p, data-addr=%p",
47 listener->func, listener->data);
48 listener->func(class, listener->data);
49 }
50 }
51
52 if (class->name) {
53 g_string_free(class->name, TRUE);
54 class->name = NULL;
55 }
56
57 if (class->description) {
58 g_string_free(class->description, TRUE);
59 class->description = NULL;
60 }
61
62 if (class->help) {
63 g_string_free(class->help, TRUE);
64 class->help = NULL;
65 }
66
67 if (class->plugin_name) {
68 g_string_free(class->plugin_name, TRUE);
69 class->plugin_name = NULL;
70 }
71
72 if (class->destroy_listeners) {
73 g_array_free(class->destroy_listeners, TRUE);
74 class->destroy_listeners = NULL;
75 }
76
77 if (bt_component_class_has_message_iterator_class(class)) {
78 struct bt_component_class_with_iterator_class *class_with_iter_class =
79 container_of(class, struct bt_component_class_with_iterator_class, parent);
80
81 BT_ASSERT(class_with_iter_class->msg_iter_cls);
82 bt_message_iterator_class_put_ref(class_with_iter_class->msg_iter_cls);
83 class_with_iter_class->msg_iter_cls = NULL;
84 }
85
86 g_free(class);
87 }
88
89 static
90 int bt_component_class_init(struct bt_component_class *class,
91 enum bt_component_class_type type, const char *name)
92 {
93 int ret = 0;
94
95 bt_object_init_shared(&class->base, destroy_component_class);
96 class->type = type;
97 class->name = g_string_new(name);
98 if (!class->name) {
99 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
100 goto error;
101 }
102
103 class->description = g_string_new(NULL);
104 if (!class->description) {
105 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
106 goto error;
107 }
108
109 class->help = g_string_new(NULL);
110 if (!class->help) {
111 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
112 goto error;
113 }
114
115 class->plugin_name = g_string_new(NULL);
116 if (!class->plugin_name) {
117 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
118 goto error;
119 }
120
121 class->destroy_listeners = g_array_new(FALSE, TRUE,
122 sizeof(struct bt_component_class_destroy_listener));
123 if (!class->destroy_listeners) {
124 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
125 goto error;
126 }
127
128 goto end;
129
130 error:
131 BT_OBJECT_PUT_REF_AND_RESET(class);
132 ret = -1;
133
134 end:
135 return ret;
136 }
137
138 static
139 int bt_component_class_with_iterator_class_init(
140 struct bt_component_class_with_iterator_class *class,
141 enum bt_component_class_type type, const char *name,
142 struct bt_message_iterator_class *message_iterator_class)
143 {
144 int ret;
145
146 ret = bt_component_class_init(&class->parent, type, name);
147 if (ret != 0) {
148 goto end;
149 }
150
151 class->msg_iter_cls = message_iterator_class;
152 bt_message_iterator_class_get_ref(class->msg_iter_cls);
153 bt_message_iterator_class_freeze(class->msg_iter_cls);
154
155 end:
156 return ret;
157 }
158
159 struct bt_component_class_source *bt_component_class_source_create(
160 const char *name,
161 struct bt_message_iterator_class *message_iterator_class)
162 {
163 struct bt_component_class_source *source_class = NULL;
164 int ret;
165
166 BT_ASSERT_PRE_NO_ERROR();
167 BT_ASSERT_PRE_NAME_NON_NULL(name);
168 BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(message_iterator_class);
169 BT_LIB_LOGI("Creating source component class: "
170 "name=\"%s\", %![msg-iter-cls-]+I",
171 name, message_iterator_class);
172 source_class = g_new0(struct bt_component_class_source, 1);
173 if (!source_class) {
174 BT_LIB_LOGE_APPEND_CAUSE(
175 "Failed to allocate one source component class.");
176 goto end;
177 }
178
179 /* bt_component_class_init() logs errors */
180 ret = bt_component_class_with_iterator_class_init(&source_class->parent,
181 BT_COMPONENT_CLASS_TYPE_SOURCE, name, message_iterator_class);
182 if (ret) {
183 /*
184 * If bt_component_class_init() fails, the component
185 * class is put, therefore its memory is already
186 * freed.
187 */
188 source_class = NULL;
189 goto end;
190 }
191
192 BT_LIB_LOGI("Created source component class: %!+C", source_class);
193
194 end:
195 return (void *) source_class;
196 }
197
198 struct bt_component_class_filter *bt_component_class_filter_create(
199 const char *name,
200 struct bt_message_iterator_class *message_iterator_class)
201 {
202 struct bt_component_class_filter *filter_class = NULL;
203 int ret;
204
205 BT_ASSERT_PRE_NO_ERROR();
206 BT_ASSERT_PRE_NAME_NON_NULL(name);
207 BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(message_iterator_class);
208 BT_LIB_LOGI("Creating filter component class: "
209 "name=\"%s\", %![msg-iter-cls-]+I",
210 name, message_iterator_class);
211 filter_class = g_new0(struct bt_component_class_filter, 1);
212 if (!filter_class) {
213 BT_LIB_LOGE_APPEND_CAUSE(
214 "Failed to allocate one filter component class.");
215 goto end;
216 }
217
218 /* bt_component_class_init() logs errors */
219 ret = bt_component_class_with_iterator_class_init(&filter_class->parent,
220 BT_COMPONENT_CLASS_TYPE_FILTER, name, message_iterator_class);
221 if (ret) {
222 /*
223 * If bt_component_class_init() fails, the component
224 * class is put, therefore its memory is already
225 * freed.
226 */
227 filter_class = NULL;
228 goto end;
229 }
230
231 BT_LIB_LOGI("Created filter component class: %!+C", filter_class);
232
233 end:
234 return (void *) filter_class;
235 }
236
237 struct bt_component_class_sink *bt_component_class_sink_create(
238 const char *name, bt_component_class_sink_consume_method method)
239 {
240 struct bt_component_class_sink *sink_class = NULL;
241 int ret;
242
243 BT_ASSERT_PRE_NO_ERROR();
244 BT_ASSERT_PRE_NAME_NON_NULL(name);
245 BT_ASSERT_PRE_NON_NULL("consume-method", method, "Consume next method");
246 BT_LOGI("Creating sink component class: "
247 "name=\"%s\", consume-method-addr=%p",
248 name, method);
249 sink_class = g_new0(struct bt_component_class_sink, 1);
250 if (!sink_class) {
251 BT_LIB_LOGE_APPEND_CAUSE(
252 "Failed to allocate one sink component class.");
253 goto end;
254 }
255
256 /* bt_component_class_init() logs errors */
257 ret = bt_component_class_init(&sink_class->parent,
258 BT_COMPONENT_CLASS_TYPE_SINK, name);
259 if (ret) {
260 /*
261 * If bt_component_class_init() fails, the component
262 * class is put, therefore its memory is already
263 * freed.
264 */
265 sink_class = NULL;
266 goto end;
267 }
268
269 sink_class->methods.consume = method;
270 BT_LIB_LOGI("Created sink component class: %!+C", sink_class);
271
272 end:
273 return (void *) sink_class;
274 }
275
276 enum bt_component_class_set_method_status
277 bt_component_class_source_set_get_supported_mip_versions_method(
278 struct bt_component_class_source *comp_cls,
279 bt_component_class_source_get_supported_mip_versions_method method)
280 {
281 BT_ASSERT_PRE_NO_ERROR();
282 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
283 BT_ASSERT_PRE_METHOD_NON_NULL(method);
284 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
285 comp_cls->methods.get_supported_mip_versions = method;
286 BT_LIB_LOGD("Set source component class's \"get supported MIP versions\" method: "
287 "%!+C", comp_cls);
288 return BT_FUNC_STATUS_OK;
289 }
290
291 enum bt_component_class_set_method_status
292 bt_component_class_filter_set_get_supported_mip_versions_method(
293 struct bt_component_class_filter *comp_cls,
294 bt_component_class_filter_get_supported_mip_versions_method method)
295 {
296 BT_ASSERT_PRE_NO_ERROR();
297 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
298 BT_ASSERT_PRE_METHOD_NON_NULL(method);
299 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
300 comp_cls->methods.get_supported_mip_versions = method;
301 BT_LIB_LOGD("Set filter component class's \"get supported MIP versions\" method: "
302 "%!+C", comp_cls);
303 return BT_FUNC_STATUS_OK;
304 }
305
306 enum bt_component_class_set_method_status
307 bt_component_class_sink_set_get_supported_mip_versions_method(
308 struct bt_component_class_sink *comp_cls,
309 bt_component_class_sink_get_supported_mip_versions_method method)
310 {
311 BT_ASSERT_PRE_NO_ERROR();
312 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
313 BT_ASSERT_PRE_METHOD_NON_NULL(method);
314 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
315 comp_cls->methods.get_supported_mip_versions = method;
316 BT_LIB_LOGD("Set sink component class's \"get supported MIP versions\" method: "
317 "%!+C", comp_cls);
318 return BT_FUNC_STATUS_OK;
319 }
320
321 enum bt_component_class_set_method_status
322 bt_component_class_source_set_initialize_method(
323 struct bt_component_class_source *comp_cls,
324 bt_component_class_source_initialize_method method)
325 {
326 BT_ASSERT_PRE_NO_ERROR();
327 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
328 BT_ASSERT_PRE_METHOD_NON_NULL(method);
329 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
330 comp_cls->methods.init = method;
331 BT_LIB_LOGD("Set source component class's initialization method: "
332 "%!+C", comp_cls);
333 return BT_FUNC_STATUS_OK;
334 }
335
336 enum bt_component_class_set_method_status
337 bt_component_class_filter_set_initialize_method(
338 struct bt_component_class_filter *comp_cls,
339 bt_component_class_filter_initialize_method method)
340 {
341 BT_ASSERT_PRE_NO_ERROR();
342 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
343 BT_ASSERT_PRE_METHOD_NON_NULL(method);
344 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
345 comp_cls->methods.init = method;
346 BT_LIB_LOGD("Set filter component class's initialization method: "
347 "%!+C", comp_cls);
348 return BT_FUNC_STATUS_OK;
349 }
350
351 enum bt_component_class_set_method_status
352 bt_component_class_sink_set_initialize_method(
353 struct bt_component_class_sink *comp_cls,
354 bt_component_class_sink_initialize_method method)
355 {
356 BT_ASSERT_PRE_NO_ERROR();
357 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
358 BT_ASSERT_PRE_METHOD_NON_NULL(method);
359 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
360 comp_cls->methods.init = method;
361 BT_LIB_LOGD("Set sink component class's initialization method: "
362 "%!+C", comp_cls);
363 return BT_FUNC_STATUS_OK;
364 }
365
366 enum bt_component_class_set_method_status
367 bt_component_class_source_set_finalize_method(
368 struct bt_component_class_source *comp_cls,
369 bt_component_class_source_finalize_method method)
370 {
371 BT_ASSERT_PRE_NO_ERROR();
372 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
373 BT_ASSERT_PRE_METHOD_NON_NULL(method);
374 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
375 comp_cls->methods.finalize = method;
376 BT_LIB_LOGD("Set source component class's finalization method: "
377 "%!+C", comp_cls);
378 return BT_FUNC_STATUS_OK;
379 }
380
381 enum bt_component_class_set_method_status
382 bt_component_class_filter_set_finalize_method(
383 struct bt_component_class_filter *comp_cls,
384 bt_component_class_filter_finalize_method method)
385 {
386 BT_ASSERT_PRE_NO_ERROR();
387 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
388 BT_ASSERT_PRE_METHOD_NON_NULL(method);
389 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
390 comp_cls->methods.finalize = method;
391 BT_LIB_LOGD("Set filter component class's finalization method: "
392 "%!+C", comp_cls);
393 return BT_FUNC_STATUS_OK;
394 }
395
396 enum bt_component_class_set_method_status
397 bt_component_class_sink_set_finalize_method(
398 struct bt_component_class_sink *comp_cls,
399 bt_component_class_sink_finalize_method method)
400 {
401 BT_ASSERT_PRE_NO_ERROR();
402 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
403 BT_ASSERT_PRE_METHOD_NON_NULL(method);
404 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
405 comp_cls->methods.finalize = method;
406 BT_LIB_LOGD("Set sink component class's finalization method: "
407 "%!+C", comp_cls);
408 return BT_FUNC_STATUS_OK;
409 }
410
411 enum bt_component_class_set_method_status
412 bt_component_class_source_set_query_method(
413 struct bt_component_class_source *comp_cls,
414 bt_component_class_source_query_method method)
415 {
416 BT_ASSERT_PRE_NO_ERROR();
417 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
418 BT_ASSERT_PRE_METHOD_NON_NULL(method);
419 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
420 comp_cls->methods.query = method;
421 BT_LIB_LOGD("Set source component class's query method: "
422 "%!+C", comp_cls);
423 return BT_FUNC_STATUS_OK;
424 }
425
426 enum bt_component_class_set_method_status
427 bt_component_class_filter_set_query_method(
428 struct bt_component_class_filter *comp_cls,
429 bt_component_class_filter_query_method method)
430 {
431 BT_ASSERT_PRE_NO_ERROR();
432 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
433 BT_ASSERT_PRE_METHOD_NON_NULL(method);
434 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
435 comp_cls->methods.query = method;
436 BT_LIB_LOGD("Set filter component class's query method: "
437 "%!+C", comp_cls);
438 return BT_FUNC_STATUS_OK;
439 }
440
441 enum bt_component_class_set_method_status
442 bt_component_class_sink_set_query_method(
443 struct bt_component_class_sink *comp_cls,
444 bt_component_class_sink_query_method method)
445 {
446 BT_ASSERT_PRE_NO_ERROR();
447 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
448 BT_ASSERT_PRE_METHOD_NON_NULL(method);
449 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
450 comp_cls->methods.query = method;
451 BT_LIB_LOGD("Set sink component class's query method: "
452 "%!+C", comp_cls);
453 return BT_FUNC_STATUS_OK;
454 }
455
456 enum bt_component_class_set_method_status
457 bt_component_class_filter_set_input_port_connected_method(
458 struct bt_component_class_filter *comp_cls,
459 bt_component_class_filter_input_port_connected_method method)
460 {
461 BT_ASSERT_PRE_NO_ERROR();
462 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
463 BT_ASSERT_PRE_METHOD_NON_NULL(method);
464 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
465 comp_cls->methods.input_port_connected = method;
466 BT_LIB_LOGD("Set filter component class's \"input port connected\" method"
467 ": %!+C", comp_cls);
468 return BT_FUNC_STATUS_OK;
469 }
470
471 enum bt_component_class_set_method_status
472 bt_component_class_sink_set_input_port_connected_method(
473 struct bt_component_class_sink *comp_cls,
474 bt_component_class_sink_input_port_connected_method method)
475 {
476 BT_ASSERT_PRE_NO_ERROR();
477 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
478 BT_ASSERT_PRE_METHOD_NON_NULL(method);
479 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
480 comp_cls->methods.input_port_connected = method;
481 BT_LIB_LOGD("Set sink component class's \"input port connected\" method"
482 ": %!+C", comp_cls);
483 return BT_FUNC_STATUS_OK;
484 }
485
486 enum bt_component_class_set_method_status
487 bt_component_class_source_set_output_port_connected_method(
488 struct bt_component_class_source *comp_cls,
489 bt_component_class_source_output_port_connected_method method)
490 {
491 BT_ASSERT_PRE_NO_ERROR();
492 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
493 BT_ASSERT_PRE_METHOD_NON_NULL(method);
494 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
495 comp_cls->methods.output_port_connected = method;
496 BT_LIB_LOGD("Set source component class's \"output port connected\" method"
497 ": %!+C", comp_cls);
498 return BT_FUNC_STATUS_OK;
499 }
500
501 enum bt_component_class_set_method_status
502 bt_component_class_filter_set_output_port_connected_method(
503 struct bt_component_class_filter *comp_cls,
504 bt_component_class_filter_output_port_connected_method method)
505 {
506 BT_ASSERT_PRE_NO_ERROR();
507 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
508 BT_ASSERT_PRE_METHOD_NON_NULL(method);
509 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
510 comp_cls->methods.output_port_connected = method;
511 BT_LIB_LOGD("Set filter component class's \"output port connected\" method"
512 ": %!+C", comp_cls);
513 return BT_FUNC_STATUS_OK;
514 }
515
516 enum bt_component_class_set_method_status
517 bt_component_class_sink_set_graph_is_configured_method(
518 struct bt_component_class_sink *comp_cls,
519 bt_component_class_sink_graph_is_configured_method method)
520 {
521 BT_ASSERT_PRE_NO_ERROR();
522 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
523 BT_ASSERT_PRE_METHOD_NON_NULL(method);
524 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
525 comp_cls->methods.graph_is_configured = method;
526 BT_LIB_LOGD("Set sink component class's \"graph is configured\" method"
527 ": %!+C", comp_cls);
528 return BT_FUNC_STATUS_OK;
529 }
530
531 enum bt_component_class_set_description_status
532 bt_component_class_set_description(
533 struct bt_component_class *comp_cls,
534 const char *description)
535 {
536 BT_ASSERT_PRE_NO_ERROR();
537 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
538 BT_ASSERT_PRE_DESCR_NON_NULL(description);
539 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
540 g_string_assign(comp_cls->description, description);
541 BT_LIB_LOGD("Set component class's description: "
542 "addr=%p, name=\"%s\", type=%s",
543 comp_cls,
544 bt_component_class_get_name(comp_cls),
545 bt_common_component_class_type_string(comp_cls->type));
546 return BT_FUNC_STATUS_OK;
547 }
548
549 enum bt_component_class_set_help_status bt_component_class_set_help(
550 struct bt_component_class *comp_cls,
551 const char *help)
552 {
553 BT_ASSERT_PRE_NO_ERROR();
554 BT_ASSERT_PRE_COMP_CLS_NON_NULL(comp_cls);
555 BT_ASSERT_PRE_NON_NULL("help-text", help, "Help text");
556 BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
557 g_string_assign(comp_cls->help, help);
558 BT_LIB_LOGD("Set component class's help text: %!+C", comp_cls);
559 return BT_FUNC_STATUS_OK;
560 }
561
562 const char *bt_component_class_get_name(const struct bt_component_class *comp_cls)
563 {
564 BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(comp_cls);
565 return comp_cls->name->str;
566 }
567
568 enum bt_component_class_type bt_component_class_get_type(
569 const struct bt_component_class *comp_cls)
570 {
571 BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(comp_cls);
572 return comp_cls->type;
573 }
574
575 const char *bt_component_class_get_description(
576 const struct bt_component_class *comp_cls)
577 {
578 BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(comp_cls);
579 return comp_cls->description &&
580 comp_cls->description->str[0] != '\0' ?
581 comp_cls->description->str : NULL;
582 }
583
584 const char *bt_component_class_get_help(
585 const struct bt_component_class *comp_cls)
586 {
587 BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(comp_cls);
588 return comp_cls->help &&
589 comp_cls->help->str[0] != '\0' ? comp_cls->help->str : NULL;
590 }
591
592 BT_HIDDEN
593 void bt_component_class_add_destroy_listener(
594 struct bt_component_class *comp_cls,
595 bt_component_class_destroy_listener_func func, void *data)
596 {
597 struct bt_component_class_destroy_listener listener;
598
599 BT_ASSERT(comp_cls);
600 BT_ASSERT(func);
601 listener.func = func;
602 listener.data = data;
603 g_array_append_val(comp_cls->destroy_listeners, listener);
604 BT_LIB_LOGD("Added destroy listener to component class: "
605 "%![cc-]+C, listener-func-addr=%p", comp_cls, func);
606 }
607
608 BT_HIDDEN
609 void _bt_component_class_freeze(const struct bt_component_class *comp_cls)
610 {
611 BT_ASSERT(comp_cls);
612 BT_LIB_LOGD("Freezing component class: %!+C", comp_cls);
613 ((struct bt_component_class *) comp_cls)->frozen = true;
614 }
615
616 void bt_component_class_get_ref(
617 const struct bt_component_class *component_class)
618 {
619 bt_object_get_ref(component_class);
620 }
621
622 void bt_component_class_put_ref(
623 const struct bt_component_class *component_class)
624 {
625 bt_object_put_ref(component_class);
626 }
627
628 void bt_component_class_source_get_ref(
629 const struct bt_component_class_source *component_class_source)
630 {
631 bt_object_get_ref(component_class_source);
632 }
633
634 void bt_component_class_source_put_ref(
635 const struct bt_component_class_source *component_class_source)
636 {
637 bt_object_put_ref(component_class_source);
638 }
639
640 void bt_component_class_filter_get_ref(
641 const struct bt_component_class_filter *component_class_filter)
642 {
643 bt_object_get_ref(component_class_filter);
644 }
645
646 void bt_component_class_filter_put_ref(
647 const struct bt_component_class_filter *component_class_filter)
648 {
649 bt_object_put_ref(component_class_filter);
650 }
651
652 void bt_component_class_sink_get_ref(
653 const struct bt_component_class_sink *component_class_sink)
654 {
655 bt_object_get_ref(component_class_sink);
656 }
657
658 void bt_component_class_sink_put_ref(
659 const struct bt_component_class_sink *component_class_sink)
660 {
661 bt_object_put_ref(component_class_sink);
662 }
This page took 0.043233 seconds and 5 git commands to generate.