Commit | Line | Data |
---|---|---|
34ac0e6c MD |
1 | #ifndef _BABELTRACE_H |
2 | #define _BABELTRACE_H | |
3 | ||
70bd0a12 JD |
4 | /* |
5 | * BabelTrace API | |
6 | * | |
7 | * Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
8 | * | |
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
10 | * of this software and associated documentation files (the "Software"), to deal | |
11 | * in the Software without restriction, including without limitation the rights | |
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
13 | * copies of the Software, and to permit persons to whom the Software is | |
14 | * furnished to do so, subject to the following conditions: | |
15 | * | |
16 | * The above copyright notice and this permission notice shall be included in | |
17 | * all copies or substantial portions of the Software. | |
18 | */ | |
847bf71a | 19 | |
c34ccddd | 20 | #include <glib.h> |
64a35d1b | 21 | #include <babeltrace/context.h> |
0ec662bd | 22 | #include <babeltrace/format.h> |
64a35d1b JD |
23 | #include <babeltrace/iterator.h> |
24 | #include <babeltrace/trace-collection.h> | |
25 | #include <babeltrace/trace-handle.h> | |
26 | #include <babeltrace/ctf/events.h> | |
c34ccddd MD |
27 | |
28 | typedef GQuark bt_event_name; | |
29 | ||
70bd0a12 | 30 | /* Forward declarations */ |
e8c92a62 | 31 | struct bt_iter; |
70bd0a12 JD |
32 | struct ctf_stream_event; |
33 | struct ctf_stream; | |
c34ccddd MD |
34 | struct bt_dependencies; |
35 | ||
36 | enum bt_cb_ret { | |
37 | BT_CB_OK = 0, | |
38 | BT_CB_OK_STOP = 1, | |
39 | BT_CB_ERROR_STOP = 2, | |
40 | BT_CB_ERROR_CONTINUE = 3, | |
41 | }; | |
063f7048 | 42 | |
e73cc54c JD |
43 | struct bt_ctf_data { |
44 | struct ctf_stream_event *event; | |
f970ae1d | 45 | struct ctf_stream *stream; |
e73cc54c JD |
46 | }; |
47 | ||
c34ccddd MD |
48 | /* |
49 | * Receives a variable number of strings as parameter, ended with NULL. | |
50 | */ | |
51 | struct bt_dependencies *babeltrace_dependencies_create(const char *first, ...); | |
52 | ||
53 | /* | |
54 | * struct bt_dependencies must be destroyed explicitly if not passed as | |
e8c92a62 | 55 | * parameter to a bt_iter_add_callback(). |
c34ccddd MD |
56 | */ |
57 | void babeltrace_dependencies_destroy(struct bt_dependencies *dep); | |
58 | ||
59 | /* | |
e8c92a62 | 60 | * bt_iter_add_callback: Add a callback to iterator. |
c34ccddd MD |
61 | * |
62 | * @iter: trace collection iterator (input) | |
63 | * @event: event to target. 0 for all events. | |
64 | * @private_data: private data pointer to pass to the callback | |
65 | * @flags: specific flags controlling the behavior of this callback | |
66 | * (or'd). | |
67 | * | |
68 | * @callback: function pointer to call | |
69 | * @depends: struct bt_dependency detailing the required computation results. | |
70 | * Ends with 0. | |
71 | * @weak_depends: struct bt_dependency detailing the optional computation | |
72 | * results that can be optionally consumed by this | |
73 | * callback. | |
74 | * @provides: struct bt_dependency detailing the computation results | |
75 | * provided by this callback. | |
76 | * Ends with 0. | |
77 | * | |
78 | * "depends", "weak_depends" and "provides" memory is handled by the | |
79 | * babeltrace library after this call succeeds or fails. These objects | |
80 | * can still be used by the caller until the babeltrace iterator is | |
81 | * destroyed, but they belong to the babeltrace library. | |
82 | * | |
83 | * (note to implementor: we need to keep a gptrarray of struct | |
e8c92a62 | 84 | * bt_dependencies to "garbage collect" in struct bt_iter, and |
c34ccddd MD |
85 | * dependencies need to have a refcount to handle the case where they |
86 | * would be passed to more than one iterator. Upon iterator detroy, we | |
87 | * iterate on all the gc ptrarray and decrement the refcounts, freeing | |
88 | * if we reach 0.) | |
89 | * (note to implementor: we calculate the dependency graph when | |
e8c92a62 JD |
90 | * bt_iter_read_event() is executed after a |
91 | * bt_iter_add_callback(). Beware that it is valid to create/add | |
c34ccddd MD |
92 | * callbacks/read/add more callbacks/read some more.) |
93 | */ | |
e8c92a62 | 94 | int bt_iter_add_callback(struct bt_iter *iter, |
c34ccddd | 95 | bt_event_name event, void *private_data, int flags, |
e73cc54c JD |
96 | enum bt_cb_ret (*callback)(struct bt_ctf_data *ctf_data, |
97 | void *caller_data), | |
c34ccddd MD |
98 | struct bt_dependencies *depends, |
99 | struct bt_dependencies *weak_depends, | |
100 | struct bt_dependencies *provides); | |
101 | ||
102 | /* | |
103 | * For flags parameter above. | |
104 | */ | |
105 | enum { | |
106 | BT_FLAGS_FREE_PRIVATE_DATA = (1 << 0), | |
107 | }; | |
108 | ||
70bd0a12 | 109 | #endif /* _BABELTRACE_H */ |