2 * SPDX-License-Identifier: MIT
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 #ifndef BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
9 #define BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
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"
20 #include "component-class.h"
23 typedef void (*bt_component_destroy_listener_func
)(
24 struct bt_component
*class, void *data
);
26 struct bt_component_destroy_listener
{
27 bt_component_destroy_listener_func func
;
34 struct bt_object base
;
35 struct bt_component_class
*class;
37 bt_logging_level log_level
;
39 /* User-defined data */
42 /* Input and output ports (weak references) */
43 GPtrArray
*input_ports
;
44 GPtrArray
*output_ports
;
46 /* Array of struct bt_component_destroy_listener */
47 GArray
*destroy_listeners
;
53 struct bt_graph
*bt_component_borrow_graph(struct bt_component
*comp
)
56 return (void *) bt_object_borrow_parent(&comp
->base
);
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
);
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
);
68 void bt_component_set_graph(struct bt_component
*component
,
69 struct bt_graph
*graph
);
71 uint64_t bt_component_get_input_port_count(const struct bt_component
*comp
,
72 const char *api_func
);
74 uint64_t bt_component_get_output_port_count(const struct bt_component
*comp
,
75 const char *api_func
);
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
);
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
);
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
);
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
);
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
);
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
);
103 void bt_component_remove_port(struct bt_component
*component
,
104 struct bt_port
*port
);
106 void bt_component_add_destroy_listener(struct bt_component
*component
,
107 bt_component_destroy_listener_func func
, void *data
);
109 void bt_component_remove_destroy_listener(struct bt_component
*component
,
110 bt_component_destroy_listener_func func
, void *data
);
112 #endif /* BABELTRACE_GRAPH_COMPONENT_INTERNAL_H */