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 | ||
ae2be88d SM |
8 | #ifndef BABELTRACE_LIB_GRAPH_PORT_H |
9 | #define BABELTRACE_LIB_GRAPH_PORT_H | |
0235b0db | 10 | |
43c59509 | 11 | #include <babeltrace2/graph/port.h> |
8b285017 | 12 | |
8b285017 JG |
13 | struct bt_port { |
14 | struct bt_object base; | |
15 | enum bt_port_type type; | |
16 | GString *name; | |
72b913fb | 17 | struct bt_connection *connection; |
a45a0b60 | 18 | void *user_data; |
8b285017 JG |
19 | }; |
20 | ||
0d72b8c3 PP |
21 | struct bt_component; |
22 | ||
8b285017 | 23 | struct bt_port *bt_port_create(struct bt_component *parent_component, |
3e9b0023 | 24 | enum bt_port_type type, const char *name, void *user_data); |
8b285017 | 25 | |
72b913fb | 26 | void bt_port_set_connection(struct bt_port *port, |
8b285017 JG |
27 | struct bt_connection *connection); |
28 | ||
0d72b8c3 PP |
29 | static inline |
30 | struct bt_component *bt_port_borrow_component_inline(const struct bt_port *port) | |
31 | { | |
98b15851 | 32 | BT_ASSERT_DBG(port); |
0d72b8c3 PP |
33 | return (void *) bt_object_borrow_parent(&port->base); |
34 | } | |
35 | ||
ab0d387b PP |
36 | static inline |
37 | const char *bt_port_type_string(enum bt_port_type port_type) | |
38 | { | |
39 | switch (port_type) { | |
40 | case BT_PORT_TYPE_INPUT: | |
8a432889 | 41 | return "INPUT"; |
ab0d387b | 42 | case BT_PORT_TYPE_OUTPUT: |
8a432889 | 43 | return "OUTPUT"; |
ab0d387b PP |
44 | default: |
45 | return "(unknown)"; | |
46 | } | |
8b285017 | 47 | } |
8b285017 | 48 | |
ae2be88d | 49 | #endif /* BABELTRACE_LIB_GRAPH_PORT_H */ |