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 | |
70bd0a12 JD |
20 | /* Forward declarations */ |
21 | struct babeltrace_iter; | |
70bd0a12 JD |
22 | struct trace_collection; |
23 | struct ctf_stream_event; | |
24 | struct ctf_stream; | |
063f7048 MD |
25 | struct babeltrace_saved_pos; |
26 | ||
27 | struct trace_collection_pos { | |
28 | enum { | |
29 | BT_SEEK_TIME, /* uses u.seek_time */ | |
30 | BT_SEEK_RESTORE, /* uses u.restore */ | |
31 | BT_SEEK_CUR, | |
32 | BT_SEEK_BEGIN, | |
33 | BT_SEEK_END, | |
34 | } type; | |
35 | union { | |
36 | uint64_t seek_time; | |
37 | struct babeltrace_saved_pos *restore; | |
38 | } u; | |
39 | }; | |
34ac0e6c | 40 | |
70bd0a12 JD |
41 | /* |
42 | * babeltrace_iter_create - Allocate a trace collection iterator. | |
063f7048 MD |
43 | * |
44 | * begin_pos and end_pos are optional parameters to specify the position | |
45 | * at which the trace collection should be seeked upon iterator | |
46 | * creation, and the position at which iteration will start returning | |
47 | * "EOF". | |
48 | * | |
49 | * By default, if begin_pos is NULL, a BT_SEEK_CUR is performed at | |
50 | * creation. By default, if end_pos is NULL, a BT_SEEK_END (end of | |
51 | * trace) is the EOF criterion. | |
70bd0a12 | 52 | */ |
063f7048 MD |
53 | struct babeltrace_iter *babeltrace_iter_create(struct trace_collection *tc, |
54 | struct trace_collection_pos *begin_pos, | |
55 | struct trace_collection_pos *end_pos); | |
34ac0e6c | 56 | |
70bd0a12 JD |
57 | /* |
58 | * babeltrace_iter_destroy - Free a trace collection iterator. | |
59 | */ | |
60 | void babeltrace_iter_destroy(struct babeltrace_iter *iter); | |
34ac0e6c | 61 | |
70bd0a12 JD |
62 | /* |
63 | * babeltrace_iter_next: Move trace collection position to the next event. | |
64 | * | |
65 | * Returns 0 on success, a negative value on error | |
66 | */ | |
67 | int babeltrace_iter_next(struct babeltrace_iter *iter); | |
46322b33 | 68 | |
70bd0a12 | 69 | /* |
063f7048 | 70 | * babeltrace_iter_save_pos - Save the current trace collection position. |
70bd0a12 JD |
71 | * |
72 | * The position returned by this function needs to be freed by | |
73 | * babeltrace_iter_free_pos after use. | |
74 | */ | |
063f7048 MD |
75 | struct trace_collection_pos * |
76 | babeltrace_iter_save_pos(struct babeltrace_iter *iter); | |
46322b33 | 77 | |
70bd0a12 JD |
78 | /* |
79 | * babeltrace_iter_free_pos - Free the position. | |
80 | */ | |
063f7048 | 81 | void babeltrace_iter_free_pos(struct trace_collection_pos *pos); |
70bd0a12 JD |
82 | |
83 | /* | |
063f7048 | 84 | * babeltrace_iter_seek: seek iterator to given position. |
70bd0a12 | 85 | * |
063f7048 | 86 | * Return EOF if position is after the last event of the trace collection. |
70bd0a12 JD |
87 | * Return other negative value for other errors. |
88 | * Return 0 for success. | |
89 | */ | |
063f7048 MD |
90 | int babeltrace_iter_seek(struct babeltrace_iter *iter, |
91 | const struct trace_collection_pos *pos); | |
70bd0a12 JD |
92 | |
93 | /* | |
94 | * babeltrace_iter_read_event: Read the iterator's current event data. | |
95 | * | |
96 | * @iter: trace collection iterator (input) | |
97 | * @stream: stream containing event at current position (output) | |
98 | * @event: current event (output) | |
99 | * Return 0 on success, negative error value on error. | |
100 | */ | |
101 | int babeltrace_iter_read_event(struct babeltrace_iter *iter, | |
102 | struct ctf_stream **stream, | |
103 | struct ctf_stream_event **event); | |
104 | ||
105 | #endif /* _BABELTRACE_H */ |