API fix : fill the values for timestamp begin and end
[babeltrace.git] / include / babeltrace / ctf / events.h
CommitLineData
9843982d
JD
1#ifndef _BABELTRACE_CTF_EVENTS_H
2#define _BABELTRACE_CTF_EVENTS_H
3
4/*
5 * BabelTrace
6 *
7 * CTF events API
8 *
9 * Copyright 2011-2012 EfficiOS Inc. and Linux Foundation
10 *
11 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 * Julien Desfossez <julien.desfossez@efficios.com>
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining
15 * a copy of this software and associated documentation files (the
16 * "Software"), to deal in the Software without restriction, including
17 * without limitation the rights to use, copy, modify, merge, publish,
18 * distribute, sublicense, and/or sell copies of the Software, and to
19 * permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
21 *
22 * The above copyright notice and this permission notice shall be
23 * included in all copies or substantial portions of the Software.
24 */
25
26#include <stdint.h>
e003ab50 27#include <babeltrace/context.h>
9843982d 28
9843982d 29struct definition;
c50d2a7a 30struct bt_ctf_event;
e003ab50 31struct bt_ctf_event_decl;
9843982d
JD
32
33/*
34 * the top-level scopes in CTF
35 */
36enum bt_ctf_scope {
37 BT_TRACE_PACKET_HEADER = 0,
38 BT_STREAM_PACKET_CONTEXT = 1,
39 BT_STREAM_EVENT_HEADER = 2,
40 BT_STREAM_EVENT_CONTEXT = 3,
41 BT_EVENT_CONTEXT = 4,
42 BT_EVENT_FIELDS = 5,
43};
44
45/*
46 * the supported CTF types
47 */
48enum ctf_type_id {
49 CTF_TYPE_UNKNOWN = 0,
50 CTF_TYPE_INTEGER,
51 CTF_TYPE_FLOAT,
52 CTF_TYPE_ENUM,
53 CTF_TYPE_STRING,
54 CTF_TYPE_STRUCT,
55 CTF_TYPE_UNTAGGED_VARIANT,
56 CTF_TYPE_VARIANT,
57 CTF_TYPE_ARRAY,
58 CTF_TYPE_SEQUENCE,
59 NR_CTF_TYPES,
60};
61
8673030f
JD
62/*
63 * the supported CTF string encodings
64 */
65enum ctf_string_encoding {
66 CTF_STRING_NONE = 0,
67 CTF_STRING_UTF8,
68 CTF_STRING_ASCII,
69 CTF_STRING_UNKNOWN,
70};
71
9843982d
JD
72/*
73 * bt_ctf_get_top_level_scope: return a definition of the top-level scope
74 *
75 * Top-level scopes are defined in the bt_ctf_scope enum.
76 * In order to get a field or a field list, the user needs to pass a
77 * scope as argument, this scope can be a top-level scope or a scope
78 * relative to an arbitrary field. This function provides the mapping
79 * between the enum and the actual definition of top-level scopes.
80 * On error return NULL.
81 */
c50d2a7a 82const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event,
9843982d
JD
83 enum bt_ctf_scope scope);
84
85/*
86 * bt_ctf_event_get_name: returns the name of the event or NULL on error
87 */
c50d2a7a 88const char *bt_ctf_event_name(const struct bt_ctf_event *event);
9843982d
JD
89
90/*
57f3005e
SJD
91 * bt_ctf_get_timestamp_raw: returns the timestamp of the event as written in
92 * the packet or -1ULL on error
93 */
c50d2a7a 94uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event);
57f3005e
SJD
95
96/*
97 * bt_ctf_get_timestamp: returns the timestamp of the event offsetted with the
98 * system clock source or -1ULL on error
9843982d 99 */
c50d2a7a 100uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event);
9843982d
JD
101
102/*
aacd0c69
JD
103 * bt_ctf_get_field_list: set list pointer to an array of definition
104 * pointers and set count to the number of elements in the array.
105 * Return 0 on success and a negative value on error.
9843982d 106 */
c50d2a7a 107int bt_ctf_get_field_list(const struct bt_ctf_event *event,
04ae3991 108 const struct definition *scope,
9843982d
JD
109 struct definition const * const **list,
110 unsigned int *count);
111
112/*
113 * bt_ctf_get_field: returns the definition of a specific field
114 */
c50d2a7a 115const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event,
04ae3991 116 const struct definition *scope,
9843982d
JD
117 const char *field);
118
119/*
120 * bt_ctf_get_index: if the field is an array or a sequence, return the element
121 * at position index, otherwise return NULL;
122 */
c50d2a7a 123const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event,
04ae3991 124 const struct definition *field,
9843982d
JD
125 unsigned int index);
126
127/*
128 * bt_ctf_field_name: returns the name of a field or NULL on error
129 */
130const char *bt_ctf_field_name(const struct definition *def);
131
132/*
133 * bt_ctf_field_type: returns the type of a field or -1 if unknown
134 */
da320b83 135enum ctf_type_id bt_ctf_field_type(const struct definition *def);
9843982d 136
8673030f
JD
137/*
138 * bt_ctf_get_int_signedness: return the signedness of an integer
139 *
140 * return 0 if unsigned
141 * return 1 if signed
142 * return -1 on error
143 */
144int bt_ctf_get_int_signedness(const struct definition *field);
145
146/*
147 * bt_ctf_get_int_base: return the base of an int or a negative value on error
148 */
149int bt_ctf_get_int_base(const struct definition *field);
150
151/*
152 * bt_ctf_get_int_byte_order: return the byte order of an int or a negative
153 * value on error
154 */
155int bt_ctf_get_int_byte_order(const struct definition *field);
156
157/*
158 * bt_ctf_get_encoding: return the encoding of an int or a string.
159 * return a negative value on error
160 */
161enum ctf_string_encoding bt_ctf_get_encoding(const struct definition *field);
162
163/*
164 * bt_ctf_get_array_len: return the len of an array or a negative
165 * value on error
166 */
167int bt_ctf_get_array_len(const struct definition *field);
168
9843982d
JD
169/*
170 * Field access functions
171 *
172 * These functions return the value associated with the field passed in
173 * parameter.
174 *
175 * If the field does not exist or is not of the type requested, the value
176 * returned is undefined. To check if an error occured, use the
177 * bt_ctf_field_error() function after accessing a field.
178 */
da320b83
JD
179uint64_t bt_ctf_get_uint64(const struct definition *field);
180int64_t bt_ctf_get_int64(const struct definition *field);
181char *bt_ctf_get_char_array(const struct definition *field);
182char *bt_ctf_get_string(const struct definition *field);
9843982d
JD
183
184/*
185 * bt_ctf_field_error: returns the last error code encountered while
186 * accessing a field and reset the error flag.
187 * Return 0 if no error, a negative value otherwise.
188 */
189int bt_ctf_field_get_error(void);
190
e003ab50
JD
191/*
192 * bt_ctf_get_event_decl_list: set list pointer to an array of bt_ctf_event_decl
193 * pointers and set count to the number of elements in the array.
194 *
195 * Return 0 on success and a negative value on error.
196 */
197int bt_ctf_get_event_decl_list(int handle_id, struct bt_context *ctx,
198 struct bt_ctf_event_decl const * const **list,
199 unsigned int *count);
200
201/*
202 * bt_ctf_get_decl_event_name: return the name of the event or NULL on error
203 */
204const char *bt_ctf_get_decl_event_name(const struct bt_ctf_event_decl *event);
205
9843982d 206#endif /* _BABELTRACE_CTF_EVENTS_H */
This page took 0.031701 seconds and 4 git commands to generate.