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> |
578e048b MJ |
13 | #include "lib/object.h" |
14 | #include "common/list.h" | |
3fadfbc0 | 15 | #include <babeltrace2/types.h> |
c4f23e30 | 16 | #include <stdbool.h> |
33b34c43 PP |
17 | #include <glib.h> |
18 | ||
19 | struct bt_component_class; | |
bfa9a4be | 20 | struct bt_plugin_so_shared_lib_handle; |
33b34c43 PP |
21 | |
22 | typedef void (*bt_component_class_destroy_listener_func)( | |
23 | struct bt_component_class *class, void *data); | |
24 | ||
d3e4dcd8 | 25 | struct bt_component_class_destroy_listener { |
33b34c43 PP |
26 | bt_component_class_destroy_listener_func func; |
27 | void *data; | |
28 | }; | |
fb2dcc52 JG |
29 | |
30 | struct bt_component_class { | |
b8a06801 | 31 | struct bt_object base; |
d3e4dcd8 | 32 | enum bt_component_class_type type; |
fb2dcc52 | 33 | GString *name; |
7c7c0433 | 34 | GString *description; |
5536d9a6 | 35 | GString *help; |
2ce06c9e | 36 | GString *plugin_name; |
d94d92ac | 37 | |
d3e4dcd8 | 38 | /* Array of struct bt_component_class_destroy_listener */ |
33b34c43 | 39 | GArray *destroy_listeners; |
d94d92ac | 40 | bool frozen; |
bfa9a4be MD |
41 | struct bt_list_head node; |
42 | struct bt_plugin_so_shared_lib_handle *so_handle; | |
33b34c43 | 43 | }; |
92893b7b | 44 | |
41a3efcd | 45 | struct bt_component_class_with_iterator_class { |
d3e4dcd8 | 46 | struct bt_component_class parent; |
41a3efcd SM |
47 | bt_message_iterator_class *msg_iter_cls; |
48 | }; | |
49 | ||
50 | struct bt_component_class_source { | |
51 | struct bt_component_class_with_iterator_class parent; | |
d3e4dcd8 | 52 | struct { |
2b55df78 | 53 | bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions; |
21a9f056 | 54 | bt_component_class_source_initialize_method init; |
0d72b8c3 | 55 | bt_component_class_source_finalize_method finalize; |
0d72b8c3 | 56 | bt_component_class_source_query_method query; |
0d72b8c3 | 57 | bt_component_class_source_output_port_connected_method output_port_connected; |
d3e4dcd8 | 58 | } methods; |
41a3efcd SM |
59 | }; |
60 | ||
61 | struct bt_component_class_filter { | |
62 | struct bt_component_class_with_iterator_class parent; | |
63 | struct { | |
64 | bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions; | |
65 | bt_component_class_filter_initialize_method init; | |
66 | bt_component_class_filter_finalize_method finalize; | |
67 | bt_component_class_filter_query_method query; | |
68 | bt_component_class_filter_input_port_connected_method input_port_connected; | |
69 | bt_component_class_filter_output_port_connected_method output_port_connected; | |
70 | } methods; | |
d3e4dcd8 PP |
71 | }; |
72 | ||
73 | struct bt_component_class_sink { | |
74 | struct bt_component_class parent; | |
75 | struct { | |
2b55df78 | 76 | bt_component_class_sink_get_supported_mip_versions_method get_supported_mip_versions; |
21a9f056 | 77 | bt_component_class_sink_initialize_method init; |
0d72b8c3 PP |
78 | bt_component_class_sink_finalize_method finalize; |
79 | bt_component_class_sink_query_method query; | |
0d72b8c3 | 80 | bt_component_class_sink_input_port_connected_method input_port_connected; |
5badd463 | 81 | bt_component_class_sink_graph_is_configured_method graph_is_configured; |
0d72b8c3 | 82 | bt_component_class_sink_consume_method consume; |
d3e4dcd8 PP |
83 | } methods; |
84 | }; | |
85 | ||
3230ee6b | 86 | void bt_component_class_add_destroy_listener(struct bt_component_class *class, |
33b34c43 | 87 | bt_component_class_destroy_listener_func func, void *data); |
fb2dcc52 | 88 | |
0d72b8c3 PP |
89 | void _bt_component_class_freeze( |
90 | const struct bt_component_class *component_class); | |
d94d92ac PP |
91 | |
92 | #ifdef BT_DEV_MODE | |
93 | # define bt_component_class_freeze _bt_component_class_freeze | |
94 | #else | |
95 | # define bt_component_class_freeze(_cc) | |
96 | #endif | |
97 | ||
41a3efcd SM |
98 | static inline |
99 | bool bt_component_class_has_message_iterator_class( | |
100 | struct bt_component_class *component_class) | |
101 | { | |
102 | return component_class->type == BT_COMPONENT_CLASS_TYPE_SOURCE || | |
103 | component_class->type == BT_COMPONENT_CLASS_TYPE_FILTER; | |
104 | } | |
105 | ||
6ac74c0c | 106 | #endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H */ |