| 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 | /* Forward declarations */ |
| 21 | struct babeltrace_iter; |
| 22 | struct babeltrace_iter_pos; |
| 23 | struct babeltrace_iter_stream_pos; |
| 24 | struct trace_collection; |
| 25 | struct ctf_stream_event; |
| 26 | struct ctf_stream; |
| 27 | |
| 28 | /* |
| 29 | * babeltrace_iter_create - Allocate a trace collection iterator. |
| 30 | */ |
| 31 | struct babeltrace_iter *babeltrace_iter_create(struct trace_collection *tc); |
| 32 | |
| 33 | /* |
| 34 | * babeltrace_iter_destroy - Free a trace collection iterator. |
| 35 | */ |
| 36 | void babeltrace_iter_destroy(struct babeltrace_iter *iter); |
| 37 | |
| 38 | /* |
| 39 | * babeltrace_iter_next: Move trace collection position to the next event. |
| 40 | * |
| 41 | * Returns 0 on success, a negative value on error |
| 42 | */ |
| 43 | int babeltrace_iter_next(struct babeltrace_iter *iter); |
| 44 | |
| 45 | /* |
| 46 | * babeltrace_iter_get_pos - Get the current trace collection position. |
| 47 | * |
| 48 | * The position returned by this function needs to be freed by |
| 49 | * babeltrace_iter_free_pos after use. |
| 50 | */ |
| 51 | struct babeltrace_iter_pos * |
| 52 | babeltrace_iter_get_pos(struct babeltrace_iter *iter); |
| 53 | |
| 54 | /* |
| 55 | * babeltrace_iter_free_pos - Free the position. |
| 56 | */ |
| 57 | void babeltrace_iter_free_pos(struct babeltrace_iter_pos *pos); |
| 58 | |
| 59 | /* |
| 60 | * babeltrace_iter_seek_pos - Seek the trace collection to the position. |
| 61 | */ |
| 62 | int babeltrace_iter_seek_pos(struct babeltrace_iter *iter, |
| 63 | struct babeltrace_iter_pos *pos); |
| 64 | |
| 65 | /* |
| 66 | * babeltrace_iter_seek_time: Seek the trace collection to the given timestamp. |
| 67 | * |
| 68 | * Return EOF if timestamp is after the last event of the trace collection. |
| 69 | * Return other negative value for other errors. |
| 70 | * Return 0 for success. |
| 71 | */ |
| 72 | int babeltrace_iter_seek_time(struct babeltrace_iter *iter, |
| 73 | uint64_t timestamp); |
| 74 | |
| 75 | /* |
| 76 | * babeltrace_iter_read_event: Read the iterator's current event data. |
| 77 | * |
| 78 | * @iter: trace collection iterator (input) |
| 79 | * @stream: stream containing event at current position (output) |
| 80 | * @event: current event (output) |
| 81 | * Return 0 on success, negative error value on error. |
| 82 | */ |
| 83 | int babeltrace_iter_read_event(struct babeltrace_iter *iter, |
| 84 | struct ctf_stream **stream, |
| 85 | struct ctf_stream_event **event); |
| 86 | |
| 87 | #endif /* _BABELTRACE_H */ |