Commit | Line | Data |
---|---|---|
bc37ae52 JG |
1 | #ifndef BABELTRACE_CTF_IR_TRACE_H |
2 | #define BABELTRACE_CTF_IR_TRACE_H | |
3 | ||
4 | /* | |
5 | * BabelTrace - CTF IR: Trace | |
6 | * | |
7 | * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
8 | * | |
9 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
10 | * | |
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
12 | * of this software and associated documentation files (the "Software"), to deal | |
13 | * in the Software without restriction, including without limitation the rights | |
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
15 | * copies of the Software, and to permit persons to whom the Software is | |
16 | * furnished to do so, subject to the following conditions: | |
17 | * | |
18 | * The above copyright notice and this permission notice shall be included in | |
19 | * all copies or substantial portions of the Software. | |
20 | * | |
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
27 | * SOFTWARE. | |
28 | * | |
29 | * The Common Trace Format (CTF) Specification is available at | |
30 | * http://www.efficios.com/ctf | |
31 | */ | |
32 | ||
33 | #include <babeltrace/ctf-ir/event-types.h> | |
34 | ||
35 | #ifdef __cplusplus | |
36 | extern "C" { | |
37 | #endif | |
38 | ||
39 | struct bt_ctf_trace; | |
40 | struct bt_ctf_stream; | |
41 | struct bt_ctf_stream_class; | |
42 | struct bt_ctf_clock; | |
43 | ||
44 | /* | |
45 | * bt_ctf_trace_create: create a trace instance. | |
46 | * | |
47 | * Allocate a new trace | |
48 | * | |
49 | * Returns a new trace on success, NULL on error. | |
50 | */ | |
51 | extern struct bt_ctf_trace *bt_ctf_trace_create(void); | |
52 | ||
53 | /* | |
54 | * bt_ctf_trace_create_stream: create a stream instance. | |
55 | * | |
56 | * Allocate a new stream instance and register it to the trace. The creation of | |
57 | * a stream sets its reference count to 1. | |
58 | * | |
59 | * @param trace Trace instance. | |
60 | * @param stream_class Stream class to instantiate. | |
61 | * | |
62 | * Returns a new stream on success, NULL on error. | |
63 | */ | |
64 | extern struct bt_ctf_stream *bt_ctf_trace_create_stream( | |
65 | struct bt_ctf_trace *trace, | |
66 | struct bt_ctf_stream_class *stream_class); | |
67 | ||
68 | /* | |
69 | * bt_ctf_trace_add_environment_field: add an environment field to the trace. | |
70 | * | |
71 | * Add an environment field to the trace. The name and value parameters are | |
72 | * copied. | |
73 | * | |
74 | * @param trace Trace instance. | |
75 | * @param name Name of the environment field (will be copied). | |
76 | * @param value Value of the environment field (will be copied). | |
77 | * | |
78 | * Returns 0 on success, a negative value on error. | |
79 | */ | |
80 | extern int bt_ctf_trace_add_environment_field(struct bt_ctf_trace *trace, | |
81 | const char *name, | |
82 | const char *value); | |
83 | ||
84 | /* | |
85 | * bt_ctf_trace_add_clock: add a clock to the trace. | |
86 | * | |
87 | * Add a clock to the trace. Clocks assigned to stream classes must be | |
88 | * added to the trace beforehand. | |
89 | * | |
90 | * @param trace Trace instance. | |
91 | * @param clock Clock to add to the trace. | |
92 | * | |
93 | * Returns 0 on success, a negative value on error. | |
94 | */ | |
95 | extern int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace, | |
96 | struct bt_ctf_clock *clock); | |
97 | ||
98 | /* | |
99 | * bt_ctf_trace_get_metadata_string: get metadata string. | |
100 | * | |
101 | * Get the trace's TSDL metadata. The caller assumes the ownership of the | |
102 | * returned string. | |
103 | * | |
104 | * @param trace Trace instance. | |
105 | * | |
106 | * Returns the metadata string on success, NULL on error. | |
107 | */ | |
108 | extern char *bt_ctf_trace_get_metadata_string(struct bt_ctf_trace *trace); | |
109 | ||
110 | /* | |
111 | * bt_ctf_trace_set_byte_order: set a field type's byte order. | |
112 | * | |
113 | * Set the trace's byte order. Defaults to BT_CTF_BYTE_ORDER_NATIVE, | |
114 | * the host machine's endianness. | |
115 | * | |
116 | * @param trace Trace instance. | |
117 | * @param byte_order Trace's byte order. | |
118 | * | |
119 | * Returns 0 on success, a negative value on error. | |
120 | */ | |
121 | extern int bt_ctf_trace_set_byte_order(struct bt_ctf_trace *trace, | |
122 | enum bt_ctf_byte_order byte_order); | |
123 | ||
124 | /* | |
125 | * bt_ctf_trace_get and bt_ctf_trace_put: increment and decrement the | |
126 | * trace's reference count. | |
127 | * | |
128 | * These functions ensure that the trace won't be destroyed while it | |
129 | * is in use. The same number of get and put (plus one extra put to | |
130 | * release the initial reference done at creation) have to be done to | |
131 | * destroy a trace. | |
132 | * | |
133 | * When the trace's reference count is decremented to 0 by a | |
134 | * bt_ctf_trace_put, the trace is freed. | |
135 | * | |
136 | * @param trace Trace instance. | |
137 | */ | |
138 | extern void bt_ctf_trace_get(struct bt_ctf_trace *trace); | |
139 | extern void bt_ctf_trace_put(struct bt_ctf_trace *trace); | |
140 | ||
141 | #ifdef __cplusplus | |
142 | } | |
143 | #endif | |
144 | ||
145 | #endif /* BABELTRACE_CTF_IR_TRACE_H */ |