Commit | Line | Data |
---|---|---|
8b285017 | 1 | /* |
0235b0db MJ |
2 | * SPDX-License-Identifier: MIT |
3 | * | |
e2f7325d | 4 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
8b285017 | 5 | * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
8b285017 JG |
6 | */ |
7 | ||
0235b0db MJ |
8 | #ifndef BABELTRACE_GRAPH_PORT_INTERNAL_H |
9 | #define BABELTRACE_GRAPH_PORT_INTERNAL_H | |
10 | ||
43c59509 | 11 | #include <babeltrace2/graph/port.h> |
91d81473 | 12 | #include "common/macros.h" |
8b285017 | 13 | |
8b285017 JG |
14 | struct bt_port { |
15 | struct bt_object base; | |
16 | enum bt_port_type type; | |
17 | GString *name; | |
72b913fb | 18 | struct bt_connection *connection; |
a45a0b60 | 19 | void *user_data; |
8b285017 JG |
20 | }; |
21 | ||
0d72b8c3 PP |
22 | struct bt_component; |
23 | ||
8b285017 JG |
24 | BT_HIDDEN |
25 | struct bt_port *bt_port_create(struct bt_component *parent_component, | |
3e9b0023 | 26 | enum bt_port_type type, const char *name, void *user_data); |
8b285017 JG |
27 | |
28 | BT_HIDDEN | |
72b913fb | 29 | void bt_port_set_connection(struct bt_port *port, |
8b285017 JG |
30 | struct bt_connection *connection); |
31 | ||
0d72b8c3 PP |
32 | static inline |
33 | struct bt_component *bt_port_borrow_component_inline(const struct bt_port *port) | |
34 | { | |
98b15851 | 35 | BT_ASSERT_DBG(port); |
0d72b8c3 PP |
36 | return (void *) bt_object_borrow_parent(&port->base); |
37 | } | |
38 | ||
ab0d387b PP |
39 | static inline |
40 | const char *bt_port_type_string(enum bt_port_type port_type) | |
41 | { | |
42 | switch (port_type) { | |
43 | case BT_PORT_TYPE_INPUT: | |
8a432889 | 44 | return "INPUT"; |
ab0d387b | 45 | case BT_PORT_TYPE_OUTPUT: |
8a432889 | 46 | return "OUTPUT"; |
ab0d387b PP |
47 | default: |
48 | return "(unknown)"; | |
49 | } | |
8b285017 | 50 | } |
8b285017 | 51 | |
6ac74c0c | 52 | #endif /* BABELTRACE_GRAPH_PORT_INTERNAL_H */ |