Move to kernel style SPDX license identifiers
[babeltrace.git] / src / lib / graph / port.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8 #ifndef BABELTRACE_GRAPH_PORT_INTERNAL_H
9 #define BABELTRACE_GRAPH_PORT_INTERNAL_H
10
11 #include <babeltrace2/graph/port.h>
12 #include "common/macros.h"
13
14 struct bt_port {
15 struct bt_object base;
16 enum bt_port_type type;
17 GString *name;
18 struct bt_connection *connection;
19 void *user_data;
20 };
21
22 struct bt_component;
23
24 BT_HIDDEN
25 struct bt_port *bt_port_create(struct bt_component *parent_component,
26 enum bt_port_type type, const char *name, void *user_data);
27
28 BT_HIDDEN
29 void bt_port_set_connection(struct bt_port *port,
30 struct bt_connection *connection);
31
32 static inline
33 struct bt_component *bt_port_borrow_component_inline(const struct bt_port *port)
34 {
35 BT_ASSERT_DBG(port);
36 return (void *) bt_object_borrow_parent(&port->base);
37 }
38
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:
44 return "INPUT";
45 case BT_PORT_TYPE_OUTPUT:
46 return "OUTPUT";
47 default:
48 return "(unknown)";
49 }
50 }
51
52 #endif /* BABELTRACE_GRAPH_PORT_INTERNAL_H */
This page took 0.031491 seconds and 5 git commands to generate.