cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / lib / graph / component.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8 #ifndef BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
9 #define BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
10
11 #include <babeltrace2/graph/component.h>
12 #include <babeltrace2/graph/component-class.h>
13 #include "lib/object.h"
14 #include <babeltrace2/types.h>
15 #include <babeltrace2/logging.h>
16 #include "common/assert.h"
17 #include <glib.h>
18 #include <stdbool.h>
19
20 #include "component-class.h"
21 #include "port.h"
22
23 typedef void (*bt_component_destroy_listener_func)(
24 struct bt_component *class, void *data);
25
26 struct bt_component_destroy_listener {
27 bt_component_destroy_listener_func func;
28 void *data;
29 };
30
31 struct bt_graph;
32
33 struct bt_component {
34 struct bt_object base;
35 struct bt_component_class *class;
36 GString *name;
37 bt_logging_level log_level;
38
39 /* User-defined data */
40 void *user_data;
41
42 /* Input and output ports (weak references) */
43 GPtrArray *input_ports;
44 GPtrArray *output_ports;
45
46 /* Array of struct bt_component_destroy_listener */
47 GArray *destroy_listeners;
48
49 bool initialized;
50 };
51
52 static inline
53 struct bt_graph *bt_component_borrow_graph(struct bt_component *comp)
54 {
55 BT_ASSERT_DBG(comp);
56 return (void *) bt_object_borrow_parent(&comp->base);
57 }
58
59 int bt_component_create(struct bt_component_class *component_class,
60 const char *name, bt_logging_level log_level,
61 struct bt_component **component);
62
63 enum bt_component_class_port_connected_method_status
64 bt_component_port_connected(
65 struct bt_component *comp,
66 struct bt_port *self_port, struct bt_port *other_port);
67
68 void bt_component_set_graph(struct bt_component *component,
69 struct bt_graph *graph);
70
71 uint64_t bt_component_get_input_port_count(const struct bt_component *comp,
72 const char *api_func);
73
74 uint64_t bt_component_get_output_port_count(const struct bt_component *comp,
75 const char *api_func);
76
77 struct bt_port_input *bt_component_borrow_input_port_by_index(
78 struct bt_component *comp, uint64_t index,
79 const char *api_func);
80
81 struct bt_port_output *bt_component_borrow_output_port_by_index(
82 struct bt_component *comp, uint64_t index,
83 const char *api_func);
84
85 struct bt_port_input *bt_component_borrow_input_port_by_name(
86 struct bt_component *comp, const char *name,
87 const char *api_func);
88
89 struct bt_port_output *bt_component_borrow_output_port_by_name(
90 struct bt_component *comp, const char *name,
91 const char *api_func);
92
93 enum bt_self_component_add_port_status bt_component_add_input_port(
94 struct bt_component *component, const char *name,
95 void *user_data, struct bt_port **port,
96 const char *api_func);
97
98 enum bt_self_component_add_port_status bt_component_add_output_port(
99 struct bt_component *component, const char *name,
100 void *user_data, struct bt_port **port,
101 const char *api_func);
102
103 void bt_component_remove_port(struct bt_component *component,
104 struct bt_port *port);
105
106 void bt_component_add_destroy_listener(struct bt_component *component,
107 bt_component_destroy_listener_func func, void *data);
108
109 void bt_component_remove_destroy_listener(struct bt_component *component,
110 bt_component_destroy_listener_func func, void *data);
111
112 #endif /* BABELTRACE_GRAPH_COMPONENT_INTERNAL_H */
This page took 0.030903 seconds and 4 git commands to generate.