API Fix : missing list fields of event decl
[babeltrace.git] / include / babeltrace / ctf / events.h
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>
27 #include <babeltrace/context.h>
28
29 struct definition;
30 struct bt_ctf_event;
31 struct bt_ctf_event_decl;
32 struct bt_ctf_field_decl;
33
34 /*
35 * the top-level scopes in CTF
36 */
37 enum bt_ctf_scope {
38 BT_TRACE_PACKET_HEADER = 0,
39 BT_STREAM_PACKET_CONTEXT = 1,
40 BT_STREAM_EVENT_HEADER = 2,
41 BT_STREAM_EVENT_CONTEXT = 3,
42 BT_EVENT_CONTEXT = 4,
43 BT_EVENT_FIELDS = 5,
44 };
45
46 /*
47 * the supported CTF types
48 */
49 enum ctf_type_id {
50 CTF_TYPE_UNKNOWN = 0,
51 CTF_TYPE_INTEGER,
52 CTF_TYPE_FLOAT,
53 CTF_TYPE_ENUM,
54 CTF_TYPE_STRING,
55 CTF_TYPE_STRUCT,
56 CTF_TYPE_UNTAGGED_VARIANT,
57 CTF_TYPE_VARIANT,
58 CTF_TYPE_ARRAY,
59 CTF_TYPE_SEQUENCE,
60 NR_CTF_TYPES,
61 };
62
63 /*
64 * the supported CTF string encodings
65 */
66 enum ctf_string_encoding {
67 CTF_STRING_NONE = 0,
68 CTF_STRING_UTF8,
69 CTF_STRING_ASCII,
70 CTF_STRING_UNKNOWN,
71 };
72
73 /*
74 * bt_ctf_get_top_level_scope: return a definition of the top-level scope
75 *
76 * Top-level scopes are defined in the bt_ctf_scope enum.
77 * In order to get a field or a field list, the user needs to pass a
78 * scope as argument, this scope can be a top-level scope or a scope
79 * relative to an arbitrary field. This function provides the mapping
80 * between the enum and the actual definition of top-level scopes.
81 * On error return NULL.
82 */
83 const struct definition *bt_ctf_get_top_level_scope(const struct bt_ctf_event *event,
84 enum bt_ctf_scope scope);
85
86 /*
87 * bt_ctf_event_get_name: returns the name of the event or NULL on error
88 */
89 const char *bt_ctf_event_name(const struct bt_ctf_event *event);
90
91 /*
92 * bt_ctf_get_timestamp_raw: returns the timestamp of the event as written in
93 * the packet or -1ULL on error
94 */
95 uint64_t bt_ctf_get_timestamp_raw(const struct bt_ctf_event *event);
96
97 /*
98 * bt_ctf_get_timestamp: returns the timestamp of the event offsetted with the
99 * system clock source or -1ULL on error
100 */
101 uint64_t bt_ctf_get_timestamp(const struct bt_ctf_event *event);
102
103 /*
104 * bt_ctf_get_field_list: set list pointer to an array of definition
105 * pointers and set count to the number of elements in the array.
106 * Return 0 on success and a negative value on error.
107 */
108 int bt_ctf_get_field_list(const struct bt_ctf_event *event,
109 const struct definition *scope,
110 struct definition const * const **list,
111 unsigned int *count);
112
113 /*
114 * bt_ctf_get_field: returns the definition of a specific field
115 */
116 const struct definition *bt_ctf_get_field(const struct bt_ctf_event *event,
117 const struct definition *scope,
118 const char *field);
119
120 /*
121 * bt_ctf_get_index: if the field is an array or a sequence, return the element
122 * at position index, otherwise return NULL;
123 */
124 const struct definition *bt_ctf_get_index(const struct bt_ctf_event *event,
125 const struct definition *field,
126 unsigned int index);
127
128 /*
129 * bt_ctf_field_name: returns the name of a field or NULL on error
130 */
131 const char *bt_ctf_field_name(const struct definition *def);
132
133 /*
134 * bt_ctf_field_type: returns the type of a field or -1 if unknown
135 */
136 enum ctf_type_id bt_ctf_field_type(const struct definition *def);
137
138 /*
139 * bt_ctf_get_int_signedness: return the signedness of an integer
140 *
141 * return 0 if unsigned
142 * return 1 if signed
143 * return -1 on error
144 */
145 int bt_ctf_get_int_signedness(const struct definition *field);
146
147 /*
148 * bt_ctf_get_int_base: return the base of an int or a negative value on error
149 */
150 int bt_ctf_get_int_base(const struct definition *field);
151
152 /*
153 * bt_ctf_get_int_byte_order: return the byte order of an int or a negative
154 * value on error
155 */
156 int bt_ctf_get_int_byte_order(const struct definition *field);
157
158 /*
159 * bt_ctf_get_encoding: return the encoding of an int or a string.
160 * return a negative value on error
161 */
162 enum ctf_string_encoding bt_ctf_get_encoding(const struct definition *field);
163
164 /*
165 * bt_ctf_get_array_len: return the len of an array or a negative
166 * value on error
167 */
168 int bt_ctf_get_array_len(const struct definition *field);
169
170 /*
171 * Field access functions
172 *
173 * These functions return the value associated with the field passed in
174 * parameter.
175 *
176 * If the field does not exist or is not of the type requested, the value
177 * returned is undefined. To check if an error occured, use the
178 * bt_ctf_field_error() function after accessing a field.
179 */
180 uint64_t bt_ctf_get_uint64(const struct definition *field);
181 int64_t bt_ctf_get_int64(const struct definition *field);
182 char *bt_ctf_get_char_array(const struct definition *field);
183 char *bt_ctf_get_string(const struct definition *field);
184
185 /*
186 * bt_ctf_field_error: returns the last error code encountered while
187 * accessing a field and reset the error flag.
188 * Return 0 if no error, a negative value otherwise.
189 */
190 int bt_ctf_field_get_error(void);
191
192 /*
193 * bt_ctf_get_event_decl_list: set list pointer to an array of bt_ctf_event_decl
194 * pointers and set count to the number of elements in the array.
195 *
196 * Return 0 on success and a negative value on error.
197 */
198 int bt_ctf_get_event_decl_list(int handle_id, struct bt_context *ctx,
199 struct bt_ctf_event_decl * const **list,
200 unsigned int *count);
201
202 /*
203 * bt_ctf_get_decl_event_name: return the name of the event or NULL on error
204 */
205 const char *bt_ctf_get_decl_event_name(const struct bt_ctf_event_decl *event);
206
207 /*
208 * bt_ctf_get_decl_fields: set list pointer to an array of bt_ctf_field_decl
209 * pointers and set count to the number of elements in the array.
210 *
211 * Returns 0 on success and a negative value on error
212 */
213 int bt_ctf_get_decl_fields(struct bt_ctf_event_decl *event_decl,
214 enum bt_ctf_scope scope,
215 struct bt_ctf_field_decl const * const **list,
216 unsigned int *count);
217
218 /*
219 * bt_ctf_get_decl_field_name: return the name of a field decl or NULL on error
220 */
221 const char *bt_ctf_get_decl_field_name(const struct bt_ctf_field_decl *field);
222
223 #endif /* _BABELTRACE_CTF_EVENTS_H */
This page took 0.061399 seconds and 4 git commands to generate.