| 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-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> |
| 34 | #include "common/macros.h" |
| 35 | #include "lib/object.h" |
| 36 | #include "common/list.h" |
| 37 | #include <babeltrace2/types.h> |
| 38 | #include <glib.h> |
| 39 | |
| 40 | struct bt_component_class; |
| 41 | struct bt_plugin_so_shared_lib_handle; |
| 42 | |
| 43 | typedef void (*bt_component_class_destroy_listener_func)( |
| 44 | struct bt_component_class *class, void *data); |
| 45 | |
| 46 | struct bt_component_class_destroy_listener { |
| 47 | bt_component_class_destroy_listener_func func; |
| 48 | void *data; |
| 49 | }; |
| 50 | |
| 51 | struct bt_component_class { |
| 52 | struct bt_object base; |
| 53 | enum bt_component_class_type type; |
| 54 | GString *name; |
| 55 | GString *description; |
| 56 | GString *help; |
| 57 | GString *plugin_name; |
| 58 | |
| 59 | /* Array of struct bt_component_class_destroy_listener */ |
| 60 | GArray *destroy_listeners; |
| 61 | bool frozen; |
| 62 | struct bt_list_head node; |
| 63 | struct bt_plugin_so_shared_lib_handle *so_handle; |
| 64 | }; |
| 65 | |
| 66 | struct bt_component_class_source { |
| 67 | struct bt_component_class parent; |
| 68 | struct { |
| 69 | bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions; |
| 70 | bt_component_class_source_init_method init; |
| 71 | bt_component_class_source_finalize_method finalize; |
| 72 | bt_component_class_source_message_iterator_init_method msg_iter_init; |
| 73 | bt_component_class_source_message_iterator_finalize_method msg_iter_finalize; |
| 74 | bt_component_class_source_message_iterator_next_method msg_iter_next; |
| 75 | bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; |
| 76 | bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning; |
| 77 | bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; |
| 78 | bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; |
| 79 | bt_component_class_source_query_method query; |
| 80 | bt_component_class_source_output_port_connected_method output_port_connected; |
| 81 | } methods; |
| 82 | }; |
| 83 | |
| 84 | struct bt_component_class_sink { |
| 85 | struct bt_component_class parent; |
| 86 | struct { |
| 87 | bt_component_class_sink_get_supported_mip_versions_method get_supported_mip_versions; |
| 88 | bt_component_class_sink_init_method init; |
| 89 | bt_component_class_sink_finalize_method finalize; |
| 90 | bt_component_class_sink_query_method query; |
| 91 | bt_component_class_sink_input_port_connected_method input_port_connected; |
| 92 | bt_component_class_sink_graph_is_configured_method graph_is_configured; |
| 93 | bt_component_class_sink_consume_method consume; |
| 94 | } methods; |
| 95 | }; |
| 96 | |
| 97 | struct bt_component_class_filter { |
| 98 | struct bt_component_class parent; |
| 99 | struct { |
| 100 | bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions; |
| 101 | bt_component_class_filter_init_method init; |
| 102 | bt_component_class_filter_finalize_method finalize; |
| 103 | bt_component_class_filter_message_iterator_init_method msg_iter_init; |
| 104 | bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize; |
| 105 | bt_component_class_filter_message_iterator_next_method msg_iter_next; |
| 106 | bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; |
| 107 | bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning; |
| 108 | bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; |
| 109 | bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; |
| 110 | bt_component_class_filter_query_method query; |
| 111 | bt_component_class_filter_input_port_connected_method input_port_connected; |
| 112 | bt_component_class_filter_output_port_connected_method output_port_connected; |
| 113 | } methods; |
| 114 | }; |
| 115 | |
| 116 | BT_HIDDEN |
| 117 | void bt_component_class_add_destroy_listener(struct bt_component_class *class, |
| 118 | bt_component_class_destroy_listener_func func, void *data); |
| 119 | |
| 120 | BT_HIDDEN |
| 121 | void _bt_component_class_freeze( |
| 122 | const struct bt_component_class *component_class); |
| 123 | |
| 124 | #ifdef BT_DEV_MODE |
| 125 | # define bt_component_class_freeze _bt_component_class_freeze |
| 126 | #else |
| 127 | # define bt_component_class_freeze(_cc) |
| 128 | #endif |
| 129 | |
| 130 | static inline |
| 131 | const char *bt_component_class_type_string(enum bt_component_class_type type) |
| 132 | { |
| 133 | switch (type) { |
| 134 | case BT_COMPONENT_CLASS_TYPE_SOURCE: |
| 135 | return "SOURCE"; |
| 136 | case BT_COMPONENT_CLASS_TYPE_SINK: |
| 137 | return "SINK"; |
| 138 | case BT_COMPONENT_CLASS_TYPE_FILTER: |
| 139 | return "FILTER"; |
| 140 | default: |
| 141 | return "(unknown)"; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | #endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_INTERNAL_H */ |