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