Babeltrace 2 C API  2.1.1
Open-source trace manipulation framework
component.h
1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation
5  */
6 
7 #ifndef BABELTRACE2_GRAPH_COMPONENT_H
8 #define BABELTRACE2_GRAPH_COMPONENT_H
9 
10 /* IWYU pragma: private, include <babeltrace2/babeltrace.h> */
11 
12 #ifndef __BT_IN_BABELTRACE_H
13 # error "Please include <babeltrace2/babeltrace.h> instead."
14 #endif
15 
16 #include <babeltrace2/graph/component-class.h>
17 #include <babeltrace2/types.h>
18 #include <babeltrace2/logging.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
243  const bt_component *component) __BT_NOEXCEPT;
244 
261 static inline
262 bt_bool bt_component_is_source(const bt_component *component) __BT_NOEXCEPT
263 {
264  return bt_component_get_class_type(component) ==
266 }
267 
284 static inline
285 bt_bool bt_component_is_filter(const bt_component *component) __BT_NOEXCEPT
286 {
287  return bt_component_get_class_type(component) ==
289 }
290 
307 static inline
308 bt_bool bt_component_is_sink(const bt_component *component) __BT_NOEXCEPT
309 {
310  return bt_component_get_class_type(component) ==
312 }
313 
335  const bt_component *component) __BT_NOEXCEPT;
336 
363 extern const char *bt_component_get_name(const bt_component *component)
364  __BT_NOEXCEPT;
365 
382  const bt_component *component) __BT_NOEXCEPT;
383 
406 extern void bt_component_get_ref(const bt_component *component) __BT_NOEXCEPT;
407 
423 extern void bt_component_put_ref(const bt_component *component) __BT_NOEXCEPT;
424 
439 #define BT_COMPONENT_PUT_REF_AND_RESET(_component) \
440  do { \
441  bt_component_put_ref(_component); \
442  (_component) = NULL; \
443  } while (0)
444 
470 #define BT_COMPONENT_MOVE_REF(_dst, _src) \
471  do { \
472  bt_component_put_ref(_dst); \
473  (_dst) = (_src); \
474  (_src) = NULL; \
475  } while (0)
476 
497 extern const bt_component_class_source *
499  const bt_component_source *component) __BT_NOEXCEPT;
500 
523 static inline
525  const bt_component_source *component) __BT_NOEXCEPT
526 {
527  return __BT_UPCAST_CONST(bt_component, component);
528 }
529 
551  const bt_component_source *component) __BT_NOEXCEPT;
552 
582 extern const bt_port_output *
584  const bt_component_source *component,
585  uint64_t index) __BT_NOEXCEPT;
586 
613 extern const bt_port_output *
615  const bt_component_source *component,
616  const char *name) __BT_NOEXCEPT;
617 
640 extern void bt_component_source_get_ref(
641  const bt_component_source *component) __BT_NOEXCEPT;
642 
658 extern void bt_component_source_put_ref(
659  const bt_component_source *component) __BT_NOEXCEPT;
660 
675 #define BT_COMPONENT_SOURCE_PUT_REF_AND_RESET(_component) \
676  do { \
677  bt_component_source_put_ref(_component); \
678  (_component) = NULL; \
679  } while (0)
680 
706 #define BT_COMPONENT_SOURCE_MOVE_REF(_dst, _src) \
707  do { \
708  bt_component_source_put_ref(_dst); \
709  (_dst) = (_src); \
710  (_src) = NULL; \
711  } while (0)
712 
733 extern const bt_component_class_filter *
735  const bt_component_filter *component) __BT_NOEXCEPT;
736 
759 static inline
761  const bt_component_filter *component) __BT_NOEXCEPT
762 {
763  return __BT_UPCAST_CONST(bt_component, component);
764 }
765 
787  const bt_component_filter *component) __BT_NOEXCEPT;
788 
818 extern const bt_port_input *
820  const bt_component_filter *component, uint64_t index)
821  __BT_NOEXCEPT;
822 
849 extern const bt_port_input *
851  const bt_component_filter *component, const char *name)
852  __BT_NOEXCEPT;
853 
868  const bt_component_filter *component) __BT_NOEXCEPT;
869 
899 extern const bt_port_output *
901  const bt_component_filter *component, uint64_t index)
902  __BT_NOEXCEPT;
903 
930 extern const bt_port_output *
932  const bt_component_filter *component, const char *name)
933  __BT_NOEXCEPT;
934 
957 extern void bt_component_filter_get_ref(
958  const bt_component_filter *component) __BT_NOEXCEPT;
959 
975 extern void bt_component_filter_put_ref(
976  const bt_component_filter *component) __BT_NOEXCEPT;
977 
992 #define BT_COMPONENT_FILTER_PUT_REF_AND_RESET(_component) \
993  do { \
994  bt_component_filter_put_ref(_component); \
995  (_component) = NULL; \
996  } while (0)
997 
1023 #define BT_COMPONENT_FILTER_MOVE_REF(_dst, _src) \
1024  do { \
1025  bt_component_filter_put_ref(_dst); \
1026  (_dst) = (_src); \
1027  (_src) = NULL; \
1028  } while (0)
1029 
1050 extern const bt_component_class_sink *
1052  const bt_component_sink *component) __BT_NOEXCEPT;
1053 
1076 static inline
1078  const bt_component_sink *component) __BT_NOEXCEPT
1079 {
1080  return __BT_UPCAST_CONST(bt_component, component);
1081 }
1082 
1104  const bt_component_sink *component) __BT_NOEXCEPT;
1105 
1135 extern const bt_port_input *
1137  const bt_component_sink *component, uint64_t index)
1138  __BT_NOEXCEPT;
1139 
1166 extern const bt_port_input *
1168  const bt_component_sink *component, const char *name)
1169  __BT_NOEXCEPT;
1170 
1193 extern void bt_component_sink_get_ref(
1194  const bt_component_sink *component) __BT_NOEXCEPT;
1195 
1211 extern void bt_component_sink_put_ref(
1212  const bt_component_sink *component) __BT_NOEXCEPT;
1213 
1228 #define BT_COMPONENT_SINK_PUT_REF_AND_RESET(_component) \
1229  do { \
1230  bt_component_sink_put_ref(_component); \
1231  (_component) = NULL; \
1232  } while (0)
1233 
1260 #define BT_COMPONENT_SINK_MOVE_REF(_dst, _src) \
1261  do { \
1262  bt_component_sink_put_ref(_dst); \
1263  (_dst) = (_src); \
1264  (_src) = NULL; \
1265  } while (0)
1266 
1271 #ifdef __cplusplus
1272 }
1273 #endif
1274 
1275 #endif /* BABELTRACE2_GRAPH_COMPONENT_H */
const char * bt_component_get_name(const bt_component *component)
Returns the name of the component component.
struct bt_component_class_source bt_component_class_source
Source component class.
Definition: types.h:28
static const bt_component * bt_component_source_as_component_const(const bt_component_source *component)
Upcasts the source component component to the common bt_component type.
Definition: component.h:524
struct bt_component_sink bt_component_sink
Sink component.
Definition: types.h:31
uint64_t bt_component_filter_get_output_port_count(const bt_component_filter *component)
Returns the number of output ports that the filter component component has.
void bt_component_filter_get_ref(const bt_component_filter *component)
Increments the reference count of the filter component component.
struct bt_port_input bt_port_input
Input port.
Definition: types.h:66
struct bt_component_source bt_component_source
Source component.
Definition: types.h:32
struct bt_component_class_filter bt_component_class_filter
Filter component class.
Definition: types.h:26
struct bt_port_output bt_port_output
Output port.
Definition: types.h:67
uint64_t bt_component_filter_get_input_port_count(const bt_component_filter *component)
Returns the number of input ports that the filter component component has.
const bt_port_input * bt_component_filter_borrow_input_port_by_name_const(const bt_component_filter *component, const char *name)
Borrows the input port named name from the filter component component.
static bt_bool bt_component_is_filter(const bt_component *component)
Returns whether or not the component component is a filter component.
Definition: component.h:285
static const bt_component * bt_component_filter_as_component_const(const bt_component_filter *component)
Upcasts the filter component component to the common bt_component type.
Definition: component.h:760
struct bt_component_class bt_component_class
Component class.
Definition: types.h:25
const bt_port_input * bt_component_sink_borrow_input_port_by_name_const(const bt_component_sink *component, const char *name)
Borrows the output port named name from the sink component component.
uint64_t bt_component_source_get_output_port_count(const bt_component_source *component)
Returns the number of output ports that the source component component has.
struct bt_component_filter bt_component_filter
Filter component.
Definition: types.h:30
bt_component_class_type
Component class type enumerators.
Definition: component-class.h:202
static bt_bool bt_component_is_sink(const bt_component *component)
Returns whether or not the component component is a sink component.
Definition: component.h:308
const bt_port_output * bt_component_source_borrow_output_port_by_name_const(const bt_component_source *component, const char *name)
Borrows the output port named name from the source component component.
bt_logging_level bt_component_get_logging_level(const bt_component *component)
Returns the logging level of the component component and its message iterators, if any...
uint64_t bt_component_sink_get_input_port_count(const bt_component_sink *component)
Returns the number of input ports that the sink component component has.
static const bt_component * bt_component_sink_as_component_const(const bt_component_sink *component)
Upcasts the sink component component to the common bt_component type.
Definition: component.h:1077
const bt_port_output * bt_component_filter_borrow_output_port_by_index_const(const bt_component_filter *component, uint64_t index)
Borrows the output port at index index from the filter component component.
const bt_component_class_sink * bt_component_sink_borrow_class_const(const bt_component_sink *component)
Borrows the class of the sink component component.
const bt_component_class * bt_component_borrow_class_const(const bt_component *component)
Borrows the class of the component component.
struct bt_component bt_component
Component.
Definition: types.h:24
bt_logging_level
Logging level enumerators.
Definition: logging.h:97
struct bt_component_class_sink bt_component_class_sink
Sink component class.
Definition: types.h:27
int bt_bool
Babeltrace 2 boolean type.
Definition: types.h:126
Filter component class.
Definition: component-class.h:213
void bt_component_filter_put_ref(const bt_component_filter *component)
Decrements the reference count of the filter component component.
bt_component_class_type bt_component_get_class_type(const bt_component *component)
Returns the type enumerator of the class of the component component.
const bt_component_class_source * bt_component_source_borrow_class_const(const bt_component_source *component)
Borrows the class of the source component component.
Source component class.
Definition: component-class.h:207
void bt_component_source_put_ref(const bt_component_source *component)
Decrements the reference count of the source component component.
void bt_component_sink_get_ref(const bt_component_sink *component)
Increments the reference count of the sink component component.
const bt_port_input * bt_component_filter_borrow_input_port_by_index_const(const bt_component_filter *component, uint64_t index)
Borrows the input port at index index from the filter component component.
const bt_port_input * bt_component_sink_borrow_input_port_by_index_const(const bt_component_sink *component, uint64_t index)
Borrows the input port at index index from the sink component component.
const bt_component_class_filter * bt_component_filter_borrow_class_const(const bt_component_filter *component)
Borrows the class of the filter component component.
static bt_bool bt_component_is_source(const bt_component *component)
Returns whether or not the component component is a source component.
Definition: component.h:262
const bt_port_output * bt_component_source_borrow_output_port_by_index_const(const bt_component_source *component, uint64_t index)
Borrows the output port at index index from the source component component.
void bt_component_get_ref(const bt_component *component)
Increments the reference count of the component component.
void bt_component_sink_put_ref(const bt_component_sink *component)
Decrements the reference count of the sink component component.
Sink component class.
Definition: component-class.h:219
const bt_port_output * bt_component_filter_borrow_output_port_by_name_const(const bt_component_filter *component, const char *name)
Borrows the output port named name from the filter component component.
void bt_component_put_ref(const bt_component *component)
Decrements the reference count of the component component.
void bt_component_source_get_ref(const bt_component_source *component)
Increments the reference count of the source component component.