Commit | Line | Data |
---|---|---|
fb2dcc52 | 1 | /* |
0235b0db MJ |
2 | * SPDX-License-Identifier: MIT |
3 | * | |
e2f7325d | 4 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
fb2dcc52 | 5 | * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
fb2dcc52 JG |
6 | */ |
7 | ||
0235b0db MJ |
8 | #ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H |
9 | #define BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H | |
10 | ||
3fadfbc0 | 11 | #include <babeltrace2/graph/component-class.h> |
43c59509 | 12 | #include <babeltrace2/graph/component.h> |
91d81473 | 13 | #include "common/macros.h" |
578e048b MJ |
14 | #include "lib/object.h" |
15 | #include "common/list.h" | |
3fadfbc0 | 16 | #include <babeltrace2/types.h> |
c4f23e30 | 17 | #include <stdbool.h> |
33b34c43 PP |
18 | #include <glib.h> |
19 | ||
20 | struct bt_component_class; | |
bfa9a4be | 21 | struct bt_plugin_so_shared_lib_handle; |
33b34c43 PP |
22 | |
23 | typedef void (*bt_component_class_destroy_listener_func)( | |
24 | struct bt_component_class *class, void *data); | |
25 | ||
d3e4dcd8 | 26 | struct bt_component_class_destroy_listener { |
33b34c43 PP |
27 | bt_component_class_destroy_listener_func func; |
28 | void *data; | |
29 | }; | |
fb2dcc52 JG |
30 | |
31 | struct bt_component_class { | |
b8a06801 | 32 | struct bt_object base; |
d3e4dcd8 | 33 | enum bt_component_class_type type; |
fb2dcc52 | 34 | GString *name; |
7c7c0433 | 35 | GString *description; |
5536d9a6 | 36 | GString *help; |
2ce06c9e | 37 | GString *plugin_name; |
d94d92ac | 38 | |
d3e4dcd8 | 39 | /* Array of struct bt_component_class_destroy_listener */ |
33b34c43 | 40 | GArray *destroy_listeners; |
d94d92ac | 41 | bool frozen; |
bfa9a4be MD |
42 | struct bt_list_head node; |
43 | struct bt_plugin_so_shared_lib_handle *so_handle; | |
33b34c43 | 44 | }; |
92893b7b | 45 | |
41a3efcd | 46 | struct bt_component_class_with_iterator_class { |
d3e4dcd8 | 47 | struct bt_component_class parent; |
41a3efcd SM |
48 | bt_message_iterator_class *msg_iter_cls; |
49 | }; | |
50 | ||
51 | struct bt_component_class_source { | |
52 | struct bt_component_class_with_iterator_class parent; | |
d3e4dcd8 | 53 | struct { |
2b55df78 | 54 | bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions; |
21a9f056 | 55 | bt_component_class_source_initialize_method init; |
0d72b8c3 | 56 | bt_component_class_source_finalize_method finalize; |
0d72b8c3 | 57 | bt_component_class_source_query_method query; |
0d72b8c3 | 58 | bt_component_class_source_output_port_connected_method output_port_connected; |
d3e4dcd8 | 59 | } methods; |
41a3efcd SM |
60 | }; |
61 | ||
62 | struct bt_component_class_filter { | |
63 | struct bt_component_class_with_iterator_class parent; | |
64 | struct { | |
65 | bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions; | |
66 | bt_component_class_filter_initialize_method init; | |
67 | bt_component_class_filter_finalize_method finalize; | |
68 | bt_component_class_filter_query_method query; | |
69 | bt_component_class_filter_input_port_connected_method input_port_connected; | |
70 | bt_component_class_filter_output_port_connected_method output_port_connected; | |
71 | } methods; | |
d3e4dcd8 PP |
72 | }; |
73 | ||
74 | struct bt_component_class_sink { | |
75 | struct bt_component_class parent; | |
76 | struct { | |
2b55df78 | 77 | bt_component_class_sink_get_supported_mip_versions_method get_supported_mip_versions; |
21a9f056 | 78 | bt_component_class_sink_initialize_method init; |
0d72b8c3 PP |
79 | bt_component_class_sink_finalize_method finalize; |
80 | bt_component_class_sink_query_method query; | |
0d72b8c3 | 81 | bt_component_class_sink_input_port_connected_method input_port_connected; |
5badd463 | 82 | bt_component_class_sink_graph_is_configured_method graph_is_configured; |
0d72b8c3 | 83 | bt_component_class_sink_consume_method consume; |
d3e4dcd8 PP |
84 | } methods; |
85 | }; | |
86 | ||
92893b7b | 87 | BT_HIDDEN |
3230ee6b | 88 | void bt_component_class_add_destroy_listener(struct bt_component_class *class, |
33b34c43 | 89 | bt_component_class_destroy_listener_func func, void *data); |
fb2dcc52 | 90 | |
d94d92ac | 91 | BT_HIDDEN |
0d72b8c3 PP |
92 | void _bt_component_class_freeze( |
93 | const struct bt_component_class *component_class); | |
d94d92ac PP |
94 | |
95 | #ifdef BT_DEV_MODE | |
96 | # define bt_component_class_freeze _bt_component_class_freeze | |
97 | #else | |
98 | # define bt_component_class_freeze(_cc) | |
99 | #endif | |
100 | ||
ab0d387b PP |
101 | static inline |
102 | const char *bt_component_class_type_string(enum bt_component_class_type type) | |
103 | { | |
104 | switch (type) { | |
ab0d387b | 105 | case BT_COMPONENT_CLASS_TYPE_SOURCE: |
8a432889 | 106 | return "SOURCE"; |
ab0d387b | 107 | case BT_COMPONENT_CLASS_TYPE_SINK: |
8a432889 | 108 | return "SINK"; |
ab0d387b | 109 | case BT_COMPONENT_CLASS_TYPE_FILTER: |
8a432889 | 110 | return "FILTER"; |
ab0d387b PP |
111 | default: |
112 | return "(unknown)"; | |
113 | } | |
114 | } | |
115 | ||
41a3efcd SM |
116 | static inline |
117 | bool bt_component_class_has_message_iterator_class( | |
118 | struct bt_component_class *component_class) | |
119 | { | |
120 | return component_class->type == BT_COMPONENT_CLASS_TYPE_SOURCE || | |
121 | component_class->type == BT_COMPONENT_CLASS_TYPE_FILTER; | |
122 | } | |
123 | ||
6ac74c0c | 124 | #endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H */ |