| 1 | #ifndef BABELTRACE_CTF_IR_STREAM_H |
| 2 | #define BABELTRACE_CTF_IR_STREAM_H |
| 3 | |
| 4 | /* |
| 5 | * BabelTrace - CTF IR: Stream |
| 6 | * |
| 7 | * Copyright 2013, 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/stream-class.h> |
| 34 | #include <stdint.h> |
| 35 | |
| 36 | #ifdef __cplusplus |
| 37 | extern "C" { |
| 38 | #endif |
| 39 | |
| 40 | /** |
| 41 | @defgroup ctfirstream CTF IR stream |
| 42 | @ingroup ctfir |
| 43 | @brief CTF IR stream. |
| 44 | |
| 45 | @code |
| 46 | #include <babeltrace/ctf-ir/stream.h> |
| 47 | @endcode |
| 48 | |
| 49 | @note |
| 50 | See \ref ctfirwriterstream which documents additional CTF IR stream |
| 51 | functions exclusive to the CTF IR writer mode. |
| 52 | |
| 53 | A CTF IR <strong><em>stream</em></strong> is an instance of a |
| 54 | \link ctfirstreamclass CTF IR stream class\endlink. |
| 55 | |
| 56 | You can obtain a CTF IR stream object in two different modes: |
| 57 | |
| 58 | - <strong>Normal mode</strong>: use bt_ctf_stream_create() with a stream |
| 59 | class having a \link ctfirtraceclass CTF IR trace class\endlink parent |
| 60 | \em not created by a \link ctfirwriter CTF IR writer\endlink object to |
| 61 | create a default stream. |
| 62 | - <strong>CTF IR writer mode</strong>: use bt_ctf_stream_create() with |
| 63 | a stream class having a trace class parent created by a CTF IR writer |
| 64 | object, or use bt_ctf_writer_create_stream(). |
| 65 | |
| 66 | A CTF IR stream object represents a CTF stream, that is, a sequence of |
| 67 | packets containing events: |
| 68 | |
| 69 | @imgtracestructure |
| 70 | |
| 71 | A CTF IR stream does not contain, however, actual \link ctfirpacket CTF |
| 72 | IR packet\endlink objects: it only acts as a common parent to identify |
| 73 | the original CTF stream of packet objects. |
| 74 | |
| 75 | As with any Babeltrace object, CTF IR stream objects have |
| 76 | <a href="https://en.wikipedia.org/wiki/Reference_counting">reference |
| 77 | counts</a>. See \ref refs to learn more about the reference counting |
| 78 | management of Babeltrace objects. |
| 79 | |
| 80 | @sa ctfirstreamclass |
| 81 | @sa ctfirpacket |
| 82 | @sa ctfirwriterstream |
| 83 | |
| 84 | @file |
| 85 | @brief CTF IR stream type and functions. |
| 86 | @sa ctfirstream |
| 87 | |
| 88 | @addtogroup ctfirstream |
| 89 | @{ |
| 90 | */ |
| 91 | |
| 92 | /** |
| 93 | @struct bt_ctf_stream |
| 94 | @brief A CTF IR stream. |
| 95 | @sa ctfirstream |
| 96 | @sa ctfirwriterstream |
| 97 | */ |
| 98 | struct bt_ctf_stream; |
| 99 | struct bt_ctf_event; |
| 100 | |
| 101 | /** |
| 102 | @brief Creates a default CTF IR stream named \p name from the CTF IR |
| 103 | stream class \p stream_class. |
| 104 | |
| 105 | \p stream_class \em must have a parent |
| 106 | \link ctfirtraceclass CTF IR trace class\endlink. |
| 107 | |
| 108 | If the parent \link ctfirtraceclass trace class\endlink of |
| 109 | \p stream_class was created by a \link ctfirwriter CTF IR writer\endlink |
| 110 | object, then the stream object is created in CTF IR writer mode, and |
| 111 | you can use the functions of \ref ctfirwriterstream on it. |
| 112 | Otherwise it is created in normal mode: you should only use the |
| 113 | functions documented in this module on it. |
| 114 | |
| 115 | \p name can be \c NULL to create an unnamed stream object. |
| 116 | |
| 117 | @param[in] stream_class CTF IR stream class to use to create the |
| 118 | CTF IR stream. |
| 119 | @param[in] name Name of the stream object to create (copied on |
| 120 | success) or \c NULL to create an unnamed stream. |
| 121 | @returns Created stream object, or \c NULL on error. |
| 122 | |
| 123 | @prenotnull{stream_class} |
| 124 | @pre \p stream_class has a parent trace class. |
| 125 | @postsuccessrefcountret1 |
| 126 | */ |
| 127 | extern struct bt_ctf_stream *bt_ctf_stream_create( |
| 128 | struct bt_ctf_stream_class *stream_class, |
| 129 | const char *name); |
| 130 | |
| 131 | /** |
| 132 | @brief Returns the name of the CTF IR stream \p stream. |
| 133 | |
| 134 | On success, \p stream remains the sole owner of the returned string. |
| 135 | |
| 136 | @param[in] stream Stream object of which to get the name. |
| 137 | @returns Name of stream \p stream, or \c NULL if |
| 138 | \p stream is unnamed or on error. |
| 139 | |
| 140 | @prenotnull{stream} |
| 141 | @postrefcountsame{stream} |
| 142 | */ |
| 143 | extern const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream); |
| 144 | |
| 145 | /** |
| 146 | @brief Returns the parent CTF IR stream class of the CTF IR |
| 147 | stream \p stream. |
| 148 | |
| 149 | This function returns a reference to the stream class which was used |
| 150 | to create the stream object in the first place with |
| 151 | bt_ctf_stream_create(). |
| 152 | |
| 153 | @param[in] stream Stream of which to get the parent stream class. |
| 154 | @returns Parent stream class of \p stream, |
| 155 | or \c NULL on error. |
| 156 | |
| 157 | @prenotnull{stream} |
| 158 | @postsuccessrefcountretinc |
| 159 | */ |
| 160 | extern struct bt_ctf_stream_class *bt_ctf_stream_get_class( |
| 161 | struct bt_ctf_stream *stream); |
| 162 | |
| 163 | /** @} */ |
| 164 | |
| 165 | #ifdef __cplusplus |
| 166 | } |
| 167 | #endif |
| 168 | |
| 169 | #endif /* BABELTRACE_CTF_IR_STREAM_H */ |