Commit | Line | Data |
---|---|---|
abe30a8f PP |
1 | #ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H |
2 | #define BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H | |
fb2dcc52 JG |
3 | |
4 | /* | |
f2b0325d | 5 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
fb2dcc52 JG |
6 | * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
7 | * | |
8 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
9 | * | |
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: | |
16 | * | |
17 | * The above copyright notice and this permission notice shall be included in | |
18 | * all copies or substantial portions of the Software. | |
19 | * | |
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 | |
26 | * SOFTWARE. | |
27 | */ | |
28 | ||
71c5da58 MJ |
29 | #include <babeltrace2/graph/component-const.h> |
30 | #include <babeltrace2/graph/component-class.h> | |
31 | #include <babeltrace2/graph/component-class-source.h> | |
32 | #include <babeltrace2/graph/component-class-filter.h> | |
33 | #include <babeltrace2/graph/component-class-sink.h> | |
85e7137b | 34 | #include "common/macros.h" |
57952005 MJ |
35 | #include "lib/object.h" |
36 | #include "common/list.h" | |
71c5da58 | 37 | #include <babeltrace2/types.h> |
969c1d8a | 38 | #include <stdbool.h> |
33b34c43 PP |
39 | #include <glib.h> |
40 | ||
41 | struct bt_component_class; | |
bfa9a4be | 42 | struct bt_plugin_so_shared_lib_handle; |
33b34c43 PP |
43 | |
44 | typedef void (*bt_component_class_destroy_listener_func)( | |
45 | struct bt_component_class *class, void *data); | |
46 | ||
d3e4dcd8 | 47 | struct bt_component_class_destroy_listener { |
33b34c43 PP |
48 | bt_component_class_destroy_listener_func func; |
49 | void *data; | |
50 | }; | |
fb2dcc52 JG |
51 | |
52 | struct bt_component_class { | |
b8a06801 | 53 | struct bt_object base; |
d3e4dcd8 | 54 | enum bt_component_class_type type; |
fb2dcc52 | 55 | GString *name; |
7c7c0433 | 56 | GString *description; |
5536d9a6 | 57 | GString *help; |
0c99efa4 | 58 | GString *plugin_name; |
834e9996 | 59 | |
d3e4dcd8 | 60 | /* Array of struct bt_component_class_destroy_listener */ |
33b34c43 | 61 | GArray *destroy_listeners; |
834e9996 | 62 | bool frozen; |
bfa9a4be MD |
63 | struct bt_list_head node; |
64 | struct bt_plugin_so_shared_lib_handle *so_handle; | |
33b34c43 | 65 | }; |
92893b7b | 66 | |
d3e4dcd8 PP |
67 | struct bt_component_class_source { |
68 | struct bt_component_class parent; | |
69 | struct { | |
be788861 | 70 | bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions; |
4175c1d5 | 71 | bt_component_class_source_initialize_method init; |
7b53201c | 72 | bt_component_class_source_finalize_method finalize; |
4175c1d5 | 73 | bt_component_class_source_message_iterator_initialize_method msg_iter_initialize; |
b09a5592 PP |
74 | bt_component_class_source_message_iterator_finalize_method msg_iter_finalize; |
75 | bt_component_class_source_message_iterator_next_method msg_iter_next; | |
15a52f66 PP |
76 | bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; |
77 | bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning; | |
78 | bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; | |
79 | bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; | |
7b53201c | 80 | bt_component_class_source_query_method query; |
7b53201c | 81 | bt_component_class_source_output_port_connected_method output_port_connected; |
d3e4dcd8 PP |
82 | } methods; |
83 | }; | |
84 | ||
85 | struct bt_component_class_sink { | |
86 | struct bt_component_class parent; | |
87 | struct { | |
be788861 | 88 | bt_component_class_sink_get_supported_mip_versions_method get_supported_mip_versions; |
4175c1d5 | 89 | bt_component_class_sink_initialize_method init; |
7b53201c PP |
90 | bt_component_class_sink_finalize_method finalize; |
91 | bt_component_class_sink_query_method query; | |
7b53201c | 92 | bt_component_class_sink_input_port_connected_method input_port_connected; |
1043fdea | 93 | bt_component_class_sink_graph_is_configured_method graph_is_configured; |
7b53201c | 94 | bt_component_class_sink_consume_method consume; |
d3e4dcd8 PP |
95 | } methods; |
96 | }; | |
97 | ||
98 | struct bt_component_class_filter { | |
99 | struct bt_component_class parent; | |
100 | struct { | |
be788861 | 101 | bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions; |
4175c1d5 | 102 | bt_component_class_filter_initialize_method init; |
7b53201c | 103 | bt_component_class_filter_finalize_method finalize; |
4175c1d5 | 104 | bt_component_class_filter_message_iterator_initialize_method msg_iter_initialize; |
b09a5592 PP |
105 | bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize; |
106 | bt_component_class_filter_message_iterator_next_method msg_iter_next; | |
15a52f66 PP |
107 | bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; |
108 | bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning; | |
109 | bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; | |
110 | bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; | |
7b53201c | 111 | bt_component_class_filter_query_method query; |
7b53201c PP |
112 | bt_component_class_filter_input_port_connected_method input_port_connected; |
113 | bt_component_class_filter_output_port_connected_method output_port_connected; | |
d3e4dcd8 PP |
114 | } methods; |
115 | }; | |
116 | ||
92893b7b | 117 | BT_HIDDEN |
3230ee6b | 118 | void bt_component_class_add_destroy_listener(struct bt_component_class *class, |
33b34c43 | 119 | bt_component_class_destroy_listener_func func, void *data); |
fb2dcc52 | 120 | |
834e9996 | 121 | BT_HIDDEN |
7b53201c PP |
122 | void _bt_component_class_freeze( |
123 | const struct bt_component_class *component_class); | |
834e9996 PP |
124 | |
125 | #ifdef BT_DEV_MODE | |
126 | # define bt_component_class_freeze _bt_component_class_freeze | |
127 | #else | |
128 | # define bt_component_class_freeze(_cc) | |
129 | #endif | |
130 | ||
ab0d387b PP |
131 | static inline |
132 | const char *bt_component_class_type_string(enum bt_component_class_type type) | |
133 | { | |
134 | switch (type) { | |
ab0d387b | 135 | case BT_COMPONENT_CLASS_TYPE_SOURCE: |
e05f8464 | 136 | return "SOURCE"; |
ab0d387b | 137 | case BT_COMPONENT_CLASS_TYPE_SINK: |
e05f8464 | 138 | return "SINK"; |
ab0d387b | 139 | case BT_COMPONENT_CLASS_TYPE_FILTER: |
e05f8464 | 140 | return "FILTER"; |
ab0d387b PP |
141 | default: |
142 | return "(unknown)"; | |
143 | } | |
144 | } | |
145 | ||
abe30a8f | 146 | #endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H */ |