6c3fe967e635ee05973a08c3d35dcdc027e9b64f
[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 /* Forward declarations */
21 struct babeltrace_iter;
22 struct trace_collection;
23 struct ctf_stream_event;
24 struct ctf_stream;
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 };
40
41 /*
42 * babeltrace_iter_create - Allocate a trace collection iterator.
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.
52 */
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);
56
57 /*
58 * babeltrace_iter_destroy - Free a trace collection iterator.
59 */
60 void babeltrace_iter_destroy(struct babeltrace_iter *iter);
61
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);
68
69 /*
70 * babeltrace_iter_save_pos - Save the current trace collection position.
71 *
72 * The position returned by this function needs to be freed by
73 * babeltrace_iter_free_pos after use.
74 */
75 struct trace_collection_pos *
76 babeltrace_iter_save_pos(struct babeltrace_iter *iter);
77
78 /*
79 * babeltrace_iter_free_pos - Free the position.
80 */
81 void babeltrace_iter_free_pos(struct trace_collection_pos *pos);
82
83 /*
84 * babeltrace_iter_seek: seek iterator to given position.
85 *
86 * Return EOF if position is after the last event of the trace collection.
87 * Return other negative value for other errors.
88 * Return 0 for success.
89 */
90 int babeltrace_iter_seek(struct babeltrace_iter *iter,
91 const struct trace_collection_pos *pos);
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 */
This page took 0.030706 seconds and 3 git commands to generate.