Babeltrace 2 C API  2.0.4
Open-source trace manipulation framework
port.h
1 #ifndef BABELTRACE2_GRAPH_PORT_H
2 #define BABELTRACE2_GRAPH_PORT_H
3 
4 /*
5  * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  */
25 
26 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
28 #endif
29 
30 #include <stdint.h>
31 
32 #include <babeltrace2/types.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
179 typedef enum bt_port_type {
185 
191 } bt_port_type;
192 
210 extern bt_port_type bt_port_get_type(const bt_port *port);
211 
227 static inline
229 {
230  return bt_port_get_type(port) == BT_PORT_TYPE_INPUT;
231 }
232 
248 static inline
250 {
251  return bt_port_get_type(port) == BT_PORT_TYPE_OUTPUT;
252 }
253 
277  const bt_port *port);
278 
299  const bt_port *port);
300 
326 extern const char *bt_port_get_name(const bt_port *port);
327 
342 extern bt_bool bt_port_is_connected(const bt_port *port);
343 
366 extern void bt_port_get_ref(const bt_port *port);
367 
383 extern void bt_port_put_ref(const bt_port *port);
384 
399 #define BT_PORT_PUT_REF_AND_RESET(_port) \
400  do { \
401  bt_port_put_ref(_port); \
402  (_port) = NULL; \
403  } while (0)
404 
430 #define BT_PORT_MOVE_REF(_dst, _src) \
431  do { \
432  bt_port_put_ref(_dst); \
433  (_dst) = (_src); \
434  (_src) = NULL; \
435  } while (0)
436 
459 static inline
461 {
462  return __BT_UPCAST_CONST(bt_port, port);
463 }
464 
480 extern void bt_port_input_get_ref(const bt_port_input *port);
481 
497 extern void bt_port_input_put_ref(const bt_port_input *port);
498 
513 #define BT_PORT_INPUT_PUT_REF_AND_RESET(_port) \
514  do { \
515  bt_port_input_put_ref(_port); \
516  (_port) = NULL; \
517  } while (0)
518 
544 #define BT_PORT_INPUT_MOVE_REF(_dst, _src) \
545  do { \
546  bt_port_input_put_ref(_dst); \
547  (_dst) = (_src); \
548  (_src) = NULL; \
549  } while (0)
550 
573 static inline
575 {
576  return __BT_UPCAST_CONST(bt_port, port);
577 }
578 
594 extern void bt_port_output_get_ref(const bt_port_output *port);
595 
611 extern void bt_port_output_put_ref(const bt_port_output *port);
612 
627 #define BT_PORT_OUTPUT_PUT_REF_AND_RESET(_port) \
628  do { \
629  bt_port_output_put_ref(_port); \
630  (_port) = NULL; \
631  } while (0)
632 
658 #define BT_PORT_OUTPUT_MOVE_REF(_dst, _src) \
659  do { \
660  bt_port_output_put_ref(_dst); \
661  (_dst) = (_src); \
662  (_src) = NULL; \
663  } while (0)
664 
669 #ifdef __cplusplus
670 }
671 #endif
672 
673 #endif /* BABELTRACE2_GRAPH_PORT_H */
const bt_component * bt_port_borrow_component_const(const bt_port *port)
Borrows the component to which the port port belongs.
void bt_port_output_get_ref(const bt_port_output *port)
Increments the reference count of the output port port.
void bt_port_input_put_ref(const bt_port_input *port)
Decrements the reference count of the input port port.
void bt_port_input_get_ref(const bt_port_input *port)
Increments the reference count of the input port port.
static bt_bool bt_port_is_input(const bt_port *port)
Returns whether or not the port port is an input port.
Definition: port.h:228
void bt_port_get_ref(const bt_port *port)
Increments the reference count of the port port.
struct bt_port_input bt_port_input
Input port.
Definition: types.h:80
struct bt_port_output bt_port_output
Output port.
Definition: types.h:81
static bt_bool bt_port_is_output(const bt_port *port)
Returns whether or not the port port is an output port.
Definition: port.h:249
void bt_port_put_ref(const bt_port *port)
Decrements the reference count of the port port.
bt_port_type
Port type enumerators.
Definition: port.h:179
bt_bool bt_port_is_connected(const bt_port *port)
Returns whether or not the port port is connected.
Input port.
Definition: port.h:184
struct bt_component bt_component
Component.
Definition: types.h:38
int bt_bool
Babeltrace 2 boolean type.
Definition: types.h:140
struct bt_port bt_port
Port.
Definition: types.h:79
struct bt_connection bt_connection
Connection.
Definition: types.h:47
const bt_connection * bt_port_borrow_connection_const(const bt_port *port)
Borrows the connection of the port port.
static const bt_port * bt_port_input_as_port_const(const bt_port_input *port)
Upcasts the input port port to the common bt_port type.
Definition: port.h:460
void bt_port_output_put_ref(const bt_port_output *port)
Decrements the reference count of the output port port.
static const bt_port * bt_port_output_as_port_const(const bt_port_output *port)
Upcasts the output port port to the common bt_port type.
Definition: port.h:574
bt_port_type bt_port_get_type(const bt_port *port)
Returns the type enumerator of the port port.
const char * bt_port_get_name(const bt_port *port)
Returns the name of the port port.
Output port.
Definition: port.h:190