bt_ctf_stream_class_add_event_class(). You can add a stream class to a
trace class with bt_ctf_trace_add_stream_class().
+You can access the streams of a trace, that is, the streams which were
+created from the trace's stream classes with bt_ctf_stream_create(),
+with bt_ctf_trace_get_stream().
+
A trace class owns the <strong>trace packet header</strong>
\link ctfirfieldtypes field type\endlink, which represents the
\c trace.packet.header CTF scope. This field type describes the
/** @} */
+/**
+@name Stream children functions
+@{
+*/
+
+/**
+@brief Returns the number of streams contained in the CTF IR trace
+ class \p trace_class.
+
+@param[in] trace_class Trace class of which to get the number
+ of children streams.
+@returns Number of children streams
+ contained in \p trace_class, or a negative
+ value on error.
+
+@prenotnull{trace_class}
+@postrefcountsame{trace_class}
+*/
+extern int bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace_class);
+
+/**
+@brief Returns the stream at index \p index in the CTF IR trace
+ class \p trace_class.
+
+@param[in] trace_class Trace class of which to get the stream.
+@param[in] index Index of the stream to find.
+@returns Stream at index \p index, or \c NULL
+ on error.
+
+@prenotnull{trace_class}
+@pre \p index is lesser than the number of streams contained in
+ the trace class \p trace_class (see
+ bt_ctf_trace_get_stream_count()).
+@postrefcountsame{trace_class}
+*/
+extern struct bt_ctf_stream *bt_ctf_trace_get_stream(
+ struct bt_ctf_trace *trace_class, int index);
+
+/** @} */
+
/**
@name Misc. functions
@{
return ret;
}
+int bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace)
+{
+ int ret;
+
+ if (!trace) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = trace->streams->len;
+
+end:
+ return ret;
+}
+
+struct bt_ctf_stream *bt_ctf_trace_get_stream(struct bt_ctf_trace *trace,
+ int index)
+{
+ struct bt_ctf_stream *stream = NULL;
+
+ if (!trace || index >= trace->streams->len) {
+ goto end;
+ }
+
+ stream = bt_get(g_ptr_array_index(trace->streams, index));
+
+end:
+ return stream;
+}
+
int bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace)
{
int ret;
struct bt_ctf_clock_class *ret_clock_class;
struct bt_ctf_stream_class *stream_class, *ret_stream_class;
struct bt_ctf_stream *stream1;
+ struct bt_ctf_stream *stream;
const char *ret_string;
const unsigned char *ret_uuid;
unsigned char tmp_uuid[16] = { 0 };
/* Instantiate a stream and append events */
ret = bt_ctf_writer_add_clock(writer, clock);
assert(ret == 0);
+ ok(bt_ctf_trace_get_stream_count(trace) == 0,
+ "bt_ctf_trace_get_stream_count() succeeds and returns the correct value (0)");
stream1 = bt_ctf_writer_create_stream(writer, stream_class);
ok(stream1, "Instanciate a stream class from writer");
+ ok(bt_ctf_trace_get_stream_count(trace) == 1,
+ "bt_ctf_trace_get_stream_count() succeeds and returns the correct value (1)");
+ stream = bt_ctf_trace_get_stream(trace, 0);
+ ok(stream == stream1,
+ "bt_ctf_trace_get_stream() succeeds and returns the correct value");
+ BT_PUT(stream);
/*
* Creating a stream through a writer adds the given stream
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/ctf-ir/trace.h>
+#include <babeltrace/ctf-ir/trace-internal.h>
#include <stdlib.h>
#include <string.h>