Docs fix: Change bt_ctf_writer_create_stream return description
[babeltrace.git] / include / babeltrace / ctf-writer / writer.h
CommitLineData
46bd0f2b
JG
1#ifndef BABELTRACE_CTF_WRITER_WRITER_H
2#define BABELTRACE_CTF_WRITER_WRITER_H
3
4/*
5 * BabelTrace - CTF Writer: Writer
6 *
7 * Copyright 2013 EfficiOS Inc.
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#ifdef __cplusplus
34extern "C" {
35#endif
36
37struct bt_ctf_writer;
38struct bt_ctf_stream;
39struct bt_ctf_stream_class;
40struct bt_ctf_clock;
41
42enum bt_ctf_byte_order {
43 BT_CTF_BYTE_ORDER_NATIVE = 0,
44 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
45 BT_CTF_BYTE_ORDER_BIG_ENDIAN,
46 BT_CTF_BYTE_ORDER_NETWORK,
47};
48
49/*
50 * bt_ctf_writer_create: create a writer instance.
51 *
52 * Allocate a new writer that will produce a trace in the given path.
53 * The creation of a writer sets its reference count to 1.
54 *
55 * @param path Path to the trace's containing folder (string is copied).
56 *
57 * Returns an allocated writer on success, NULL on error.
58 */
59extern struct bt_ctf_writer *bt_ctf_writer_create(const char *path);
60
61/*
62 * bt_ctf_writer_create_stream: create a stream instance.
63 *
64 * Allocate a new stream instance and register it to the writer. The creation of
65 * a stream sets its reference count to 1.
66 *
67 * @param writer Writer instance.
68 * @param stream_class Stream class to instantiate.
69 *
0e4e7f39 70 * Returns an allocated stream on success, NULL on error.
46bd0f2b
JG
71 */
72extern struct bt_ctf_stream *bt_ctf_writer_create_stream(
73 struct bt_ctf_writer *writer,
74 struct bt_ctf_stream_class *stream_class);
75
76/*
77 * bt_ctf_writer_add_environment_field: add an environment field to the trace.
78 *
79 * Add an environment field to the trace. The name and value parameters are
80 * copied.
81 *
82 * @param writer Writer instance.
83 * @param name Name of the environment field (will be copied).
84 * @param value Value of the environment field (will be copied).
85 *
86 * Returns 0 on success, a negative value on error.
87 */
88extern int bt_ctf_writer_add_environment_field(struct bt_ctf_writer *writer,
89 const char *name,
90 const char *value);
91
92/*
93 * bt_ctf_writer_add_clock: add a clock to the trace.
94 *
95 * Add a clock to the trace. Clocks assigned to stream classes must be
96 * registered to the writer.
97 *
98 * @param writer Writer instance.
99 * @param clock Clock to add to the trace.
100 *
101 * Returns 0 on success, a negative value on error.
102 */
103extern int bt_ctf_writer_add_clock(struct bt_ctf_writer *writer,
104 struct bt_ctf_clock *clock);
105
106/*
107 * bt_ctf_writer_get_metadata_string: get meta-data string.
108 *
109 * Get the trace's TSDL meta-data. The caller assumes the ownership of the
110 * returned string.
111 *
112 * @param writer Writer instance.
113 *
114 * Returns the metadata string on success, NULL on error.
115 */
116extern char *bt_ctf_writer_get_metadata_string(struct bt_ctf_writer *writer);
117
118/*
119 * bt_ctf_writer_flush_metadata: flush the trace's metadata to disk.
120 *
121 * Flush the trace's metadata to the metadata file. Note that the metadata will
122 * be flushed automatically when the Writer instance is released (last call to
123 * bt_ctf_writer_put).
124 *
125 * @param writer Writer instance.
126 */
127extern void bt_ctf_writer_flush_metadata(struct bt_ctf_writer *writer);
128
129/*
130 * bt_ctf_writer_set_byte_order: set a field type's byte order.
131 *
132 * Set the trace's byte order. Defaults to BT_CTF_BYTE_ORDER_NATIVE,
133 * the host machine's endianness.
134 *
135 * @param writer Writer instance.
136 * @param byte_order Trace's byte order.
137 *
138 * Returns 0 on success, a negative value on error.
139 */
140extern int bt_ctf_writer_set_byte_order(struct bt_ctf_writer *writer,
141 enum bt_ctf_byte_order byte_order);
142
143/*
144 * bt_ctf_writer_get and bt_ctf_writer_put: increment and decrement the
145 * writer's reference count.
146 *
147 * These functions ensure that the writer won't be destroyed while it
148 * is in use. The same number of get and put (plus one extra put to
149 * release the initial reference done at creation) have to be done to
150 * destroy a writer.
151 *
152 * When the writer's reference count is decremented to 0 by a
153 * bt_ctf_writer_put, the writer is freed.
154 *
155 * @param writer Writer instance.
156 */
157extern void bt_ctf_writer_get(struct bt_ctf_writer *writer);
158extern void bt_ctf_writer_put(struct bt_ctf_writer *writer);
159
160#ifdef __cplusplus
161}
162#endif
163
164#endif /* BABELTRACE_CTF_WRITER_WRITER_H */
This page took 0.028105 seconds and 4 git commands to generate.