cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[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
13 struct bt_port {
14 struct bt_object base;
15 enum bt_port_type type;
16 GString *name;
17 struct bt_connection *connection;
18 void *user_data;
19 };
20
21 struct bt_component;
22
23 struct bt_port *bt_port_create(struct bt_component *parent_component,
24 enum bt_port_type type, const char *name, void *user_data);
25
26 void bt_port_set_connection(struct bt_port *port,
27 struct bt_connection *connection);
28
29 static inline
30 struct bt_component *bt_port_borrow_component_inline(const struct bt_port *port)
31 {
32 BT_ASSERT_DBG(port);
33 return (void *) bt_object_borrow_parent(&port->base);
34 }
35
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:
41 return "INPUT";
42 case BT_PORT_TYPE_OUTPUT:
43 return "OUTPUT";
44 default:
45 return "(unknown)";
46 }
47 }
48
49 #endif /* BABELTRACE_GRAPH_PORT_INTERNAL_H */
This page took 0.030507 seconds and 4 git commands to generate.