1 #ifndef _BABELTRACE_LIB_H
2 #define _BABELTRACE_LIB_H
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/types.h>
21 #include <babeltrace/format.h>
22 #include <babeltrace/ctf/types.h>
23 #include <babeltrace/ctf-ir/metadata.h>
26 * struct babeltrace_iter: data structure representing an iterator on a trace
29 struct babeltrace_iter
{
30 struct ptr_heap
*stream_heap
;
31 struct trace_collection
*tc
;
34 struct babeltrace_iter_pos
{
35 GPtrArray
*pos
; /* struct babeltrace_iter_stream_pos */
38 struct babeltrace_iter_stream_pos
{
39 struct stream_pos parent
;
45 * Initialization/teardown.
47 struct babeltrace_iter
*babeltrace_iter_create(struct trace_collection
*tc
);
48 void babeltrace_iter_destroy(struct babeltrace_iter
*iter
);
51 * Move within the trace.
54 * babeltrace_iter_next: Move stream position to the next event.
56 * Returns 0 on success, a negative value on error
58 int babeltrace_iter_next(struct babeltrace_iter
*iter
);
60 /* Get the current position for each stream of the trace */
61 struct babeltrace_iter_pos
*
62 babeltrace_iter_get_pos(struct babeltrace_iter
*iter
);
64 /* The position needs to be freed after use */
65 void babeltrace_iter_free_pos(struct babeltrace_iter_pos
*pos
);
67 /* Seek the trace to the position */
68 int babeltrace_iter_seek_pos(struct babeltrace_iter
*iter
,
69 struct babeltrace_iter_pos
*pos
);
72 * babeltrace_iter_seek_time: Seek the trace to the given timestamp.
74 * Return EOF if timestamp is after the last event of the trace.
75 * Return other negative value for other errors.
76 * Return 0 for success.
78 int babeltrace_iter_seek_time(struct babeltrace_iter
*iter
,
82 * babeltrace_iter_read_event: Read the current event data.
84 * @iter: trace iterator (input)
85 * @stream: stream containing event at current position (output)
86 * @event: current event (output)
87 * Return 0 on success, negative error value on error.
89 int babeltrace_iter_read_event(struct babeltrace_iter
*iter
,
90 struct ctf_stream
**stream
,
91 struct ctf_stream_event
**event
);
93 #endif /* _BABELTRACE_LIB_H */