4 * Babeltrace Plugin Component Class
6 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #define BT_LOG_TAG "COMP-CLASS"
30 #include <babeltrace/lib-logging-internal.h>
32 #include <babeltrace/compiler-internal.h>
33 #include <babeltrace/graph/component-class-internal.h>
34 #include <babeltrace/ref.h>
35 #include <babeltrace/types.h>
39 void bt_component_class_destroy(struct bt_object
*obj
)
41 struct bt_component_class
*class;
45 class = container_of(obj
, struct bt_component_class
, base
);
47 BT_LOGD("Destroying component class: "
48 "addr=%p, name=\"%s\", type=%s",
49 class, bt_component_class_get_name(class),
50 bt_component_class_type_string(class->type
));
52 /* Call destroy listeners in reverse registration order */
53 for (i
= class->destroy_listeners
->len
- 1; i
>= 0; i
--) {
54 struct bt_component_class_destroy_listener
*listener
=
55 &g_array_index(class->destroy_listeners
,
56 struct bt_component_class_destroy_listener
,
59 BT_LOGD("Calling destroy listener: func-addr=%p, data-addr=%p",
60 listener
->func
, listener
->data
);
61 listener
->func(class, listener
->data
);
65 g_string_free(class->name
, TRUE
);
67 if (class->description
) {
68 g_string_free(class->description
, TRUE
);
71 g_string_free(class->help
, TRUE
);
73 if (class->destroy_listeners
) {
74 g_array_free(class->destroy_listeners
, TRUE
);
81 int bt_component_class_init(struct bt_component_class
*class,
82 enum bt_component_class_type type
, const char *name
)
86 bt_object_init(class, bt_component_class_destroy
);
88 class->name
= g_string_new(name
);
90 BT_LOGE_STR("Failed to allocate a GString.");
94 class->description
= g_string_new(NULL
);
95 if (!class->description
) {
96 BT_LOGE_STR("Failed to allocate a GString.");
100 class->help
= g_string_new(NULL
);
102 BT_LOGE_STR("Failed to allocate a GString.");
106 class->destroy_listeners
= g_array_new(FALSE
, TRUE
,
107 sizeof(struct bt_component_class_destroy_listener
));
108 if (!class->destroy_listeners
) {
109 BT_LOGE_STR("Failed to allocate a GArray.");
123 struct bt_component_class
*bt_component_class_source_create(const char *name
,
124 bt_component_class_notification_iterator_next_method notification_iterator_next_method
)
126 struct bt_component_class_source
*source_class
= NULL
;
130 BT_LOGW_STR("Invalid parameter: name is NULL.");
134 if (!notification_iterator_next_method
) {
135 BT_LOGW_STR("Invalid parameter: method is NULL.");
139 BT_LOGD("Creating source component class: "
140 "name=\"%s\", notif-iter-next-method-addr=%p",
141 name
, notification_iterator_next_method
);
142 source_class
= g_new0(struct bt_component_class_source
, 1);
144 BT_LOGE_STR("Failed to allocate one source component class.");
148 /* bt_component_class_init() logs errors */
149 ret
= bt_component_class_init(&source_class
->parent
,
150 BT_COMPONENT_CLASS_TYPE_SOURCE
, name
);
153 * If bt_component_class_init() fails, the component
154 * class is put, therefore its memory is already
161 source_class
->methods
.iterator
.next
= notification_iterator_next_method
;
162 BT_LOGD("Created source component class: "
163 "name=\"%s\", notif-iter-next-method-addr=%p, addr=%p",
164 name
, notification_iterator_next_method
, &source_class
->parent
);
167 return &source_class
->parent
;
170 struct bt_component_class
*bt_component_class_filter_create(const char *name
,
171 bt_component_class_notification_iterator_next_method notification_iterator_next_method
)
173 struct bt_component_class_filter
*filter_class
= NULL
;
177 BT_LOGW_STR("Invalid parameter: name is NULL.");
181 if (!notification_iterator_next_method
) {
182 BT_LOGW_STR("Invalid parameter: method is NULL.");
186 BT_LOGD("Creating filter component class: "
187 "name=\"%s\", notif-iter-next-method-addr=%p",
188 name
, notification_iterator_next_method
);
189 filter_class
= g_new0(struct bt_component_class_filter
, 1);
191 BT_LOGE_STR("Failed to allocate one filter component class.");
195 /* bt_component_class_init() logs errors */
196 ret
= bt_component_class_init(&filter_class
->parent
,
197 BT_COMPONENT_CLASS_TYPE_FILTER
, name
);
200 * If bt_component_class_init() fails, the component
201 * class is put, therefore its memory is already
208 filter_class
->methods
.iterator
.next
= notification_iterator_next_method
;
209 BT_LOGD("Created filter component class: "
210 "name=\"%s\", notif-iter-next-method-addr=%p, addr=%p",
211 name
, notification_iterator_next_method
, &filter_class
->parent
);
214 return &filter_class
->parent
;
217 struct bt_component_class
*bt_component_class_sink_create(const char *name
,
218 bt_component_class_sink_consume_method consume_method
)
220 struct bt_component_class_sink
*sink_class
= NULL
;
224 BT_LOGW_STR("Invalid parameter: name is NULL.");
228 if (!consume_method
) {
229 BT_LOGW_STR("Invalid parameter: method is NULL.");
233 BT_LOGD("Creating sink component class: "
234 "name=\"%s\", consume-method-addr=%p",
235 name
, consume_method
);
236 sink_class
= g_new0(struct bt_component_class_sink
, 1);
238 BT_LOGE_STR("Failed to allocate one sink component class.");
242 /* bt_component_class_init() logs errors */
243 ret
= bt_component_class_init(&sink_class
->parent
,
244 BT_COMPONENT_CLASS_TYPE_SINK
, name
);
247 * If bt_component_class_init() fails, the component
248 * class is put, therefore its memory is already
255 sink_class
->methods
.consume
= consume_method
;
256 BT_LOGD("Created sink component class: "
257 "name=\"%s\", consume-method-addr=%p, addr=%p",
258 name
, consume_method
, &sink_class
->parent
);
261 return &sink_class
->parent
;
264 int bt_component_class_set_init_method(
265 struct bt_component_class
*component_class
,
266 bt_component_class_init_method init_method
)
270 if (!component_class
) {
271 BT_LOGW_STR("Invalid parameter: component class is NULL.");
277 BT_LOGW_STR("Invalid parameter: method is NULL.");
282 if (component_class
->frozen
) {
283 BT_LOGW("Invalid parameter: component class is frozen: "
284 "addr=%p, name=\"%s\", type=%s",
286 bt_component_class_get_name(component_class
),
287 bt_component_class_type_string(component_class
->type
));
292 component_class
->methods
.init
= init_method
;
293 BT_LOGV("Set component class's initialization method: "
294 "addr=%p, name=\"%s\", type=%s, method-addr=%p",
296 bt_component_class_get_name(component_class
),
297 bt_component_class_type_string(component_class
->type
),
304 int bt_component_class_set_query_method(
305 struct bt_component_class
*component_class
,
306 bt_component_class_query_method query_method
)
310 if (!component_class
) {
311 BT_LOGW_STR("Invalid parameter: component class is NULL.");
317 BT_LOGW_STR("Invalid parameter: method is NULL.");
322 if (component_class
->frozen
) {
323 BT_LOGW("Invalid parameter: component class is frozen: "
324 "addr=%p, name=\"%s\", type=%s",
326 bt_component_class_get_name(component_class
),
327 bt_component_class_type_string(component_class
->type
));
332 component_class
->methods
.query
= query_method
;
333 BT_LOGV("Set component class's query method: "
334 "addr=%p, name=\"%s\", type=%s, method-addr=%p",
336 bt_component_class_get_name(component_class
),
337 bt_component_class_type_string(component_class
->type
),
344 int bt_component_class_set_accept_port_connection_method(
345 struct bt_component_class
*component_class
,
346 bt_component_class_accept_port_connection_method method
)
350 if (!component_class
) {
351 BT_LOGW_STR("Invalid parameter: component class is NULL.");
357 BT_LOGW_STR("Invalid parameter: method is NULL.");
362 if (component_class
->frozen
) {
363 BT_LOGW("Invalid parameter: component class is frozen: "
364 "addr=%p, name=\"%s\", type=%s",
366 bt_component_class_get_name(component_class
),
367 bt_component_class_type_string(component_class
->type
));
372 component_class
->methods
.accept_port_connection
= method
;
373 BT_LOGV("Set component class's \"accept port connection\" method: "
374 "addr=%p, name=\"%s\", type=%s, method-addr=%p",
376 bt_component_class_get_name(component_class
),
377 bt_component_class_type_string(component_class
->type
),
384 int bt_component_class_set_port_connected_method(
385 struct bt_component_class
*component_class
,
386 bt_component_class_port_connected_method method
)
390 if (!component_class
) {
391 BT_LOGW_STR("Invalid parameter: component class is NULL.");
397 BT_LOGW_STR("Invalid parameter: method is NULL.");
402 if (component_class
->frozen
) {
403 BT_LOGW("Invalid parameter: component class is frozen: "
404 "addr=%p, name=\"%s\", type=%s",
406 bt_component_class_get_name(component_class
),
407 bt_component_class_type_string(component_class
->type
));
412 component_class
->methods
.port_connected
= method
;
413 BT_LOGV("Set component class's \"port connected\" method: "
414 "addr=%p, name=\"%s\", type=%s, method-addr=%p",
416 bt_component_class_get_name(component_class
),
417 bt_component_class_type_string(component_class
->type
),
424 int bt_component_class_set_port_disconnected_method(
425 struct bt_component_class
*component_class
,
426 bt_component_class_port_disconnected_method method
)
430 if (!component_class
) {
431 BT_LOGW_STR("Invalid parameter: component class is NULL.");
437 BT_LOGW_STR("Invalid parameter: method is NULL.");
442 if (component_class
->frozen
) {
443 BT_LOGW("Invalid parameter: component class is frozen: "
444 "addr=%p, name=\"%s\", type=%s",
446 bt_component_class_get_name(component_class
),
447 bt_component_class_type_string(component_class
->type
));
452 component_class
->methods
.port_disconnected
= method
;
453 BT_LOGV("Set component class's \"port disconnected\" method: "
454 "addr=%p, name=\"%s\", type=%s, method-addr=%p",
456 bt_component_class_get_name(component_class
),
457 bt_component_class_type_string(component_class
->type
),
464 int bt_component_class_set_finalize_method(
465 struct bt_component_class
*component_class
,
466 bt_component_class_finalize_method finalize_method
)
470 if (!component_class
) {
471 BT_LOGW_STR("Invalid parameter: component class is NULL.");
476 if (!finalize_method
) {
477 BT_LOGW_STR("Invalid parameter: method is NULL.");
482 if (component_class
->frozen
) {
483 BT_LOGW("Invalid parameter: component class is frozen: "
484 "addr=%p, name=\"%s\", type=%s",
486 bt_component_class_get_name(component_class
),
487 bt_component_class_type_string(component_class
->type
));
492 component_class
->methods
.finalize
= finalize_method
;
493 BT_LOGV("Set component class's finalization method: "
494 "addr=%p, name=\"%s\", type=%s, method-addr=%p",
496 bt_component_class_get_name(component_class
),
497 bt_component_class_type_string(component_class
->type
),
504 int bt_component_class_source_set_notification_iterator_init_method(
505 struct bt_component_class
*component_class
,
506 bt_component_class_notification_iterator_init_method notification_iterator_init_method
)
508 struct bt_component_class_source
*source_class
;
511 if (!component_class
) {
512 BT_LOGW_STR("Invalid parameter: component class is NULL.");
517 if (!notification_iterator_init_method
) {
518 BT_LOGW_STR("Invalid parameter: method is NULL.");
523 if (component_class
->type
!= BT_COMPONENT_CLASS_TYPE_SOURCE
) {
524 BT_LOGW("Invalid parameter: component class is not a source component class: "
525 "addr=%p, name=\"%s\", type=%s",
527 bt_component_class_get_name(component_class
),
528 bt_component_class_type_string(component_class
->type
));
533 if (component_class
->frozen
) {
534 BT_LOGW("Invalid parameter: component class is frozen: "
535 "addr=%p, name=\"%s\", type=%s",
537 bt_component_class_get_name(component_class
),
538 bt_component_class_type_string(component_class
->type
));
543 source_class
= container_of(component_class
,
544 struct bt_component_class_source
, parent
);
545 source_class
->methods
.iterator
.init
= notification_iterator_init_method
;
546 BT_LOGV("Set filter component class's notification iterator initialization method: "
547 "addr=%p, name=\"%s\", method-addr=%p",
549 bt_component_class_get_name(component_class
),
550 notification_iterator_init_method
);
556 int bt_component_class_source_set_notification_iterator_finalize_method(
557 struct bt_component_class
*component_class
,
558 bt_component_class_notification_iterator_finalize_method notification_iterator_finalize_method
)
560 struct bt_component_class_source
*source_class
;
563 if (!component_class
) {
564 BT_LOGW_STR("Invalid parameter: component class is NULL.");
569 if (!notification_iterator_finalize_method
) {
570 BT_LOGW_STR("Invalid parameter: method is NULL.");
575 if (component_class
->type
!= BT_COMPONENT_CLASS_TYPE_SOURCE
) {
576 BT_LOGW("Invalid parameter: component class is not a source component class: "
577 "addr=%p, name=\"%s\", type=%s",
579 bt_component_class_get_name(component_class
),
580 bt_component_class_type_string(component_class
->type
));
585 if (component_class
->frozen
) {
586 BT_LOGW("Invalid parameter: component class is frozen: "
587 "addr=%p, name=\"%s\", type=%s",
589 bt_component_class_get_name(component_class
),
590 bt_component_class_type_string(component_class
->type
));
595 source_class
= container_of(component_class
,
596 struct bt_component_class_source
, parent
);
597 source_class
->methods
.iterator
.finalize
=
598 notification_iterator_finalize_method
;
599 BT_LOGV("Set filter component class's notification iterator finalization method: "
600 "addr=%p, name=\"%s\", method-addr=%p",
602 bt_component_class_get_name(component_class
),
603 notification_iterator_finalize_method
);
609 int bt_component_class_source_set_notification_iterator_seek_time_method(
610 struct bt_component_class
*component_class
,
611 bt_component_class_notification_iterator_seek_time_method notification_iterator_seek_time_method
)
613 struct bt_component_class_source
*source_class
;
616 if (!component_class
) {
617 BT_LOGW_STR("Invalid parameter: component class is NULL.");
622 if (!notification_iterator_seek_time_method
) {
623 BT_LOGW_STR("Invalid parameter: method is NULL.");
628 if (component_class
->type
!= BT_COMPONENT_CLASS_TYPE_SOURCE
) {
629 BT_LOGW("Invalid parameter: component class is not a source component class: "
630 "addr=%p, name=\"%s\", type=%s",
632 bt_component_class_get_name(component_class
),
633 bt_component_class_type_string(component_class
->type
));
638 if (component_class
->frozen
) {
639 BT_LOGW("Invalid parameter: component class is frozen: "
640 "addr=%p, name=\"%s\", type=%s",
642 bt_component_class_get_name(component_class
),
643 bt_component_class_type_string(component_class
->type
));
648 source_class
= container_of(component_class
,
649 struct bt_component_class_source
, parent
);
650 source_class
->methods
.iterator
.seek_time
=
651 notification_iterator_seek_time_method
;
652 BT_LOGV("Set source component class's notification iterator seek time method: "
653 "addr=%p, name=\"%s\", method-addr=%p",
655 bt_component_class_get_name(component_class
),
656 notification_iterator_seek_time_method
);
662 int bt_component_class_filter_set_notification_iterator_init_method(
663 struct bt_component_class
*component_class
,
664 bt_component_class_notification_iterator_init_method notification_iterator_init_method
)
666 struct bt_component_class_filter
*filter_class
;
669 if (!component_class
) {
670 BT_LOGW_STR("Invalid parameter: component class is NULL.");
675 if (!notification_iterator_init_method
) {
676 BT_LOGW_STR("Invalid parameter: method is NULL.");
681 if (component_class
->type
!= BT_COMPONENT_CLASS_TYPE_FILTER
) {
682 BT_LOGW("Invalid parameter: component class is not a filter component class: "
683 "addr=%p, name=\"%s\", type=%s",
685 bt_component_class_get_name(component_class
),
686 bt_component_class_type_string(component_class
->type
));
691 if (component_class
->frozen
) {
692 BT_LOGW("Invalid parameter: component class is frozen: "
693 "addr=%p, name=\"%s\", type=%s",
695 bt_component_class_get_name(component_class
),
696 bt_component_class_type_string(component_class
->type
));
701 filter_class
= container_of(component_class
,
702 struct bt_component_class_filter
, parent
);
703 filter_class
->methods
.iterator
.init
= notification_iterator_init_method
;
704 BT_LOGV("Set filter component class's notification iterator initialization method: "
705 "addr=%p, name=\"%s\", method-addr=%p",
707 bt_component_class_get_name(component_class
),
708 notification_iterator_init_method
);
714 int bt_component_class_filter_set_notification_iterator_finalize_method(
715 struct bt_component_class
*component_class
,
716 bt_component_class_notification_iterator_finalize_method notification_iterator_finalize_method
)
718 struct bt_component_class_filter
*filter_class
;
721 if (!component_class
) {
722 BT_LOGW_STR("Invalid parameter: component class is NULL.");
727 if (!notification_iterator_finalize_method
) {
728 BT_LOGW_STR("Invalid parameter: method is NULL.");
733 if (component_class
->type
!= BT_COMPONENT_CLASS_TYPE_FILTER
) {
734 BT_LOGW("Invalid parameter: component class is not a filter component class: "
735 "addr=%p, name=\"%s\", type=%s",
737 bt_component_class_get_name(component_class
),
738 bt_component_class_type_string(component_class
->type
));
743 if (component_class
->frozen
) {
744 BT_LOGW("Invalid parameter: component class is frozen: "
745 "addr=%p, name=\"%s\", type=%s",
747 bt_component_class_get_name(component_class
),
748 bt_component_class_type_string(component_class
->type
));
753 filter_class
= container_of(component_class
,
754 struct bt_component_class_filter
, parent
);
755 filter_class
->methods
.iterator
.finalize
=
756 notification_iterator_finalize_method
;
757 BT_LOGV("Set filter component class's notification iterator finalization method: "
758 "addr=%p, name=\"%s\", method-addr=%p",
760 bt_component_class_get_name(component_class
),
761 notification_iterator_finalize_method
);
767 int bt_component_class_filter_set_notification_iterator_seek_time_method(
768 struct bt_component_class
*component_class
,
769 bt_component_class_notification_iterator_seek_time_method notification_iterator_seek_time_method
)
771 struct bt_component_class_filter
*filter_class
;
774 if (!component_class
) {
775 BT_LOGW_STR("Invalid parameter: component class is NULL.");
780 if (!notification_iterator_seek_time_method
) {
781 BT_LOGW_STR("Invalid parameter: method is NULL.");
786 if (component_class
->type
!= BT_COMPONENT_CLASS_TYPE_FILTER
) {
787 BT_LOGW("Invalid parameter: component class is not a filter component class: "
788 "addr=%p, name=\"%s\", type=%s",
790 bt_component_class_get_name(component_class
),
791 bt_component_class_type_string(component_class
->type
));
796 if (component_class
->frozen
) {
797 BT_LOGW("Invalid parameter: component class is frozen: "
798 "addr=%p, name=\"%s\", type=%s",
800 bt_component_class_get_name(component_class
),
801 bt_component_class_type_string(component_class
->type
));
806 filter_class
= container_of(component_class
,
807 struct bt_component_class_filter
, parent
);
808 filter_class
->methods
.iterator
.seek_time
=
809 notification_iterator_seek_time_method
;
810 BT_LOGV("Set filter component class's notification iterator seek time method: "
811 "addr=%p, name=\"%s\", method-addr=%p",
813 bt_component_class_get_name(component_class
),
814 notification_iterator_seek_time_method
);
820 int bt_component_class_set_description(
821 struct bt_component_class
*component_class
,
822 const char *description
)
826 if (!component_class
) {
827 BT_LOGW_STR("Invalid parameter: component class is NULL.");
833 BT_LOGW_STR("Invalid parameter: description is NULL.");
838 if (component_class
->frozen
) {
839 BT_LOGW("Invalid parameter: component class is frozen: "
840 "addr=%p, name=\"%s\", type=%s",
842 bt_component_class_get_name(component_class
),
843 bt_component_class_type_string(component_class
->type
));
848 g_string_assign(component_class
->description
, description
);
849 BT_LOGV("Set component class's description: "
850 "addr=%p, name=\"%s\", type=%s",
852 bt_component_class_get_name(component_class
),
853 bt_component_class_type_string(component_class
->type
));
859 int bt_component_class_set_help(
860 struct bt_component_class
*component_class
,
865 if (!component_class
) {
866 BT_LOGW_STR("Invalid parameter: component class is NULL.");
872 BT_LOGW_STR("Invalid parameter: help is NULL.");
877 if (component_class
->frozen
) {
878 BT_LOGW("Invalid parameter: component class is frozen: "
879 "addr=%p, name=\"%s\", type=%s",
881 bt_component_class_get_name(component_class
),
882 bt_component_class_type_string(component_class
->type
));
887 g_string_assign(component_class
->help
, help
);
888 BT_LOGV("Set component class's help text: "
889 "addr=%p, name=\"%s\", type=%s",
891 bt_component_class_get_name(component_class
),
892 bt_component_class_type_string(component_class
->type
));
898 const char *bt_component_class_get_name(
899 struct bt_component_class
*component_class
)
901 return component_class
? component_class
->name
->str
: NULL
;
904 enum bt_component_class_type
bt_component_class_get_type(
905 struct bt_component_class
*component_class
)
907 return component_class
? component_class
->type
:
908 BT_COMPONENT_CLASS_TYPE_UNKNOWN
;
911 const char *bt_component_class_get_description(
912 struct bt_component_class
*component_class
)
914 return component_class
&& component_class
->description
&&
915 component_class
->description
->str
[0] != '\0' ?
916 component_class
->description
->str
: NULL
;
919 const char *bt_component_class_get_help(
920 struct bt_component_class
*component_class
)
922 return component_class
&& component_class
->help
&&
923 component_class
->help
->str
[0] != '\0' ?
924 component_class
->help
->str
: NULL
;
928 void bt_component_class_add_destroy_listener(struct bt_component_class
*class,
929 bt_component_class_destroy_listener_func func
, void *data
)
931 struct bt_component_class_destroy_listener listener
;
935 listener
.func
= func
;
936 listener
.data
= data
;
937 g_array_append_val(class->destroy_listeners
, listener
);
938 BT_LOGV("Component class has no registered query method: "
939 "comp-class-addr=%p, comp-class-name=\"%s\", comp-class-type=%s"
940 "func-addr=%p, data-addr=%p",
942 bt_component_class_get_name(class),
943 bt_component_class_type_string(class->type
),
947 int bt_component_class_freeze(
948 struct bt_component_class
*component_class
)
952 if (!component_class
) {
953 BT_LOGW_STR("Invalid parameter: component class is NULL.");
958 if (component_class
->frozen
) {
962 BT_LOGD("Freezing component class: "
963 "addr=%p, name=\"%s\", type=%s",
965 bt_component_class_get_name(component_class
),
966 bt_component_class_type_string(component_class
->type
));
967 component_class
->frozen
= BT_TRUE
;
973 struct bt_value
*bt_component_class_query(
974 struct bt_component_class
*component_class
,
975 const char *object
, struct bt_value
*params
)
977 struct bt_value
*results
= NULL
;
979 if (!component_class
) {
980 BT_LOGW_STR("Invalid parameter: component class is NULL.");
985 BT_LOGW_STR("Invalid parameter: object string is NULL.");
990 BT_LOGW_STR("Invalid parameter: parameters value is NULL.");
994 if (!component_class
->methods
.query
) {
995 /* Not an error: nothing to query */
996 BT_LOGD("Component class has no registered query method: "
997 "addr=%p, name=\"%s\", type=%s",
999 bt_component_class_get_name(component_class
),
1000 bt_component_class_type_string(component_class
->type
));
1004 BT_LOGD("Calling user's query method: "
1005 "comp-class-addr=%p, comp-class-name=\"%s\", comp-class-type=%s"
1006 "object=\"%s\", params-addr=%p",
1008 bt_component_class_get_name(component_class
),
1009 bt_component_class_type_string(component_class
->type
),
1011 results
= component_class
->methods
.query(component_class
,
1013 BT_LOGD("User method returned: results-addr=%p", results
);