*/
int valid;
GPtrArray *listeners; /* Array of struct listener_wrapper */
+ bool is_static;
};
struct metadata_context {
@{
*/
+/**
+@brief Returns whether or not the CTF IR trace class \p trace_class
+ is static.
+
+It is guaranteed that a static trace class will never contain new
+streams, stream classes, or clock classes. A static class is always
+frozen.
+
+This function returns \c true if bt_ctf_trace_set_is_static() was
+previously called on it.
+
+@param[in] trace_class Trace class to check.
+@returns \c true if \p trace_class is static,
+
+@sa bt_ctf_trace_set_is_static(): Makes a trace class static.
+*/
+extern bool bt_ctf_trace_is_static(struct bt_ctf_trace *trace_class);
+
+/**
+@brief Makes the CTF IR trace class \p trace_class static.
+
+A static trace class is frozen and you cannot call any modifying
+function on it:
+
+- bt_ctf_trace_add_stream_class()
+- bt_ctf_trace_add_clock_class()
+
+You cannot create a stream with bt_ctf_stream_create() with any of the
+stream classes of a static trace class.
+
+@param[in] trace_class Trace class to make static.
+@returns 0 on success, or a negative value on error.
+
+@prenotnull{trace_class}
+@postrefcountsame{trace_class}
+@postsuccessfrozen{trace_class}
+
+@sa bt_ctf_trace_is_static(): Checks whether or not a given trace class
+ is static.
+*/
+extern int bt_ctf_trace_set_is_static(struct bt_ctf_trace *trace_class);
+
/**
@brief Accepts the visitor \p visitor to visit the hierarchy of the
CTF IR trace class \p trace_class.
goto end;
}
+ trace = bt_ctf_stream_class_get_trace(stream_class);
+ if (trace && trace->is_static) {
+ ret = -1;
+ goto end;
+ }
+
event_id = g_new(int64_t, 1);
if (!event_id) {
ret = -1;
goto end;
}
- trace = bt_ctf_stream_class_get_trace(stream_class);
if (trace) {
/*
* If the stream class is associated with a trace, then
#include <babeltrace/ctf-ir/stream.h>
#include <babeltrace/ctf-ir/stream-internal.h>
#include <babeltrace/ctf-ir/stream-class-internal.h>
+#include <babeltrace/ctf-ir/trace.h>
#include <babeltrace/ctf-ir/trace-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/graph/component-internal.h>
goto error;
}
+ if (bt_ctf_trace_is_static(trace)) {
+ /*
+ * A static trace has the property that all its stream
+ * classes, clock classes, and streams are definitive:
+ * no more can be added, and each object is also frozen.
+ */
+ goto error;
+ }
+
stream = g_new0(struct bt_ctf_stream, 1);
if (!stream) {
goto error;
{
int ret = 0;
- if (!trace || !bt_ctf_clock_class_is_valid(clock_class)) {
+ if (!trace || trace->is_static ||
+ !bt_ctf_clock_class_is_valid(clock_class)) {
ret = -1;
goto end;
}
int event_class_count;
struct bt_ctf_trace *current_parent_trace = NULL;
- if (!trace || !stream_class) {
+ if (!trace || !stream_class || trace->is_static) {
ret = -1;
goto end;
}
bt_put(trace_packet_header_type);
return ret;
}
+
+bool bt_ctf_trace_is_static(struct bt_ctf_trace *trace)
+{
+ bool is_static = false;
+
+ if (!trace) {
+ goto end;
+ }
+
+ is_static = trace->is_static;
+
+end:
+ return is_static;
+}
+
+int bt_ctf_trace_set_is_static(struct bt_ctf_trace *trace)
+{
+ int ret = 0;
+
+ if (!trace) {
+ ret = -1;
+ goto end;
+ }
+
+ trace->is_static = true;
+ bt_ctf_trace_freeze(trace);
+
+end:
+ return ret;
+}