b829672a9317ec333b376066e829f6944b8746e5
[babeltrace.git] / src / lib / graph / component-class.h
1 #ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
2 #define BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H
3
4 /*
5 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
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
29 #include <babeltrace2/graph/component-class.h>
30 #include <babeltrace2/graph/component.h>
31 #include "common/macros.h"
32 #include "lib/object.h"
33 #include "common/list.h"
34 #include <babeltrace2/types.h>
35 #include <stdbool.h>
36 #include <glib.h>
37
38 struct bt_component_class;
39 struct bt_plugin_so_shared_lib_handle;
40
41 typedef void (*bt_component_class_destroy_listener_func)(
42 struct bt_component_class *class, void *data);
43
44 struct bt_component_class_destroy_listener {
45 bt_component_class_destroy_listener_func func;
46 void *data;
47 };
48
49 struct bt_component_class {
50 struct bt_object base;
51 enum bt_component_class_type type;
52 GString *name;
53 GString *description;
54 GString *help;
55 GString *plugin_name;
56
57 /* Array of struct bt_component_class_destroy_listener */
58 GArray *destroy_listeners;
59 bool frozen;
60 struct bt_list_head node;
61 struct bt_plugin_so_shared_lib_handle *so_handle;
62 };
63
64 struct bt_component_class_with_iterator_class {
65 struct bt_component_class parent;
66 bt_message_iterator_class *msg_iter_cls;
67 };
68
69 struct bt_component_class_source {
70 struct bt_component_class_with_iterator_class parent;
71 struct {
72 bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions;
73 bt_component_class_source_initialize_method init;
74 bt_component_class_source_finalize_method finalize;
75 bt_component_class_source_query_method query;
76 bt_component_class_source_output_port_connected_method output_port_connected;
77 } methods;
78 };
79
80 struct bt_component_class_filter {
81 struct bt_component_class_with_iterator_class parent;
82 struct {
83 bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions;
84 bt_component_class_filter_initialize_method init;
85 bt_component_class_filter_finalize_method finalize;
86 bt_component_class_filter_query_method query;
87 bt_component_class_filter_input_port_connected_method input_port_connected;
88 bt_component_class_filter_output_port_connected_method output_port_connected;
89 } methods;
90 };
91
92 struct bt_component_class_sink {
93 struct bt_component_class parent;
94 struct {
95 bt_component_class_sink_get_supported_mip_versions_method get_supported_mip_versions;
96 bt_component_class_sink_initialize_method init;
97 bt_component_class_sink_finalize_method finalize;
98 bt_component_class_sink_query_method query;
99 bt_component_class_sink_input_port_connected_method input_port_connected;
100 bt_component_class_sink_graph_is_configured_method graph_is_configured;
101 bt_component_class_sink_consume_method consume;
102 } methods;
103 };
104
105 BT_HIDDEN
106 void bt_component_class_add_destroy_listener(struct bt_component_class *class,
107 bt_component_class_destroy_listener_func func, void *data);
108
109 BT_HIDDEN
110 void _bt_component_class_freeze(
111 const struct bt_component_class *component_class);
112
113 #ifdef BT_DEV_MODE
114 # define bt_component_class_freeze _bt_component_class_freeze
115 #else
116 # define bt_component_class_freeze(_cc)
117 #endif
118
119 static inline
120 const char *bt_component_class_type_string(enum bt_component_class_type type)
121 {
122 switch (type) {
123 case BT_COMPONENT_CLASS_TYPE_SOURCE:
124 return "SOURCE";
125 case BT_COMPONENT_CLASS_TYPE_SINK:
126 return "SINK";
127 case BT_COMPONENT_CLASS_TYPE_FILTER:
128 return "FILTER";
129 default:
130 return "(unknown)";
131 }
132 }
133
134 static inline
135 bool bt_component_class_has_message_iterator_class(
136 struct bt_component_class *component_class)
137 {
138 return component_class->type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
139 component_class->type == BT_COMPONENT_CLASS_TYPE_FILTER;
140 }
141
142 #endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H */
This page took 0.033689 seconds and 3 git commands to generate.