API Fix: bt_ctf_iter_read_event_flags
[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
6946751f
JD
23#ifdef __cplusplus
24extern "C" {
25#endif
26
f60efc0e
JD
27/* Flags for the iterator read_event */
28enum {
29 BT_ITER_FLAG_LOST_EVENTS = (1 << 0),
30};
31
6204d33c 32/* Forward declarations */
e8c92a62 33struct bt_iter;
e8c92a62 34struct bt_saved_pos;
6204d33c 35
31265d84
JD
36/*
37 * bt_iter is an abstract class, each format has to implement its own
38 * iterator derived from this parent class.
39 */
40
41/*
42 * bt_iter_pos
43 *
44 * This structure represents the position where to set an iterator.
45 *
46 * type represents the type of seek to use.
47 * u is the argument of the seek if necessary :
03798a93 48 * - seek_time is the real timestamp to seek to when using BT_SEEK_TIME, it
836c4dd8 49 * is expressed in nanoseconds
31265d84
JD
50 * - restore is a position saved with bt_iter_get_pos, it is used with
51 * BT_SEEK_RESTORE.
f7ed6563
MD
52 *
53 * Note about BT_SEEK_LAST: if many events happen to be at the last
54 * timestamp, it is implementation-defined which event will be the last,
55 * and the order of events with the same timestamp may not be the same
56 * as normal iteration on the trace. Therefore, it is recommended to
57 * only use BT_SEEK_LAST to get the timestamp of the last event(s) in
58 * the trace.
31265d84 59 */
e8c92a62 60struct bt_iter_pos {
6204d33c
JD
61 enum {
62 BT_SEEK_TIME, /* uses u.seek_time */
63 BT_SEEK_RESTORE, /* uses u.restore */
64 BT_SEEK_CUR,
65 BT_SEEK_BEGIN,
f7ed6563 66 BT_SEEK_LAST,
6204d33c
JD
67 } type;
68 union {
69 uint64_t seek_time;
e8c92a62 70 struct bt_saved_pos *restore;
6204d33c
JD
71 } u;
72};
73
6204d33c 74/*
e8c92a62 75 * bt_iter_next: Move trace collection position to the next event.
6204d33c
JD
76 *
77 * Returns 0 on success, a negative value on error
78 */
e8c92a62 79int bt_iter_next(struct bt_iter *iter);
6204d33c
JD
80
81/*
90fcbacc 82 * bt_iter_get_pos - Get the current iterator position.
6204d33c
JD
83 *
84 * The position returned by this function needs to be freed by
e8c92a62 85 * bt_iter_free_pos after use.
6204d33c 86 */
5a23202c 87struct bt_iter_pos *bt_iter_get_pos(struct bt_iter *iter);
6204d33c
JD
88
89/*
e8c92a62 90 * bt_iter_free_pos - Free the position.
6204d33c 91 */
e8c92a62 92void bt_iter_free_pos(struct bt_iter_pos *pos);
6204d33c
JD
93
94/*
90fcbacc 95 * bt_iter_set_pos: move the iterator to a given position.
6204d33c 96 *
dc81689e
JD
97 * On error, the stream_heap is reinitialized and returned empty.
98 *
6204d33c 99 * Return 0 for success.
dc81689e
JD
100 *
101 * Return EOF if the position requested is after the last event of the
102 * trace collection.
103 * Return -EINVAL when called with invalid parameter.
104 * Return -ENOMEM if the stream_heap could not be properly initialized.
105 */
106int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *pos);
107
108/*
109 * bt_iter_create_time_pos: create a position based on time
110 *
111 * This function allocates and returns a new bt_iter_pos (which must be freed
112 * with bt_iter_free_pos) to be able to restore an iterator position based on a
03798a93 113 * real timestamp.
6204d33c 114 */
dc81689e
JD
115struct bt_iter_pos *bt_iter_create_time_pos(struct bt_iter *iter,
116 uint64_t timestamp);
6204d33c 117
6946751f
JD
118#ifdef __cplusplus
119}
120#endif
121
6204d33c 122#endif /* _BABELTRACE_ITERATOR_H */
This page took 0.041141 seconds and 4 git commands to generate.