API cleanup: Move bt_iter_create/destroy to internal header
[babeltrace.git] / include / babeltrace / iterator.h
CommitLineData
6204d33c
JD
1#ifndef _BABELTRACE_ITERATOR_H
2#define _BABELTRACE_ITERATOR_H
3
4/*
5 * BabelTrace API Iterators
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#include <babeltrace/format.h>
21#include <babeltrace/context.h>
22
6204d33c 23/* Forward declarations */
e8c92a62 24struct bt_iter;
e8c92a62 25struct bt_saved_pos;
6204d33c 26
e8c92a62 27struct bt_iter_pos {
6204d33c
JD
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;
e8c92a62 37 struct bt_saved_pos *restore;
6204d33c
JD
38 } u;
39};
40
6204d33c 41/*
e8c92a62 42 * bt_iter_next: Move trace collection position to the next event.
6204d33c
JD
43 *
44 * Returns 0 on success, a negative value on error
45 */
e8c92a62 46int bt_iter_next(struct bt_iter *iter);
6204d33c
JD
47
48/*
90fcbacc 49 * bt_iter_get_pos - Get the current iterator position.
6204d33c
JD
50 *
51 * The position returned by this function needs to be freed by
e8c92a62 52 * bt_iter_free_pos after use.
6204d33c 53 */
5a23202c 54struct bt_iter_pos *bt_iter_get_pos(struct bt_iter *iter);
6204d33c
JD
55
56/*
e8c92a62 57 * bt_iter_free_pos - Free the position.
6204d33c 58 */
e8c92a62 59void bt_iter_free_pos(struct bt_iter_pos *pos);
6204d33c
JD
60
61/*
90fcbacc 62 * bt_iter_set_pos: move the iterator to a given position.
6204d33c 63 *
dc81689e
JD
64 * On error, the stream_heap is reinitialized and returned empty.
65 *
6204d33c 66 * Return 0 for success.
dc81689e
JD
67 *
68 * Return EOF if the position requested is after the last event of the
69 * trace collection.
70 * Return -EINVAL when called with invalid parameter.
71 * Return -ENOMEM if the stream_heap could not be properly initialized.
72 */
73int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *pos);
74
75/*
76 * bt_iter_create_time_pos: create a position based on time
77 *
78 * This function allocates and returns a new bt_iter_pos (which must be freed
79 * with bt_iter_free_pos) to be able to restore an iterator position based on a
80 * timestamp.
6204d33c 81 */
dc81689e
JD
82struct bt_iter_pos *bt_iter_create_time_pos(struct bt_iter *iter,
83 uint64_t timestamp);
6204d33c 84
6204d33c 85#endif /* _BABELTRACE_ITERATOR_H */
This page took 0.029019 seconds and 4 git commands to generate.