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