#include <babeltrace/ctf-ir/event-class-internal.h>
#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/ctf-ir/stream-class-internal.h>
+#include <babeltrace/ctf-ir/stream-internal.h>
+#include <babeltrace/ctf-ir/packet.h>
+#include <babeltrace/ctf-ir/packet-internal.h>
#include <babeltrace/ctf-ir/trace-internal.h>
#include <babeltrace/ctf-ir/validation-internal.h>
#include <babeltrace/ctf-ir/packet-internal.h>
* lifetime.
*/
event->event_class = bt_get(event_class);
+ event->clock_values = g_hash_table_new_full(g_direct_hash,
+ g_direct_equal, NULL, g_free);
event_header =
bt_ctf_field_create(validation_output.event_header_type);
if (!event_header) {
{
int ret = 0;
- if (!event || !payload) {
+ if (!event || !payload || event->frozen) {
ret = -1;
goto end;
}
int ret = 0;
struct bt_ctf_field_type *payload_type = NULL;
- if (!event || !payload) {
+ if (!event || !payload || event->frozen) {
ret = -1;
goto end;
}
struct bt_ctf_field_type *field_type = NULL;
struct bt_ctf_stream_class *stream_class = NULL;
- if (!event || !header) {
+ if (!event || !header || event->frozen) {
ret = -1;
goto end;
}
int ret = 0;
struct bt_ctf_field_type *field_type = NULL;
- if (!event || !context) {
+ if (!event || !context || event->frozen) {
ret = -1;
goto end;
}
struct bt_ctf_field_type *field_type = NULL;
struct bt_ctf_stream_class *stream_class = NULL;
- if (!event || !stream_event_context) {
+ if (!event || !stream_event_context || event->frozen) {
ret = -1;
goto end;
}
*/
bt_put(event->event_class);
}
+ g_hash_table_destroy(event->clock_values);
bt_put(event->event_header);
bt_put(event->stream_event_context);
bt_put(event->context_payload);
int ret = 0;
struct bt_ctf_field *id_field = NULL, *timestamp_field = NULL;
- if (!event) {
+ if (!event || event->frozen) {
ret = -1;
goto end;
}
return ret;
}
-struct bt_ctf_event *bt_ctf_event_copy(struct bt_ctf_event *event)
-{
- struct bt_ctf_event *copy = NULL;
-
- if (!event) {
- goto error;
- }
-
- copy = g_new0(struct bt_ctf_event, 1);
- if (!copy) {
- goto error;
- }
-
- bt_object_init(copy, bt_ctf_event_destroy);
- copy->event_class = bt_get(event->event_class);
-
- if (event->event_header) {
- copy->event_header = bt_ctf_field_copy(event->event_header);
- if (!copy->event_header) {
- goto error;
- }
- }
-
- if (event->stream_event_context) {
- copy->stream_event_context =
- bt_ctf_field_copy(event->stream_event_context);
- if (!copy->stream_event_context) {
- goto error;
- }
- }
-
- if (event->context_payload) {
- copy->context_payload = bt_ctf_field_copy(
- event->context_payload);
- if (!copy->context_payload) {
- goto error;
- }
- }
-
- if (event->fields_payload) {
- copy->fields_payload = bt_ctf_field_copy(event->fields_payload);
- if (!copy->fields_payload) {
- goto error;
- }
- }
-
- return copy;
-
-error:
- BT_PUT(copy);
- return copy;
-}
-
int bt_ctf_event_set_packet(struct bt_ctf_event *event,
struct bt_ctf_packet *packet)
{
struct bt_ctf_stream *stream = NULL;
int ret = 0;
- if (!event || !packet) {
+ if (!event || !packet || event->frozen) {
ret = -1;
goto end;
}
return ret;
}
+
+BT_HIDDEN
+void bt_ctf_event_freeze(struct bt_ctf_event *event)
+{
+ assert(event);
+ bt_ctf_packet_freeze(event->packet);
+ bt_ctf_field_freeze(event->event_header);
+ bt_ctf_field_freeze(event->stream_event_context);
+ bt_ctf_field_freeze(event->context_payload);
+ bt_ctf_field_freeze(event->fields_payload);
+ event->frozen = 1;
+}
+
+static
+void insert_stream_clock_value_into_event_clock_values(gpointer key,
+ gpointer value,
+ gpointer data)
+{
+ struct bt_ctf_event *event = data;
+ uint64_t *clock_value;
+
+ assert(event);
+
+ /* Copy clock value because it belongs to the hash table */
+ clock_value = g_new0(uint64_t, 1);
+ *clock_value = *((uint64_t *) value);
+
+ /* Insert copy into event clock values */
+ g_hash_table_insert(event->clock_values, key, clock_value);
+}
+
+BT_HIDDEN
+int bt_ctf_event_register_stream_clock_values(struct bt_ctf_event *event)
+{
+ int ret = 0;
+ struct bt_ctf_stream *stream;
+
+ stream = bt_ctf_event_get_stream(event);
+ assert(stream);
+ g_hash_table_remove_all(event->clock_values);
+ g_hash_table_foreach(stream->clock_values,
+ insert_stream_clock_value_into_event_clock_values, event);
+ BT_PUT(stream);
+
+ return ret;
+}
+
+uint64_t bt_ctf_event_get_clock_value(struct bt_ctf_event *event,
+ struct bt_ctf_clock *clock)
+{
+ uint64_t ret = -1ULL;
+ uint64_t *clock_value;
+
+ if (!event || !clock) {
+ goto end;
+ }
+
+ clock_value = g_hash_table_lookup(event->clock_values, clock);
+ if (!clock_value) {
+ goto end;
+ }
+
+ ret = *clock_value;
+
+end:
+ return ret;
+}