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 /* IWYU pragma: private, include <babeltrace2/babeltrace.h> */
12 #ifndef __BT_IN_BABELTRACE_H
13 # error "Please include <babeltrace2/babeltrace.h> instead."
16 #include <babeltrace2/types.h>
23 @defgroup api-self-comp-port Self component ports
24 @ingroup api-self-comp
27 Private views of \bt_p_port for \bt_comp_cls instance methods.
29 The #bt_self_component_port, #bt_self_component_port_input, and
30 #bt_self_component_port_output types are private views of a \bt_port
31 from within a component class
32 \ref api-comp-cls-dev-instance-meth "instance method".
34 Borrow the \bt_self_comp of a port with
35 bt_self_component_port_borrow_component().
37 Get the user data attached to a port with
38 bt_self_component_port_get_data().
40 \ref api-fund-c-typing "Upcast" the "self" (private) types to the
41 public and common self component port types with the
42 <code>bt_self_component_port*_as_port*()</code> and
43 <code>bt_self_component_port_*_as_self_component_port()</code>
53 @typedef struct bt_self_component_port bt_self_component_port;
56 Self component \bt_comp.
58 @typedef struct bt_self_component_port_input bt_self_component_port_input;
61 Self component \bt_iport.
63 @typedef struct bt_self_component_port_output bt_self_component_port_output;
66 Self component \bt_oport.
72 @name Component access
78 Borrows the \bt_comp of the \bt_port \bt_p{self_component_port}.
80 @param[in] self_component_port
81 Port from which to borrow the component which owns it.
84 Component which owns \bt_p{self_component_port}.
86 @bt_pre_not_null{self_component_port}
88 extern bt_self_component
*bt_self_component_port_borrow_component(
89 bt_self_component_port
*self_component_port
);
94 @name User data access
100 Returns the user data of the \bt_port \bt_p{self_component_port}.
102 You can attach user data to a port when you add it to a component with
103 bt_self_component_source_add_output_port(),
104 bt_self_component_filter_add_input_port(),
105 bt_self_component_filter_add_output_port(), and
106 bt_self_component_sink_add_input_port().
108 @param[in] self_component_port
109 Port of which to get the user data.
112 User data of \bt_p{self_component_port}.
114 @bt_pre_not_null{self_component_port}
116 extern void *bt_self_component_port_get_data(
117 const bt_self_component_port
*self_component_port
);
122 @name Self to public upcast
128 \ref api-fund-c-typing "Upcasts" the self component port
129 \bt_p{self_component_port} to the public #bt_port type.
131 @param[in] self_component_port
139 \bt_p{self_component_port} as a public port.
142 const bt_port
*bt_self_component_port_as_port(
143 bt_self_component_port
*self_component_port
)
145 return __BT_UPCAST_CONST(bt_port
, self_component_port
);
150 \ref api-fund-c-typing "Upcasts" the self component \bt_iport
151 \bt_p{self_component_port} to the public #bt_port_input type.
153 @param[in] self_component_port
155 Input port to upcast.
161 \bt_p{self_component_port} as a public input port.
164 const bt_port_input
*bt_self_component_port_input_as_port_input(
165 const bt_self_component_port_input
*self_component_port
)
167 return __BT_UPCAST_CONST(bt_port_input
, self_component_port
);
172 \ref api-fund-c-typing "Upcasts" the self component \bt_oport
173 \bt_p{self_component_port} to the public #bt_port_output type.
175 @param[in] self_component_port
177 Output port to upcast.
183 \bt_p{self_component_port} as a public output port.
186 const bt_port_output
*bt_self_component_port_output_as_port_output(
187 bt_self_component_port_output
*self_component_port
)
189 return __BT_UPCAST_CONST(bt_port_output
, self_component_port
);
195 @name Self to common self upcast
201 \ref api-fund-c-typing "Upcasts" the self \bt_iport
202 \bt_p{self_component_port} to the common #bt_self_component_port
205 @param[in] self_component_port
207 Input port to upcast.
213 \bt_p{self_component_port} as a common self component port.
216 bt_self_component_port
*
217 bt_self_component_port_input_as_self_component_port(
218 bt_self_component_port_input
*self_component_port
)
220 return __BT_UPCAST(bt_self_component_port
, self_component_port
);
225 \ref api-fund-c-typing "Upcasts" the self \bt_oport
226 \bt_p{self_component_port} to the common #bt_self_component_port
229 @param[in] self_component_port
231 Output port to upcast.
237 \bt_p{self_component_port} as a common self component port.
240 bt_self_component_port
*
241 bt_self_component_port_output_as_self_component_port(
242 bt_self_component_port_output
*self_component_port
)
244 return __BT_UPCAST(bt_self_component_port
, self_component_port
);
255 #endif /* BABELTRACE2_GRAPH_SELF_COMPONENT_PORT_H */