API : split iterator headers from babeltrace.h
[babeltrace.git] / include / babeltrace / babeltrace.h
1 #ifndef _BABELTRACE_H
2 #define _BABELTRACE_H
3
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 */
19
20 #include <glib.h>
21 #include <babeltrace/format.h>
22
23 typedef GQuark bt_event_name;
24
25 /* Forward declarations */
26 struct babeltrace_iter;
27 struct ctf_stream_event;
28 struct ctf_stream;
29 struct bt_dependencies;
30
31 enum bt_cb_ret {
32 BT_CB_OK = 0,
33 BT_CB_OK_STOP = 1,
34 BT_CB_ERROR_STOP = 2,
35 BT_CB_ERROR_CONTINUE = 3,
36 };
37
38 struct bt_ctf_data {
39 struct ctf_stream_event *event;
40 struct ctf_stream *stream;
41 };
42
43 /*
44 * Receives a variable number of strings as parameter, ended with NULL.
45 */
46 struct bt_dependencies *babeltrace_dependencies_create(const char *first, ...);
47
48 /*
49 * struct bt_dependencies must be destroyed explicitly if not passed as
50 * parameter to a babeltrace_iter_add_callback().
51 */
52 void babeltrace_dependencies_destroy(struct bt_dependencies *dep);
53
54 /*
55 * babeltrace_iter_add_callback: Add a callback to iterator.
56 *
57 * @iter: trace collection iterator (input)
58 * @event: event to target. 0 for all events.
59 * @private_data: private data pointer to pass to the callback
60 * @flags: specific flags controlling the behavior of this callback
61 * (or'd).
62 *
63 * @callback: function pointer to call
64 * @depends: struct bt_dependency detailing the required computation results.
65 * Ends with 0.
66 * @weak_depends: struct bt_dependency detailing the optional computation
67 * results that can be optionally consumed by this
68 * callback.
69 * @provides: struct bt_dependency detailing the computation results
70 * provided by this callback.
71 * Ends with 0.
72 *
73 * "depends", "weak_depends" and "provides" memory is handled by the
74 * babeltrace library after this call succeeds or fails. These objects
75 * can still be used by the caller until the babeltrace iterator is
76 * destroyed, but they belong to the babeltrace library.
77 *
78 * (note to implementor: we need to keep a gptrarray of struct
79 * bt_dependencies to "garbage collect" in struct babeltrace_iter, and
80 * dependencies need to have a refcount to handle the case where they
81 * would be passed to more than one iterator. Upon iterator detroy, we
82 * iterate on all the gc ptrarray and decrement the refcounts, freeing
83 * if we reach 0.)
84 * (note to implementor: we calculate the dependency graph when
85 * babeltrace_iter_read_event() is executed after a
86 * babeltrace_iter_add_callback(). Beware that it is valid to create/add
87 * callbacks/read/add more callbacks/read some more.)
88 */
89 int babeltrace_iter_add_callback(struct babeltrace_iter *iter,
90 bt_event_name event, void *private_data, int flags,
91 enum bt_cb_ret (*callback)(struct bt_ctf_data *ctf_data,
92 void *caller_data),
93 struct bt_dependencies *depends,
94 struct bt_dependencies *weak_depends,
95 struct bt_dependencies *provides);
96
97 /*
98 * For flags parameter above.
99 */
100 enum {
101 BT_FLAGS_FREE_PRIVATE_DATA = (1 << 0),
102 };
103
104 #endif /* _BABELTRACE_H */
This page took 0.030524 seconds and 4 git commands to generate.