Babeltrace 2 C API  2.0.3
Open-source trace manipulation framework
component.h
1 #ifndef BABELTRACE2_GRAPH_COMPONENT_H
2 #define BABELTRACE2_GRAPH_COMPONENT_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 <babeltrace2/graph/component-class.h>
31 #include <babeltrace2/types.h>
32 #include <babeltrace2/logging.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
257  const bt_component *component);
258 
275 static inline
277 {
278  return bt_component_get_class_type(component) ==
280 }
281 
298 static inline
300 {
301  return bt_component_get_class_type(component) ==
303 }
304 
321 static inline
323 {
324  return bt_component_get_class_type(component) ==
326 }
327 
349  const bt_component *component);
350 
377 extern const char *bt_component_get_name(const bt_component *component);
378 
395  const bt_component *component);
396 
419 extern void bt_component_get_ref(const bt_component *component);
420 
436 extern void bt_component_put_ref(const bt_component *component);
437 
452 #define BT_COMPONENT_PUT_REF_AND_RESET(_component) \
453  do { \
454  bt_component_put_ref(_component); \
455  (_component) = NULL; \
456  } while (0)
457 
483 #define BT_COMPONENT_MOVE_REF(_dst, _src) \
484  do { \
485  bt_component_put_ref(_dst); \
486  (_dst) = (_src); \
487  (_src) = NULL; \
488  } while (0)
489 
510 extern const bt_component_class_source *
512  const bt_component_source *component);
513 
536 static inline
538  const bt_component_source *component)
539 {
540  return __BT_UPCAST_CONST(bt_component, component);
541 }
542 
564  const bt_component_source *component);
565 
595 extern const bt_port_output *
597  const bt_component_source *component, uint64_t index);
598 
625 extern const bt_port_output *
627  const bt_component_source *component, const char *name);
628 
651 extern void bt_component_source_get_ref(
652  const bt_component_source *component);
653 
669 extern void bt_component_source_put_ref(
670  const bt_component_source *component);
671 
686 #define BT_COMPONENT_SOURCE_PUT_REF_AND_RESET(_component) \
687  do { \
688  bt_component_source_put_ref(_component); \
689  (_component) = NULL; \
690  } while (0)
691 
717 #define BT_COMPONENT_SOURCE_MOVE_REF(_dst, _src) \
718  do { \
719  bt_component_source_put_ref(_dst); \
720  (_dst) = (_src); \
721  (_src) = NULL; \
722  } while (0)
723 
744 extern const bt_component_class_filter *
746  const bt_component_filter *component);
747 
770 static inline
772  const bt_component_filter *component)
773 {
774  return __BT_UPCAST_CONST(bt_component, component);
775 }
776 
798  const bt_component_filter *component);
799 
829 extern const bt_port_input *
831  const bt_component_filter *component, uint64_t index);
832 
859 extern const bt_port_input *
861  const bt_component_filter *component, const char *name);
862 
877  const bt_component_filter *component);
878 
908 extern const bt_port_output *
910  const bt_component_filter *component, uint64_t index);
911 
938 extern const bt_port_output *
940  const bt_component_filter *component, const char *name);
941 
964 extern void bt_component_filter_get_ref(
965  const bt_component_filter *component);
966 
982 extern void bt_component_filter_put_ref(
983  const bt_component_filter *component);
984 
999 #define BT_COMPONENT_FILTER_PUT_REF_AND_RESET(_component) \
1000  do { \
1001  bt_component_filter_put_ref(_component); \
1002  (_component) = NULL; \
1003  } while (0)
1004 
1030 #define BT_COMPONENT_FILTER_MOVE_REF(_dst, _src) \
1031  do { \
1032  bt_component_filter_put_ref(_dst); \
1033  (_dst) = (_src); \
1034  (_src) = NULL; \
1035  } while (0)
1036 
1057 extern const bt_component_class_sink *
1059  const bt_component_sink *component);
1060 
1083 static inline
1085  const bt_component_sink *component)
1086 {
1087  return __BT_UPCAST_CONST(bt_component, component);
1088 }
1089 
1111  const bt_component_sink *component);
1112 
1142 extern const bt_port_input *
1144  const bt_component_sink *component, uint64_t index);
1145 
1172 extern const bt_port_input *
1174  const bt_component_sink *component, const char *name);
1175 
1198 extern void bt_component_sink_get_ref(
1199  const bt_component_sink *component);
1200 
1216 extern void bt_component_sink_put_ref(
1217  const bt_component_sink *component);
1218 
1233 #define BT_COMPONENT_SINK_PUT_REF_AND_RESET(_component) \
1234  do { \
1235  bt_component_sink_put_ref(_component); \
1236  (_component) = NULL; \
1237  } while (0)
1238 
1265 #define BT_COMPONENT_SINK_MOVE_REF(_dst, _src) \
1266  do { \
1267  bt_component_sink_put_ref(_dst); \
1268  (_dst) = (_src); \
1269  (_src) = NULL; \
1270  } while (0)
1271 
1276 #ifdef __cplusplus
1277 }
1278 #endif
1279 
1280 #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:42
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:537
struct bt_component_sink bt_component_sink
Sink component.
Definition: types.h:45
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:80
struct bt_component_source bt_component_source
Source component.
Definition: types.h:46
struct bt_component_class_filter bt_component_class_filter
Filter component class.
Definition: types.h:40
struct bt_port_output bt_port_output
Output port.
Definition: types.h:81
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:299
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:771
struct bt_component_class bt_component_class
Component class.
Definition: types.h:39
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:44
bt_component_class_type
Component class type enumerators.
Definition: component-class.h:214
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:322
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:1084
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:38
bt_logging_level
Logging level enumerators.
Definition: logging.h:110
struct bt_component_class_sink bt_component_class_sink
Sink component class.
Definition: types.h:41
int bt_bool
Babeltrace 2 boolean type.
Definition: types.h:140
Filter component class.
Definition: component-class.h:225
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:219
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:276
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:231
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.