lib: make plugin API const-correct
[babeltrace.git] / include / babeltrace / graph / component-class-internal.h
CommitLineData
6ac74c0c
PP
1#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
2#define BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
fb2dcc52
JG
3
4/*
fb2dcc52 5 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
33b34c43 6 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
fb2dcc52
JG
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
b2e0c907
PP
29#include <babeltrace/graph/component.h>
30#include <babeltrace/graph/component-class.h>
d94d92ac
PP
31#include <babeltrace/graph/private-component-class-source.h>
32#include <babeltrace/graph/private-component-class-filter.h>
33#include <babeltrace/graph/private-component-class-sink.h>
fb2dcc52 34#include <babeltrace/babeltrace-internal.h>
b8a06801 35#include <babeltrace/object-internal.h>
bfa9a4be 36#include <babeltrace/list-internal.h>
c55a9f58 37#include <babeltrace/types.h>
33b34c43
PP
38#include <glib.h>
39
40struct bt_component_class;
bfa9a4be 41struct bt_plugin_so_shared_lib_handle;
33b34c43
PP
42
43typedef void (*bt_component_class_destroy_listener_func)(
44 struct bt_component_class *class, void *data);
45
d3e4dcd8 46struct bt_component_class_destroy_listener {
33b34c43
PP
47 bt_component_class_destroy_listener_func func;
48 void *data;
49};
fb2dcc52
JG
50
51struct bt_component_class {
b8a06801 52 struct bt_object base;
d3e4dcd8 53 enum bt_component_class_type type;
fb2dcc52 54 GString *name;
7c7c0433 55 GString *description;
5536d9a6 56 GString *help;
d94d92ac 57
d3e4dcd8 58 /* Array of struct bt_component_class_destroy_listener */
33b34c43 59 GArray *destroy_listeners;
d94d92ac 60 bool frozen;
bfa9a4be
MD
61 struct bt_list_head node;
62 struct bt_plugin_so_shared_lib_handle *so_handle;
33b34c43 63};
92893b7b 64
d3e4dcd8
PP
65struct bt_component_class_source {
66 struct bt_component_class parent;
67 struct {
d94d92ac
PP
68 bt_private_component_class_source_init_method init;
69 bt_private_component_class_source_finalize_method finalize;
70 bt_private_component_class_source_notification_iterator_init_method notif_iter_init;
71 bt_private_component_class_source_notification_iterator_finalize_method notif_iter_finalize;
72 bt_private_component_class_source_notification_iterator_next_method notif_iter_next;
73 bt_private_component_class_source_query_method query;
74 bt_private_component_class_source_accept_output_port_connection_method accept_output_port_connection;
75 bt_private_component_class_source_output_port_connected_method output_port_connected;
76 bt_private_component_class_source_output_port_disconnected_method output_port_disconnected;
d3e4dcd8
PP
77 } methods;
78};
79
80struct bt_component_class_sink {
81 struct bt_component_class parent;
82 struct {
d94d92ac
PP
83 bt_private_component_class_sink_init_method init;
84 bt_private_component_class_sink_finalize_method finalize;
85 bt_private_component_class_sink_query_method query;
86 bt_private_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
87 bt_private_component_class_sink_input_port_connected_method input_port_connected;
88 bt_private_component_class_sink_input_port_disconnected_method input_port_disconnected;
89 bt_private_component_class_sink_consume_method consume;
d3e4dcd8
PP
90 } methods;
91};
92
93struct bt_component_class_filter {
94 struct bt_component_class parent;
95 struct {
d94d92ac
PP
96 bt_private_component_class_filter_init_method init;
97 bt_private_component_class_filter_finalize_method finalize;
98 bt_private_component_class_filter_notification_iterator_init_method notif_iter_init;
99 bt_private_component_class_filter_notification_iterator_finalize_method notif_iter_finalize;
100 bt_private_component_class_filter_notification_iterator_next_method notif_iter_next;
101 bt_private_component_class_filter_query_method query;
102 bt_private_component_class_filter_accept_input_port_connection_method accept_input_port_connection;
103 bt_private_component_class_filter_accept_output_port_connection_method accept_output_port_connection;
104 bt_private_component_class_filter_input_port_connected_method input_port_connected;
105 bt_private_component_class_filter_output_port_connected_method output_port_connected;
106 bt_private_component_class_filter_input_port_disconnected_method input_port_disconnected;
107 bt_private_component_class_filter_output_port_disconnected_method output_port_disconnected;
d3e4dcd8
PP
108 } methods;
109};
110
92893b7b 111BT_HIDDEN
3230ee6b 112void bt_component_class_add_destroy_listener(struct bt_component_class *class,
33b34c43 113 bt_component_class_destroy_listener_func func, void *data);
fb2dcc52 114
d94d92ac
PP
115BT_HIDDEN
116void _bt_component_class_freeze(struct bt_component_class *component_class);
117
118#ifdef BT_DEV_MODE
119# define bt_component_class_freeze _bt_component_class_freeze
120#else
121# define bt_component_class_freeze(_cc)
122#endif
123
ab0d387b
PP
124static inline
125const char *bt_component_class_type_string(enum bt_component_class_type type)
126{
127 switch (type) {
ab0d387b
PP
128 case BT_COMPONENT_CLASS_TYPE_SOURCE:
129 return "BT_COMPONENT_CLASS_TYPE_SOURCE";
130 case BT_COMPONENT_CLASS_TYPE_SINK:
131 return "BT_COMPONENT_CLASS_TYPE_SINK";
132 case BT_COMPONENT_CLASS_TYPE_FILTER:
133 return "BT_COMPONENT_CLASS_TYPE_FILTER";
134 default:
135 return "(unknown)";
136 }
137}
138
6ac74c0c 139#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H */
This page took 0.047196 seconds and 4 git commands to generate.