2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation
7 #ifndef BABELTRACE2_GRAPH_SELF_COMPONENT_PORT_H
8 #define BABELTRACE2_GRAPH_SELF_COMPONENT_PORT_H
10 #ifndef __BT_IN_BABELTRACE_H
11 # error "Please include <babeltrace2/babeltrace.h> instead."
14 #include <babeltrace2/types.h>
21 @defgroup api-self-comp-port Self component ports
22 @ingroup api-self-comp
25 Private views of \bt_p_port for \bt_comp_cls instance methods.
27 The #bt_self_component_port, #bt_self_component_port_input, and
28 #bt_self_component_port_output types are private views of a \bt_port
29 from within a component class
30 \ref api-comp-cls-dev-instance-meth "instance method".
32 Borrow the \bt_self_comp of a port with
33 bt_self_component_port_borrow_component().
35 Get the user data attached to a port with
36 bt_self_component_port_get_data().
38 \ref api-fund-c-typing "Upcast" the "self" (private) types to the
39 public and common self component port types with the
40 <code>bt_self_component_port*_as_port*()</code> and
41 <code>bt_self_component_port_*_as_self_component_port()</code>
51 @typedef struct bt_self_component_port bt_self_component_port;
54 Self component \bt_comp.
56 @typedef struct bt_self_component_port_input bt_self_component_port_input;
59 Self component \bt_iport.
61 @typedef struct bt_self_component_port_output bt_self_component_port_output;
64 Self component \bt_oport.
70 @name Component access
76 Borrows the \bt_comp of the \bt_port \bt_p{self_component_port}.
78 @param[in] self_component_port
79 Port from which to borrow the component which owns it.
82 Component which owns \bt_p{self_component_port}.
84 @bt_pre_not_null{self_component_port}
86 extern bt_self_component
*bt_self_component_port_borrow_component(
87 bt_self_component_port
*self_component_port
);
92 @name User data access
98 Returns the user data of the \bt_port \bt_p{self_component_port}.
100 You can attach user data to a port when you add it to a component with
101 bt_self_component_source_add_output_port(),
102 bt_self_component_filter_add_input_port(),
103 bt_self_component_filter_add_output_port(), and
104 bt_self_component_sink_add_input_port().
106 @param[in] self_component_port
107 Port of which to get the user data.
110 User data of \bt_p{self_component_port}.
112 @bt_pre_not_null{self_component_port}
114 extern void *bt_self_component_port_get_data(
115 const bt_self_component_port
*self_component_port
);
120 @name Self to public upcast
126 \ref api-fund-c-typing "Upcasts" the self component port
127 \bt_p{self_component_port} to the public #bt_port type.
129 @param[in] self_component_port
137 \bt_p{self_component_port} as a public port.
140 const bt_port
*bt_self_component_port_as_port(
141 bt_self_component_port
*self_component_port
)
143 return __BT_UPCAST_CONST(bt_port
, self_component_port
);
148 \ref api-fund-c-typing "Upcasts" the self component \bt_iport
149 \bt_p{self_component_port} to the public #bt_port_input type.
151 @param[in] self_component_port
153 Input port to upcast.
159 \bt_p{self_component_port} as a public input port.
162 const bt_port_input
*bt_self_component_port_input_as_port_input(
163 const bt_self_component_port_input
*self_component_port
)
165 return __BT_UPCAST_CONST(bt_port_input
, self_component_port
);
170 \ref api-fund-c-typing "Upcasts" the self component \bt_oport
171 \bt_p{self_component_port} to the public #bt_port_output type.
173 @param[in] self_component_port
175 Output port to upcast.
181 \bt_p{self_component_port} as a public output port.
184 const bt_port_output
*bt_self_component_port_output_as_port_output(
185 bt_self_component_port_output
*self_component_port
)
187 return __BT_UPCAST_CONST(bt_port_output
, self_component_port
);
193 @name Self to common self upcast
199 \ref api-fund-c-typing "Upcasts" the self \bt_iport
200 \bt_p{self_component_port} to the common #bt_self_component_port
203 @param[in] self_component_port
205 Input port to upcast.
211 \bt_p{self_component_port} as a common self component port.
214 bt_self_component_port
*
215 bt_self_component_port_input_as_self_component_port(
216 bt_self_component_port_input
*self_component_port
)
218 return __BT_UPCAST(bt_self_component_port
, self_component_port
);
223 \ref api-fund-c-typing "Upcasts" the self \bt_oport
224 \bt_p{self_component_port} to the common #bt_self_component_port
227 @param[in] self_component_port
229 Output port to upcast.
235 \bt_p{self_component_port} as a common self component port.
238 bt_self_component_port
*
239 bt_self_component_port_output_as_self_component_port(
240 bt_self_component_port_output
*self_component_port
)
242 return __BT_UPCAST(bt_self_component_port
, self_component_port
);
253 #endif /* BABELTRACE2_GRAPH_SELF_COMPONENT_PORT_H */