7 * Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
20 #include <babeltrace/context.h>
21 #include <babeltrace/format.h>
22 #include <babeltrace/iterator.h>
23 #include <babeltrace/trace-collection.h>
24 #include <babeltrace/trace-handle.h>
25 #include <babeltrace/ctf/events.h>
27 /* Forward declarations */
29 struct ctf_stream_event
;
31 struct bt_dependencies
;
37 BT_CB_ERROR_CONTINUE
= 3,
41 struct ctf_stream_event
*event
;
42 struct ctf_stream
*stream
;
46 * Receives a variable number of strings as parameter, ended with NULL.
48 struct bt_dependencies
*babeltrace_dependencies_create(const char *first
, ...);
51 * struct bt_dependencies must be destroyed explicitly if not passed as
52 * parameter to a bt_iter_add_callback().
54 void babeltrace_dependencies_destroy(struct bt_dependencies
*dep
);
57 * bt_iter_add_callback: Add a callback to iterator.
59 * @iter: trace collection iterator (input)
60 * @event: event to target. 0 for all events.
61 * @private_data: private data pointer to pass to the callback
62 * @flags: specific flags controlling the behavior of this callback
65 * @callback: function pointer to call
66 * @depends: struct bt_dependency detailing the required computation results.
68 * @weak_depends: struct bt_dependency detailing the optional computation
69 * results that can be optionally consumed by this
71 * @provides: struct bt_dependency detailing the computation results
72 * provided by this callback.
75 * "depends", "weak_depends" and "provides" memory is handled by the
76 * babeltrace library after this call succeeds or fails. These objects
77 * can still be used by the caller until the babeltrace iterator is
78 * destroyed, but they belong to the babeltrace library.
80 * (note to implementor: we need to keep a gptrarray of struct
81 * bt_dependencies to "garbage collect" in struct bt_iter, and
82 * dependencies need to have a refcount to handle the case where they
83 * would be passed to more than one iterator. Upon iterator detroy, we
84 * iterate on all the gc ptrarray and decrement the refcounts, freeing
86 * (note to implementor: we calculate the dependency graph when
87 * bt_iter_read_event() is executed after a
88 * bt_iter_add_callback(). Beware that it is valid to create/add
89 * callbacks/read/add more callbacks/read some more.)
91 int bt_iter_add_callback(struct bt_iter
*iter
,
92 bt_intern_str event
, void *private_data
, int flags
,
93 enum bt_cb_ret (*callback
)(struct bt_ctf_data
*ctf_data
,
95 struct bt_dependencies
*depends
,
96 struct bt_dependencies
*weak_depends
,
97 struct bt_dependencies
*provides
);
100 * For flags parameter above.
103 BT_FLAGS_FREE_PRIVATE_DATA
= (1 << 0),
106 #endif /* _BABELTRACE_H */