1 #ifndef BABELTRACE2_GRAPH_PORT_H
2 #define BABELTRACE2_GRAPH_PORT_H
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
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:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
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
26 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
32 #include <babeltrace2/types.h>
39 @defgroup api-port Ports
43 \bt_c_comp input and output ports.
45 A <strong><em>port</em></strong> is a point of \bt_conn between
48 @image html component-zoom.png
50 A port is a \ref api-fund-shared-object "shared object": get a new
51 reference with bt_port_get_ref() and put an existing reference with
54 The common C type of a port is #bt_port.
56 There are two types of ports:
59 <dt>\anchor api-port-in Input port</dt>
61 Input connection point from which \bt_p_msg are received.
63 Filter and sink components have input ports.
65 An input port's specific type is #bt_port_input and its type
66 enumerator is #BT_PORT_TYPE_INPUT.
68 \ref api-fund-c-typing "Upcast" the #bt_port_input type to the
69 #bt_port type with bt_port_input_as_port_const().
71 Get a new input port reference with bt_port_input_get_ref() and put
72 an existing one with bt_port_input_put_ref().
75 <dt>\anchor api-port-out Output port</dt>
77 Output connection point to which messages are sent.
79 Source and filter components have output ports.
81 An output port's specific type is #bt_port_output and its type
82 enumerator is #BT_PORT_TYPE_OUTPUT.
84 \ref api-fund-c-typing "Upcast" the #bt_port_output type to the
85 #bt_port type with bt_port_output_as_port_const().
87 Get a new output port reference with bt_port_output_get_ref() and
88 put an existing one with bt_port_output_put_ref().
92 Get a port's type enumerator with bt_port_get_type(). You can also use
93 the bt_port_is_input() and bt_port_is_output() helper functions.
95 A \bt_comp can add a port with:
97 - bt_self_component_source_add_output_port()
98 - bt_self_component_filter_add_input_port()
99 - bt_self_component_filter_add_output_port()
100 - bt_self_component_sink_add_input_port()
102 Borrow a port's \bt_conn, if any, with
103 bt_port_borrow_connection_const().
105 Borrow the component to which a port belongs with
106 bt_port_borrow_component_const().
110 A port has the following common properties:
114 \anchor api-port-prop-name
120 For a given \bt_comp:
122 - Each input port has a unique name.
123 - Each output port has a unique name.
125 A port's name is set when the component adds it; you cannot change
128 Get a port's name with bt_port_get_name().
132 \anchor api-port-prop-is-connected
136 Whether or not the port is currently connected to another port.
138 Get whether or not a port is connected with bt_port_is_connected().
140 When a port is unconnected, bt_port_borrow_connection_const()
152 @typedef struct bt_port bt_port;
157 @typedef struct bt_port_input bt_port_input;
162 @typedef struct bt_port_output bt_port_output;
177 Port type enumerators.
179 typedef enum bt_port_type
{
184 BT_PORT_TYPE_INPUT
= 1 << 0,
190 BT_PORT_TYPE_OUTPUT
= 1 << 1,
195 Returns the type enumerator of the port \bt_p{port}.
198 Port of which to get the type enumerator
201 Type enumerator of \bt_p{port}.
203 @bt_pre_not_null{port}
205 @sa bt_port_is_input() —
206 Returns whether or not a port is an \bt_iport.
207 @sa bt_port_is_output() —
208 Returns whether or not a port is an \bt_oport.
210 extern bt_port_type
bt_port_get_type(const bt_port
*port
);
214 Returns whether or not the port \bt_p{port} is an \bt_iport.
220 #BT_TRUE if \bt_p{port} is an input port.
222 @bt_pre_not_null{port}
224 @sa bt_port_get_type() —
225 Returns the type enumerator of a port.
228 bt_bool
bt_port_is_input(const bt_port
*port
)
230 return bt_port_get_type(port
) == BT_PORT_TYPE_INPUT
;
235 Returns whether or not the port \bt_p{port} is an \bt_oport.
241 #BT_TRUE if \bt_p{port} is an output port.
243 @bt_pre_not_null{port}
245 @sa bt_port_get_type() —
246 Returns the type enumerator of a port.
249 bt_bool
bt_port_is_output(const bt_port
*port
)
251 return bt_port_get_type(port
) == BT_PORT_TYPE_OUTPUT
;
257 @name Connection access
263 Borrows the \bt_conn of the port \bt_p{port}.
265 This function returns \c NULL if \bt_p{port} is unconnected
266 (bt_port_is_connected() returns #BT_FALSE).
269 Port of which to borrow the connection.
272 \em Borrowed reference of the connection of \bt_p{port}.
274 @bt_pre_not_null{port}
276 extern const bt_connection
*bt_port_borrow_connection_const(
277 const bt_port
*port
);
282 @name Component access
288 Borrows the \bt_comp to which the port \bt_p{port} belongs.
291 Port of which to borrow the component which owns it.
294 \em Borrowed reference of the component which owns \bt_p{port}.
296 @bt_pre_not_null{port}
298 extern const bt_component
*bt_port_borrow_component_const(
299 const bt_port
*port
);
310 Returns the name of the port \bt_p{port}.
312 See the \ref api-port-prop-name "name" property.
315 Port of which to get the name.
319 Name of \bt_p{port}, or \c NULL if none.
321 The returned pointer remains valid as long as \bt_p{port} exists.
324 @bt_pre_not_null{port}
326 extern const char *bt_port_get_name(const bt_port
*port
);
330 Returns whether or not the port \bt_p{port} is connected.
332 See the \ref api-port-prop-is-connected "is connected?" property.
335 Port of which to get whether or not it's connected.
338 #BT_TRUE if \bt_p{port} is connected.
340 @bt_pre_not_null{port}
342 extern bt_bool
bt_port_is_connected(const bt_port
*port
);
347 @name Reference count (common)
353 Increments the \ref api-fund-shared-object "reference count" of
354 the port \bt_p{port}.
358 Port of which to increment the reference count.
363 @sa bt_port_put_ref() —
364 Decrements the reference count of a port.
366 extern void bt_port_get_ref(const bt_port
*port
);
370 Decrements the \ref api-fund-shared-object "reference count" of
371 the port \bt_p{port}.
375 Port of which to decrement the reference count.
380 @sa bt_port_get_ref() —
381 Increments the reference count of a port.
383 extern void bt_port_put_ref(const bt_port
*port
);
387 Decrements the reference count of the port
388 \bt_p{_port}, and then sets \bt_p{_port} to \c NULL.
392 Port of which to decrement the reference count.
397 @bt_pre_assign_expr{_port}
399 #define BT_PORT_PUT_REF_AND_RESET(_port) \
401 bt_port_put_ref(_port); \
407 Decrements the reference count of the port \bt_p{_dst}, sets
408 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
410 This macro effectively moves a port reference from the
411 expression \bt_p{_src} to the expression \bt_p{_dst}, putting the
412 existing \bt_p{_dst} reference.
416 Destination expression.
427 @bt_pre_assign_expr{_dst}
428 @bt_pre_assign_expr{_src}
430 #define BT_PORT_MOVE_REF(_dst, _src) \
432 bt_port_put_ref(_dst); \
446 \ref api-fund-c-typing "Upcasts" the \bt_iport \bt_p{port} to the
447 common #bt_port type.
451 Input port to upcast.
457 \bt_p{port} as a common port.
460 const bt_port
*bt_port_input_as_port_const(const bt_port_input
*port
)
462 return __BT_UPCAST_CONST(bt_port
, port
);
467 Increments the \ref api-fund-shared-object "reference count" of
468 the \bt_iport \bt_p{port}.
472 Input port of which to increment the reference count.
477 @sa bt_port_input_put_ref() —
478 Decrements the reference count of an input port.
480 extern void bt_port_input_get_ref(const bt_port_input
*port
);
484 Decrements the \ref api-fund-shared-object "reference count" of
485 the \bt_iport \bt_p{port}.
489 Input port of which to decrement the reference count.
494 @sa bt_port_input_get_ref() —
495 Increments the reference count of an input port.
497 extern void bt_port_input_put_ref(const bt_port_input
*port
);
501 Decrements the reference count of the \bt_iport
502 \bt_p{_port}, and then sets \bt_p{_port} to \c NULL.
506 Input port of which to decrement the reference count.
511 @bt_pre_assign_expr{_port}
513 #define BT_PORT_INPUT_PUT_REF_AND_RESET(_port) \
515 bt_port_input_put_ref(_port); \
521 Decrements the reference count of the \bt_iport \bt_p{_dst}, sets
522 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
524 This macro effectively moves an \bt_iport reference from the
525 expression \bt_p{_src} to the expression \bt_p{_dst}, putting the
526 existing \bt_p{_dst} reference.
530 Destination expression.
541 @bt_pre_assign_expr{_dst}
542 @bt_pre_assign_expr{_src}
544 #define BT_PORT_INPUT_MOVE_REF(_dst, _src) \
546 bt_port_input_put_ref(_dst); \
560 \ref api-fund-c-typing "Upcasts" the \bt_oport \bt_p{port} to the
561 common #bt_port type.
565 Output port to upcast.
571 \bt_p{port} as a common port.
574 const bt_port
*bt_port_output_as_port_const(const bt_port_output
*port
)
576 return __BT_UPCAST_CONST(bt_port
, port
);
581 Increments the \ref api-fund-shared-object "reference count" of
582 the \bt_oport \bt_p{port}.
586 Output port of which to increment the reference count.
591 @sa bt_port_output_put_ref() —
592 Decrements the reference count of a \bt_oport.
594 extern void bt_port_output_get_ref(const bt_port_output
*port
);
598 Decrements the \ref api-fund-shared-object "reference count" of
599 the \bt_oport \bt_p{port}.
603 Output port of which to decrement the reference count.
608 @sa bt_port_output_get_ref() —
609 Increments the reference count of a \bt_oport.
611 extern void bt_port_output_put_ref(const bt_port_output
*port
);
615 Decrements the reference count of the \bt_oport
616 \bt_p{_port}, and then sets \bt_p{_port} to \c NULL.
620 Output port of which to decrement the reference count.
625 @bt_pre_assign_expr{_port}
627 #define BT_PORT_OUTPUT_PUT_REF_AND_RESET(_port) \
629 bt_port_output_put_ref(_port); \
635 Decrements the reference count of the \bt_oport \bt_p{_dst}, sets
636 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
638 This macro effectively moves an \bt_oport reference from the
639 expression \bt_p{_src} to the expression \bt_p{_dst}, putting the
640 existing \bt_p{_dst} reference.
644 Destination expression.
655 @bt_pre_assign_expr{_dst}
656 @bt_pre_assign_expr{_src}
658 #define BT_PORT_OUTPUT_MOVE_REF(_dst, _src) \
660 bt_port_output_put_ref(_dst); \
673 #endif /* BABELTRACE2_GRAPH_PORT_H */
This page took 0.058693 seconds and 4 git commands to generate.