Commit | Line | Data |
---|---|---|
890882ef | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
890882ef | 3 | * |
0235b0db | 4 | * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation |
890882ef PP |
5 | */ |
6 | ||
0235b0db MJ |
7 | #ifndef BABELTRACE2_GRAPH_SELF_COMPONENT_H |
8 | #define BABELTRACE2_GRAPH_SELF_COMPONENT_H | |
9 | ||
4fa90f32 PP |
10 | #ifndef __BT_IN_BABELTRACE_H |
11 | # error "Please include <babeltrace2/babeltrace.h> instead." | |
12 | #endif | |
13 | ||
3fadfbc0 | 14 | #include <babeltrace2/types.h> |
b19ff26f | 15 | |
890882ef PP |
16 | #ifdef __cplusplus |
17 | extern "C" { | |
18 | #endif | |
19 | ||
43c59509 PP |
20 | /*! |
21 | @defgroup api-self-comp Self components | |
22 | @ingroup api-comp-cls-dev | |
23 | ||
24 | @brief | |
25 | Private views of \bt_p_comp for instance methods. | |
26 | ||
27 | The #bt_self_component, #bt_self_component_source, | |
28 | #bt_self_component_filter, #bt_self_component_sink types are | |
29 | private views of a \bt_comp from within a component class | |
30 | \ref api-comp-cls-dev-instance-meth "instance method". | |
31 | ||
32 | Add a \bt_port to a component with | |
33 | bt_self_component_source_add_output_port(), | |
34 | bt_self_component_filter_add_input_port(), | |
35 | bt_self_component_filter_add_output_port(), and | |
36 | bt_self_component_sink_add_input_port(). | |
37 | ||
38 | When you add a port to a component, you can attach custom user data | |
39 | to it (\bt_voidp). You can retrieve this user data | |
40 | afterwards with bt_self_component_port_get_data(). | |
41 | ||
42 | Borrow a \bt_self_comp_port from a component by index with | |
43 | bt_self_component_source_borrow_output_port_by_index(), | |
44 | bt_self_component_filter_borrow_input_port_by_index(), | |
45 | bt_self_component_filter_borrow_output_port_by_index(), and | |
46 | bt_self_component_sink_borrow_input_port_by_index(). | |
47 | ||
48 | Borrow a \bt_self_comp_port from a component by name with | |
49 | bt_self_component_source_borrow_output_port_by_name(), | |
50 | bt_self_component_filter_borrow_input_port_by_name(), | |
51 | bt_self_component_filter_borrow_output_port_by_name(), and | |
52 | bt_self_component_sink_borrow_input_port_by_name(). | |
53 | ||
54 | Set and get user data attached to a component with | |
55 | bt_self_component_set_data() and bt_self_component_get_data(). | |
56 | ||
57 | Get a component's owning trace processing \bt_graph's effective | |
58 | \bt_mip version with bt_self_component_get_graph_mip_version(). | |
59 | ||
60 | Check whether or not a \bt_sink_comp is interrupted with | |
61 | bt_self_component_sink_is_interrupted(). | |
62 | ||
63 | \ref api-fund-c-typing "Upcast" the "self" (private) types to the | |
64 | public and common self component types with the | |
65 | <code>bt_self_component*_as_component*()</code> and | |
66 | <code>bt_self_component_*_as_self_component()</code> functions. | |
67 | */ | |
68 | ||
69 | /*! @{ */ | |
70 | ||
71 | /*! | |
72 | @name Types | |
73 | @{ | |
74 | ||
75 | @typedef struct bt_self_component bt_self_component; | |
76 | ||
77 | @brief | |
78 | Self \bt_comp. | |
79 | ||
80 | @typedef struct bt_self_component_source bt_self_component_source; | |
81 | ||
82 | @brief | |
83 | Self \bt_src_comp. | |
84 | ||
85 | @typedef struct bt_self_component_filter bt_self_component_filter; | |
86 | ||
87 | @brief | |
88 | Self \bt_flt_comp. | |
89 | ||
90 | @typedef struct bt_self_component_sink bt_self_component_sink; | |
91 | ||
92 | @brief | |
93 | Self \bt_sink_comp. | |
94 | ||
95 | @typedef struct bt_self_component_source_configuration bt_self_component_source_configuration; | |
96 | ||
97 | @brief | |
98 | Self \bt_src_comp configuration. | |
99 | ||
100 | @typedef struct bt_self_component_filter_configuration bt_self_component_filter_configuration; | |
101 | ||
102 | @brief | |
103 | Self \bt_flt_comp configuration. | |
104 | ||
105 | @typedef struct bt_self_component_sink_configuration bt_self_component_sink_configuration; | |
106 | ||
107 | @brief | |
108 | Self \bt_sink_comp configuration. | |
109 | ||
110 | @} | |
111 | */ | |
112 | ||
113 | /*! | |
114 | @name Port adding | |
115 | @{ | |
116 | */ | |
117 | ||
118 | /*! | |
119 | @brief | |
120 | Status codes for bt_self_component_source_add_output_port(), | |
121 | bt_self_component_filter_add_input_port(), | |
122 | bt_self_component_filter_add_output_port(), and | |
123 | bt_self_component_sink_add_input_port(). | |
124 | */ | |
d24d5663 | 125 | typedef enum bt_self_component_add_port_status { |
43c59509 PP |
126 | /*! |
127 | @brief | |
128 | Success. | |
129 | */ | |
d24d5663 | 130 | BT_SELF_COMPONENT_ADD_PORT_STATUS_OK = __BT_FUNC_STATUS_OK, |
43c59509 PP |
131 | |
132 | /*! | |
133 | @brief | |
134 | Out of memory. | |
135 | */ | |
d24d5663 | 136 | BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, |
43c59509 PP |
137 | |
138 | /*! | |
139 | @brief | |
140 | Other error. | |
141 | */ | |
142 | BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, | |
d24d5663 | 143 | } bt_self_component_add_port_status; |
d94d92ac | 144 | |
43c59509 PP |
145 | /*! |
146 | @brief | |
147 | Adds an \bt_oport named \bt_p{name} and having the user data | |
148 | \bt_p{user_data} to the \bt_src_comp \bt_p{self_component}, | |
149 | and sets \bt_p{*self_component_port} to the resulting port. | |
150 | ||
151 | @attention | |
152 | You can only call this function from within the | |
153 | \ref api-comp-cls-dev-meth-init "initialization", | |
154 | \link api-comp-cls-dev-meth-iport-connected "input port connected"\endlink, | |
155 | and | |
156 | \link api-comp-cls-dev-meth-oport-connected "output port connected"\endlink | |
157 | methods. | |
158 | ||
159 | @param[in] self_component | |
160 | Source component instance. | |
161 | @param[in] name | |
162 | Name of the output port to add to \bt_p{self_component} (copied). | |
163 | @param[in] user_data | |
164 | User data of the output port to add to \bt_p{self_component}. | |
165 | @param[out] self_component_port | |
166 | <strong>On success, if not \c NULL</strong>, | |
167 | \bt_p{*self_component_port} is a \em borrowed reference of the | |
168 | created port. | |
169 | ||
170 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_OK | |
171 | Success. | |
172 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR | |
173 | Out of memory. | |
174 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR | |
175 | Other error. | |
176 | ||
177 | @bt_pre_not_null{self_component} | |
178 | @bt_pre_not_null{name} | |
179 | @pre | |
180 | No other output port within \bt_p{self_component} has the name | |
181 | \bt_p{name}. | |
182 | */ | |
183 | extern bt_self_component_add_port_status | |
184 | bt_self_component_source_add_output_port( | |
185 | bt_self_component_source *self_component, | |
186 | const char *name, void *user_data, | |
187 | bt_self_component_port_output **self_component_port); | |
188 | ||
189 | /*! | |
190 | @brief | |
191 | Adds an \bt_iport named \bt_p{name} and having the user data | |
192 | \bt_p{user_data} to the \bt_flt_comp \bt_p{self_component}, | |
193 | and sets \bt_p{*self_component_port} to the resulting port. | |
194 | ||
195 | @attention | |
196 | You can only call this function from within the | |
197 | \ref api-comp-cls-dev-meth-init "initialization", | |
198 | \link api-comp-cls-dev-meth-iport-connected "input port connected"\endlink, | |
199 | and | |
200 | \link api-comp-cls-dev-meth-oport-connected "output port connected"\endlink | |
201 | methods. | |
202 | ||
203 | @param[in] self_component | |
204 | Filter component instance. | |
205 | @param[in] name | |
206 | Name of the input port to add to \bt_p{self_component} (copied). | |
207 | @param[in] user_data | |
208 | User data of the input port to add to \bt_p{self_component}. | |
209 | @param[out] self_component_port | |
210 | <strong>On success, if not \c NULL</strong>, | |
211 | \bt_p{*self_component_port} is a \em borrowed reference of the | |
212 | created port. | |
213 | ||
214 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_OK | |
215 | Success. | |
216 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR | |
217 | Out of memory. | |
218 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR | |
219 | Other error. | |
220 | ||
221 | @bt_pre_not_null{self_component} | |
222 | @bt_pre_not_null{name} | |
223 | @pre | |
224 | No other input port within \bt_p{self_component} has the name | |
225 | \bt_p{name}. | |
226 | */ | |
227 | extern bt_self_component_add_port_status | |
228 | bt_self_component_filter_add_input_port( | |
229 | bt_self_component_filter *self_component, | |
230 | const char *name, void *user_data, | |
231 | bt_self_component_port_input **self_component_port); | |
232 | ||
233 | /*! | |
234 | @brief | |
235 | Adds an \bt_oport named \bt_p{name} and having the user data | |
236 | \bt_p{user_data} to the \bt_flt_comp \bt_p{self_component}, | |
237 | and sets \bt_p{*self_component_port} to the resulting port. | |
238 | ||
239 | @attention | |
240 | You can only call this function from within the | |
241 | \ref api-comp-cls-dev-meth-init "initialization", | |
242 | \link api-comp-cls-dev-meth-iport-connected "input port connected"\endlink, | |
243 | and | |
244 | \link api-comp-cls-dev-meth-oport-connected "output port connected"\endlink | |
245 | methods. | |
246 | ||
247 | @param[in] self_component | |
248 | Filter component instance. | |
249 | @param[in] name | |
250 | Name of the output port to add to \bt_p{self_component} (copied). | |
251 | @param[in] user_data | |
252 | User data of the output port to add to \bt_p{self_component}. | |
253 | @param[out] self_component_port | |
254 | <strong>On success, if not \c NULL</strong>, | |
255 | \bt_p{*self_component_port} is a \em borrowed reference of the | |
256 | created port. | |
257 | ||
258 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_OK | |
259 | Success. | |
260 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR | |
261 | Out of memory. | |
262 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR | |
263 | Other error. | |
264 | ||
265 | @bt_pre_not_null{self_component} | |
266 | @bt_pre_not_null{name} | |
267 | @pre | |
268 | No other output port within \bt_p{self_component} has the name | |
269 | \bt_p{name}. | |
270 | */ | |
271 | extern bt_self_component_add_port_status | |
272 | bt_self_component_filter_add_output_port( | |
273 | bt_self_component_filter *self_component, | |
274 | const char *name, void *user_data, | |
275 | bt_self_component_port_output **self_component_port); | |
276 | ||
277 | /*! | |
278 | @brief | |
279 | Adds an \bt_iport named \bt_p{name} and having the user data | |
280 | \bt_p{user_data} to the \bt_sink_comp \bt_p{self_component}, | |
281 | and sets \bt_p{*self_component_port} to the resulting port. | |
282 | ||
283 | @attention | |
284 | You can only call this function from within the | |
285 | \ref api-comp-cls-dev-meth-init "initialization", | |
286 | \link api-comp-cls-dev-meth-iport-connected "input port connected"\endlink, | |
287 | and | |
288 | \link api-comp-cls-dev-meth-oport-connected "output port connected"\endlink | |
289 | methods. | |
290 | ||
291 | @param[in] self_component | |
292 | Sink component instance. | |
293 | @param[in] name | |
294 | Name of the input port to add to \bt_p{self_component} (copied). | |
295 | @param[in] user_data | |
296 | User data of the input port to add to \bt_p{self_component}. | |
297 | @param[out] self_component_port | |
298 | <strong>On success, if not \c NULL</strong>, | |
299 | \bt_p{*self_component_port} is a \em borrowed reference of the | |
300 | created port. | |
301 | ||
302 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_OK | |
303 | Success. | |
304 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR | |
305 | Out of memory. | |
306 | @retval #BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR | |
307 | Other error. | |
308 | ||
309 | @bt_pre_not_null{self_component} | |
310 | @bt_pre_not_null{name} | |
311 | @pre | |
312 | No other input port within \bt_p{self_component} has the name | |
313 | \bt_p{name}. | |
314 | */ | |
315 | ||
316 | extern bt_self_component_add_port_status | |
317 | bt_self_component_sink_add_input_port( | |
318 | bt_self_component_sink *self_component, | |
319 | const char *name, void *user_data, | |
320 | bt_self_component_port_input **self_component_port); | |
321 | ||
322 | /*! @} */ | |
323 | ||
324 | /*! | |
325 | @name Port access | |
326 | @{ | |
327 | */ | |
328 | ||
329 | /*! | |
330 | @brief | |
331 | Borrows the \bt_self_comp_oport at index \bt_p{index} from the | |
332 | \bt_src_comp \bt_p{self_component}. | |
333 | ||
334 | @param[in] self_component | |
335 | Source component instance. | |
336 | @param[in] index | |
337 | Index of the output port to borrow from \bt_p{self_component}. | |
338 | ||
339 | @returns | |
340 | @parblock | |
341 | \em Borrowed reference of the output port of | |
342 | \bt_p{self_component} at index \bt_p{index}. | |
343 | ||
344 | The returned pointer remains valid as long as \bt_p{self_component} | |
345 | exists. | |
346 | @endparblock | |
347 | ||
348 | @bt_pre_not_null{self_component} | |
349 | @pre | |
350 | \bt_p{index} is less than the number of output ports | |
351 | \bt_p{self_component} has (as returned by | |
352 | bt_component_source_get_output_port_count()). | |
353 | ||
354 | @sa bt_component_source_get_output_port_count() — | |
355 | Returns the number of output ports that a source component has. | |
356 | */ | |
357 | extern bt_self_component_port_output * | |
358 | bt_self_component_source_borrow_output_port_by_index( | |
359 | bt_self_component_source *self_component, | |
360 | uint64_t index); | |
361 | ||
362 | /*! | |
363 | @brief | |
364 | Borrows the \bt_self_comp_iport at index \bt_p{index} from the | |
365 | \bt_flt_comp \bt_p{self_component}. | |
366 | ||
367 | @param[in] self_component | |
368 | Filter component instance. | |
369 | @param[in] index | |
370 | Index of the input port to borrow from \bt_p{self_component}. | |
371 | ||
372 | @returns | |
373 | @parblock | |
374 | \em Borrowed reference of the input port of | |
375 | \bt_p{self_component} at index \bt_p{index}. | |
376 | ||
377 | The returned pointer remains valid as long as \bt_p{self_component} | |
378 | exists. | |
379 | @endparblock | |
380 | ||
381 | @bt_pre_not_null{self_component} | |
382 | @pre | |
383 | \bt_p{index} is less than the number of input ports | |
384 | \bt_p{self_component} has (as returned by | |
385 | bt_component_filter_get_input_port_count()). | |
386 | ||
387 | @sa bt_component_filter_get_input_port_count() — | |
388 | Returns the number of input ports that a filter component has. | |
389 | */ | |
390 | extern bt_self_component_port_input * | |
391 | bt_self_component_filter_borrow_input_port_by_index( | |
392 | bt_self_component_filter *self_component, | |
393 | uint64_t index); | |
394 | ||
395 | /*! | |
396 | @brief | |
397 | Borrows the \bt_self_comp_oport at index \bt_p{index} from the | |
398 | \bt_flt_comp \bt_p{self_component}. | |
399 | ||
400 | @param[in] self_component | |
401 | Filter component instance. | |
402 | @param[in] index | |
403 | Index of the output port to borrow from \bt_p{self_component}. | |
404 | ||
405 | @returns | |
406 | @parblock | |
407 | \em Borrowed reference of the output port of | |
408 | \bt_p{self_component} at index \bt_p{index}. | |
409 | ||
410 | The returned pointer remains valid as long as \bt_p{self_component} | |
411 | exists. | |
412 | @endparblock | |
413 | ||
414 | @bt_pre_not_null{self_component} | |
415 | @pre | |
416 | \bt_p{index} is less than the number of output ports | |
417 | \bt_p{self_component} has (as returned by | |
418 | bt_component_filter_get_output_port_count()). | |
419 | ||
420 | @sa bt_component_filter_get_output_port_count() — | |
421 | Returns the number of output ports that a filter component has. | |
422 | */ | |
423 | extern bt_self_component_port_output * | |
424 | bt_self_component_filter_borrow_output_port_by_index( | |
425 | bt_self_component_filter *self_component, | |
426 | uint64_t index); | |
427 | ||
428 | /*! | |
429 | @brief | |
430 | Borrows the \bt_self_comp_iport at index \bt_p{index} from the | |
431 | \bt_sink_comp \bt_p{self_component}. | |
432 | ||
433 | @param[in] self_component | |
434 | Sink component instance. | |
435 | @param[in] index | |
436 | Index of the input port to borrow from \bt_p{self_component}. | |
437 | ||
438 | @returns | |
439 | @parblock | |
440 | \em Borrowed reference of the input port of | |
441 | \bt_p{self_component} at index \bt_p{index}. | |
442 | ||
443 | The returned pointer remains valid as long as \bt_p{self_component} | |
444 | exists. | |
445 | @endparblock | |
446 | ||
447 | @bt_pre_not_null{self_component} | |
448 | @pre | |
449 | \bt_p{index} is less than the number of input ports | |
450 | \bt_p{self_component} has (as returned by | |
451 | bt_component_sink_get_input_port_count()). | |
452 | ||
453 | @sa bt_component_sink_get_input_port_count() — | |
454 | Returns the number of input ports that a sink component has. | |
455 | */ | |
456 | extern bt_self_component_port_input * | |
457 | bt_self_component_sink_borrow_input_port_by_index( | |
458 | bt_self_component_sink *self_component, uint64_t index); | |
459 | ||
460 | /*! | |
461 | @brief | |
462 | Borrows the \bt_self_comp_oport named \bt_p{name} from the | |
463 | \bt_src_comp \bt_p{self_component}. | |
464 | ||
465 | If \bt_p{self_component} has no output port named \bt_p{name}, this | |
466 | function returns \c NULL. | |
467 | ||
468 | @param[in] self_component | |
469 | Source component instance. | |
470 | @param[in] name | |
471 | Name of the output port to borrow from \bt_p{self_component}. | |
472 | ||
473 | @returns | |
474 | @parblock | |
475 | \em Borrowed reference of the output port of | |
476 | \bt_p{self_component} named \bt_p{name}, or \c NULL if none. | |
477 | ||
478 | The returned pointer remains valid as long as \bt_p{self_component} | |
479 | exists. | |
480 | @endparblock | |
481 | ||
482 | @bt_pre_not_null{self_component} | |
483 | @bt_pre_not_null{name} | |
484 | */ | |
485 | extern bt_self_component_port_output * | |
486 | bt_self_component_source_borrow_output_port_by_name( | |
487 | bt_self_component_source *self_component, | |
488 | const char *name); | |
489 | ||
490 | /*! | |
491 | @brief | |
492 | Borrows the \bt_self_comp_iport named \bt_p{name} from the | |
493 | \bt_flt_comp \bt_p{self_component}. | |
494 | ||
495 | If \bt_p{self_component} has no input port named \bt_p{name}, this | |
496 | function returns \c NULL. | |
497 | ||
498 | @param[in] self_component | |
499 | Filter component instance. | |
500 | @param[in] name | |
501 | Name of the input port to borrow from \bt_p{self_component}. | |
502 | ||
503 | @returns | |
504 | @parblock | |
505 | \em Borrowed reference of the input port of | |
506 | \bt_p{self_component} named \bt_p{name}, or \c NULL if none. | |
507 | ||
508 | The returned pointer remains valid as long as \bt_p{self_component} | |
509 | exists. | |
510 | @endparblock | |
511 | ||
512 | @bt_pre_not_null{self_component} | |
513 | @bt_pre_not_null{name} | |
514 | */ | |
515 | extern bt_self_component_port_input * | |
516 | bt_self_component_filter_borrow_input_port_by_name( | |
517 | bt_self_component_filter *self_component, | |
518 | const char *name); | |
519 | ||
520 | /*! | |
521 | @brief | |
522 | Borrows the \bt_self_comp_oport named \bt_p{name} from the | |
523 | \bt_flt_comp \bt_p{self_component}. | |
524 | ||
525 | If \bt_p{self_component} has no output port named \bt_p{name}, this | |
526 | function returns \c NULL. | |
527 | ||
528 | @param[in] self_component | |
529 | Filter component instance. | |
530 | @param[in] name | |
531 | Name of the output port to borrow from \bt_p{self_component}. | |
532 | ||
533 | @returns | |
534 | @parblock | |
535 | \em Borrowed reference of the output port of | |
536 | \bt_p{self_component} named \bt_p{name}, or \c NULL if none. | |
537 | ||
538 | The returned pointer remains valid as long as \bt_p{self_component} | |
539 | exists. | |
540 | @endparblock | |
541 | ||
542 | @bt_pre_not_null{self_component} | |
543 | @bt_pre_not_null{name} | |
544 | */ | |
545 | extern bt_self_component_port_output * | |
546 | bt_self_component_filter_borrow_output_port_by_name( | |
547 | bt_self_component_filter *self_component, | |
548 | const char *name); | |
549 | ||
550 | /*! | |
551 | @brief | |
552 | Borrows the \bt_self_comp_iport named \bt_p{name} from the | |
553 | \bt_sink_comp \bt_p{self_component}. | |
554 | ||
555 | If \bt_p{self_component} has no input port named \bt_p{name}, this | |
556 | function returns \c NULL. | |
557 | ||
558 | @param[in] self_component | |
559 | Sink component instance. | |
560 | @param[in] name | |
561 | Name of the input port to borrow from \bt_p{self_component}. | |
562 | ||
563 | @returns | |
564 | @parblock | |
565 | \em Borrowed reference of the input port of | |
566 | \bt_p{self_component} named \bt_p{name}, or \c NULL if none. | |
567 | ||
568 | The returned pointer remains valid as long as \bt_p{self_component} | |
569 | exists. | |
570 | @endparblock | |
571 | ||
572 | @bt_pre_not_null{self_component} | |
573 | @bt_pre_not_null{name} | |
574 | */ | |
575 | extern bt_self_component_port_input * | |
576 | bt_self_component_sink_borrow_input_port_by_name( | |
577 | bt_self_component_sink *self_component, | |
578 | const char *name); | |
579 | ||
580 | /*! @} */ | |
581 | ||
582 | /*! | |
583 | @name User data | |
584 | @{ | |
585 | */ | |
586 | ||
587 | /*! | |
588 | @brief | |
589 | Sets the user data of the \bt_comp \bt_p{self_component} to | |
590 | \bt_p{data}. | |
591 | ||
592 | @param[in] self_component | |
593 | Component instance. | |
594 | @param[in] user_data | |
595 | New user data of \bt_p{self_component}. | |
596 | ||
597 | @bt_pre_not_null{self_component} | |
598 | ||
599 | @sa bt_self_component_get_data() — | |
600 | Returns the user data of a component. | |
601 | */ | |
602 | extern void bt_self_component_set_data( | |
603 | bt_self_component *self_component, void *user_data); | |
604 | ||
605 | /*! | |
606 | @brief | |
607 | Returns the user data of the \bt_comp \bt_p{self_component}. | |
608 | ||
609 | @param[in] self_component | |
610 | Component instance. | |
611 | ||
612 | @returns | |
613 | User data of \bt_p{self_component}. | |
614 | ||
615 | @bt_pre_not_null{self_component} | |
616 | ||
617 | @sa bt_self_component_set_data() — | |
618 | Sets the user data of a component. | |
619 | */ | |
620 | extern void *bt_self_component_get_data( | |
621 | const bt_self_component *self_component); | |
622 | ||
623 | /*! @} */ | |
624 | ||
625 | /*! | |
626 | @name Trace processing graph's effective MIP version access | |
627 | @{ | |
628 | */ | |
629 | ||
630 | /*! | |
631 | @brief | |
632 | Returns the effective \bt_mip (MIP) version of the trace processing | |
633 | \bt_graph which contains the \bt_comp \bt_p{self_component}. | |
634 | ||
635 | @note | |
636 | As of \bt_name_version_min_maj, because bt_get_maximal_mip_version() | |
637 | returns 0, this function always returns 0. | |
638 | ||
639 | @param[in] self_component | |
640 | Component instance. | |
641 | ||
642 | @returns | |
643 | Effective MIP version of the trace processing graph which | |
644 | contains \bt_p{self_component}. | |
645 | ||
646 | @bt_pre_not_null{self_component} | |
647 | */ | |
648 | extern | |
649 | uint64_t bt_self_component_get_graph_mip_version( | |
650 | bt_self_component *self_component); | |
651 | ||
652 | /*! @} */ | |
653 | ||
654 | /*! | |
655 | @name Sink component's interruption query | |
656 | @{ | |
657 | */ | |
658 | ||
659 | /*! | |
660 | @brief | |
661 | Returns whether or not the \bt_sink_comp \bt_p{self_component} | |
662 | is interrupted, that is, whether or not any of its \bt_p_intr | |
663 | is set. | |
664 | ||
665 | @param[in] self_component | |
666 | Component instance. | |
667 | ||
668 | @returns | |
669 | #BT_TRUE if \bt_p{self_component} is interrupted (any of its | |
670 | interrupters is set). | |
671 | ||
672 | @bt_pre_not_null{self_component} | |
673 | ||
674 | @sa bt_graph_borrow_default_interrupter() — | |
675 | Borrows a trace processing graph's default interrupter. | |
676 | @sa bt_graph_add_interrupter() — | |
677 | Adds an interrupter to a graph. | |
678 | */ | |
679 | extern bt_bool bt_self_component_sink_is_interrupted( | |
680 | const bt_self_component_sink *self_component); | |
681 | ||
682 | /*! @} */ | |
683 | ||
684 | /*! | |
685 | @name Self to public upcast | |
686 | @{ | |
687 | */ | |
688 | ||
689 | /*! | |
690 | @brief | |
691 | \ref api-fund-c-typing "Upcasts" the self \bt_comp | |
692 | \bt_p{self_component} to the public #bt_component type. | |
693 | ||
694 | @param[in] self_component | |
695 | @parblock | |
696 | Component to upcast. | |
697 | ||
698 | Can be \c NULL. | |
699 | @endparblock | |
700 | ||
701 | @returns | |
702 | \bt_p{self_component} as a public component. | |
703 | */ | |
d94d92ac | 704 | static inline |
b19ff26f PP |
705 | const bt_component *bt_self_component_as_component( |
706 | bt_self_component *self_component) | |
d94d92ac | 707 | { |
005f1204 | 708 | return __BT_UPCAST(bt_component, self_component); |
d94d92ac | 709 | } |
890882ef | 710 | |
43c59509 PP |
711 | /*! |
712 | @brief | |
713 | \ref api-fund-c-typing "Upcasts" the self \bt_src_comp | |
714 | \bt_p{self_component} to the public #bt_component_source | |
715 | type. | |
056deb59 | 716 | |
43c59509 PP |
717 | @param[in] self_component |
718 | @parblock | |
719 | Source component to upcast. | |
890882ef | 720 | |
43c59509 PP |
721 | Can be \c NULL. |
722 | @endparblock | |
723 | ||
724 | @returns | |
725 | \bt_p{self_component} as a public source component. | |
726 | */ | |
727 | static inline | |
728 | const bt_component_source * | |
729 | bt_self_component_source_as_component_source( | |
730 | bt_self_component_source *self_component) | |
731 | { | |
732 | return __BT_UPCAST_CONST(bt_component_source, self_component); | |
733 | } | |
734 | ||
735 | /*! | |
736 | @brief | |
737 | \ref api-fund-c-typing "Upcasts" the self \bt_flt_comp | |
738 | \bt_p{self_component} to the public #bt_component_filter | |
739 | type. | |
740 | ||
741 | @param[in] self_component | |
742 | @parblock | |
743 | Filter component to upcast. | |
744 | ||
745 | Can be \c NULL. | |
746 | @endparblock | |
747 | ||
748 | @returns | |
749 | \bt_p{self_component} as a public filter component. | |
750 | */ | |
751 | static inline | |
752 | const bt_component_filter * | |
753 | bt_self_component_filter_as_component_filter( | |
754 | bt_self_component_filter *self_component) | |
755 | { | |
756 | return __BT_UPCAST_CONST(bt_component_filter, self_component); | |
757 | } | |
758 | ||
759 | /*! | |
760 | @brief | |
761 | \ref api-fund-c-typing "Upcasts" the self \bt_sink_comp | |
762 | \bt_p{self_component} to the public #bt_component_sink | |
763 | type. | |
764 | ||
765 | @param[in] self_component | |
766 | @parblock | |
767 | Sink component to upcast. | |
768 | ||
769 | Can be \c NULL. | |
770 | @endparblock | |
771 | ||
772 | @returns | |
773 | \bt_p{self_component} as a public sink component. | |
774 | */ | |
775 | static inline | |
776 | const bt_component_sink * | |
777 | bt_self_component_sink_as_component_sink( | |
778 | bt_self_component_sink *self_component) | |
779 | { | |
780 | return __BT_UPCAST_CONST(bt_component_sink, self_component); | |
781 | } | |
782 | ||
783 | /*! @} */ | |
784 | ||
785 | /*! | |
786 | @name Self to common self upcast | |
787 | @{ | |
788 | */ | |
789 | ||
790 | /*! | |
791 | @brief | |
792 | \ref api-fund-c-typing "Upcasts" the self \bt_src_comp | |
793 | \bt_p{self_component} to the common #bt_self_component | |
794 | type. | |
795 | ||
796 | @param[in] self_component | |
797 | @parblock | |
798 | Source component to upcast. | |
799 | ||
800 | Can be \c NULL. | |
801 | @endparblock | |
802 | ||
803 | @returns | |
804 | \bt_p{self_component} as a common self component. | |
805 | */ | |
806 | static inline | |
807 | bt_self_component *bt_self_component_source_as_self_component( | |
808 | bt_self_component_source *self_component) | |
809 | { | |
810 | return __BT_UPCAST(bt_self_component, self_component); | |
811 | } | |
812 | ||
813 | /*! | |
814 | @brief | |
815 | \ref api-fund-c-typing "Upcasts" the self \bt_flt_comp | |
816 | \bt_p{self_component} to the common #bt_self_component | |
817 | type. | |
818 | ||
819 | @param[in] self_component | |
820 | @parblock | |
821 | Filter component to upcast. | |
822 | ||
823 | Can be \c NULL. | |
824 | @endparblock | |
825 | ||
826 | @returns | |
827 | \bt_p{self_component} as a common self component. | |
828 | */ | |
829 | static inline | |
830 | bt_self_component *bt_self_component_filter_as_self_component( | |
831 | bt_self_component_filter *self_component) | |
832 | { | |
833 | return __BT_UPCAST(bt_self_component, self_component); | |
834 | } | |
835 | ||
836 | /*! | |
837 | @brief | |
838 | \ref api-fund-c-typing "Upcasts" the self \bt_sink_comp | |
839 | \bt_p{self_component} to the common #bt_self_component | |
840 | type. | |
841 | ||
842 | @param[in] self_component | |
843 | @parblock | |
844 | Sink component to upcast. | |
845 | ||
846 | Can be \c NULL. | |
847 | @endparblock | |
848 | ||
849 | @returns | |
850 | \bt_p{self_component} as a common self component. | |
851 | */ | |
852 | static inline | |
853 | bt_self_component *bt_self_component_sink_as_self_component( | |
854 | bt_self_component_sink *self_component) | |
855 | { | |
856 | return __BT_UPCAST(bt_self_component, self_component); | |
857 | } | |
858 | ||
859 | /*! @} */ | |
860 | ||
861 | /*! @} */ | |
890882ef PP |
862 | |
863 | #ifdef __cplusplus | |
864 | } | |
865 | #endif | |
866 | ||
924dc299 | 867 | #endif /* BABELTRACE2_GRAPH_SELF_COMPONENT_H */ |