lib: rename clock class's absolute property to "origin is Unix epoch"
[babeltrace.git] / plugins / libctfcopytrace / ctfcopytrace.c
index 145770f56d1b0200e24bc0829b8680d3b660b9a8..a65b05032a84efcdb79123fe91c3cb88ba174aec 100644 (file)
 #include <babeltrace/assert-internal.h>
 
 #include "ctfcopytrace.h"
-#include "clock-fields.h"
+#include "clock-field.h"
 
 BT_HIDDEN
-struct bt_clock_class *ctf_copy_clock_class(FILE *err,
-               struct bt_clock_class *clock_class)
+const bt_clock_class *ctf_copy_clock_class(FILE *err,
+               const bt_clock_class *clock_class)
 {
        int64_t offset, offset_s;
        int int_ret;
        uint64_t u64_ret;
        const char *name, *description;
-       struct bt_clock_class *writer_clock_class = NULL;
+       const bt_clock_class *writer_clock_class = NULL;
 
        BT_ASSERT(err && clock_class);
 
@@ -83,10 +83,10 @@ struct bt_clock_class *ctf_copy_clock_class(FILE *err,
        int_ret = bt_clock_class_set_offset_cycles(writer_clock_class, offset);
        BT_ASSERT(!int_ret);
 
-       int_ret = bt_clock_class_is_absolute(clock_class);
+       int_ret = bt_clock_class_origin_is_unix_epoch(clock_class);
        BT_ASSERT(int_ret >= 0);
 
-       int_ret = bt_clock_class_set_is_absolute(writer_clock_class, int_ret);
+       int_ret = bt_clock_class_set_origin_is_unix_epoch(writer_clock_class, int_ret);
        BT_ASSERT(!int_ret);
 
 end:
@@ -94,25 +94,25 @@ end:
 }
 
 BT_HIDDEN
-enum bt_component_status ctf_copy_clock_classes(FILE *err,
-               struct bt_trace *writer_trace,
-               struct bt_stream_class *writer_stream_class,
-               struct bt_trace *trace)
+bt_component_status ctf_copy_clock_classes(FILE *err,
+               const bt_trace *writer_trace,
+               const bt_stream_class *writer_stream_class,
+               const bt_trace *trace)
 {
-       enum bt_component_status ret;
+       bt_component_status ret;
        int int_ret, clock_class_count, i;
 
        clock_class_count = bt_trace_get_clock_class_count(trace);
 
        for (i = 0; i < clock_class_count; i++) {
-               struct bt_clock_class *writer_clock_class;
-               struct bt_clock_class *clock_class =
+               const bt_clock_class *writer_clock_class;
+               const bt_clock_class *clock_class =
                        bt_trace_get_clock_class_by_index(trace, i);
 
                BT_ASSERT(clock_class);
 
                writer_clock_class = ctf_copy_clock_class(err, clock_class);
-               bt_object_put_ref(clock_class);
+               bt_clock_class_put_ref(clock_class);
                if (!writer_clock_class) {
                        BT_LOGE_STR("Failed to copy clock class.");
                        ret = BT_COMPONENT_STATUS_ERROR;
@@ -121,7 +121,7 @@ enum bt_component_status ctf_copy_clock_classes(FILE *err,
 
                int_ret = bt_trace_add_clock_class(writer_trace, writer_clock_class);
                if (int_ret != 0) {
-                       BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class);
+                       BT_CLOCK_CLASS_PUT_REF_AND_RESET(writer_clock_class);
                        BT_LOGE_STR("Failed to add clock class.");
                        ret = BT_COMPONENT_STATUS_ERROR;
                        goto end;
@@ -130,7 +130,7 @@ enum bt_component_status ctf_copy_clock_classes(FILE *err,
                /*
                 * Ownership transferred to the trace.
                 */
-               bt_object_put_ref(writer_clock_class);
+               bt_clock_class_put_ref(writer_clock_class);
        }
 
        ret = BT_COMPONENT_STATUS_OK;
@@ -140,8 +140,8 @@ end:
 }
 
 static
-void replace_clock_classes(struct bt_trace *trace_copy,
-               struct bt_field_type *field_type)
+void replace_clock_classes(const bt_trace *trace_copy,
+               bt_field_type *field_type)
 {
        int ret;
 
@@ -151,9 +151,9 @@ void replace_clock_classes(struct bt_trace *trace_copy,
        switch (bt_field_type_get_type_id(field_type)) {
        case BT_FIELD_TYPE_ID_INTEGER:
        {
-               struct bt_clock_class *mapped_clock_class =
+               const bt_clock_class *mapped_clock_class =
                        bt_field_type_integer_get_mapped_clock_class(field_type);
-               struct bt_clock_class *clock_class_copy = NULL;
+               const bt_clock_class *clock_class_copy = NULL;
                const char *name;
 
                if (!mapped_clock_class) {
@@ -168,15 +168,15 @@ void replace_clock_classes(struct bt_trace *trace_copy,
                ret = bt_field_type_integer_set_mapped_clock_class(
                        field_type, clock_class_copy);
                BT_ASSERT(ret == 0);
-               bt_object_put_ref(mapped_clock_class);
-               bt_object_put_ref(clock_class_copy);
+               bt_clock_class_put_ref(mapped_clock_class);
+               bt_clock_class_put_ref(clock_class_copy);
                break;
        }
        case BT_FIELD_TYPE_ID_ENUM:
        case BT_FIELD_TYPE_ID_ARRAY:
        case BT_FIELD_TYPE_ID_SEQUENCE:
        {
-               struct bt_field_type *subtype = NULL;
+               bt_field_type *subtype = NULL;
 
                switch (bt_field_type_get_type_id(field_type)) {
                case BT_FIELD_TYPE_ID_ENUM:
@@ -210,7 +210,7 @@ void replace_clock_classes(struct bt_trace *trace_copy,
 
                for (i = 0; i < count; i++) {
                        const char *name;
-                       struct bt_field_type *member_type;
+                       bt_field_type *member_type;
 
                        ret = bt_field_type_structure_get_field_by_index(
                                field_type, &name, &member_type, i);
@@ -229,7 +229,7 @@ void replace_clock_classes(struct bt_trace *trace_copy,
 
                for (i = 0; i < count; i++) {
                        const char *name;
-                       struct bt_field_type *member_type;
+                       bt_field_type *member_type;
 
                        ret = bt_field_type_variant_get_field_by_index(
                                field_type, &name, &member_type, i);
@@ -246,16 +246,16 @@ void replace_clock_classes(struct bt_trace *trace_copy,
 }
 
 BT_HIDDEN
-struct bt_event_class *ctf_copy_event_class(FILE *err,
-               struct bt_trace *trace_copy,
-               struct bt_event_class *event_class)
+const bt_event_class *ctf_copy_event_class(FILE *err,
+               const bt_trace *trace_copy,
+               const bt_event_class *event_class)
 {
-       struct bt_event_class *writer_event_class = NULL;
-       struct bt_field_type *context = NULL, *payload_type = NULL;
+       const bt_event_class *writer_event_class = NULL;
+       bt_field_type *context = NULL, *payload_type = NULL;
        const char *name;
        int ret;
        int64_t id;
-       enum bt_event_class_log_level log_level;
+       bt_event_class_log_level log_level;
        const char *emf_uri;
 
        name = bt_event_class_get_name(event_class);
@@ -296,7 +296,7 @@ struct bt_event_class *ctf_copy_event_class(FILE *err,
 
        payload_type = bt_event_class_get_payload_type(event_class);
        if (payload_type) {
-               struct bt_field_type *ft_copy =
+               bt_field_type *ft_copy =
                        bt_field_type_copy(payload_type);
 
                if (!ft_copy) {
@@ -315,7 +315,7 @@ struct bt_event_class *ctf_copy_event_class(FILE *err,
 
        context = bt_event_class_get_context_type(event_class);
        if (context) {
-               struct bt_field_type *ft_copy =
+               bt_field_type *ft_copy =
                        bt_field_type_copy(context);
 
                if (!ft_copy) {
@@ -334,7 +334,7 @@ struct bt_event_class *ctf_copy_event_class(FILE *err,
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_event_class);
+       BT_EVENT_CLASS_PUT_REF_AND_RESET(writer_event_class);
 end:
        BT_OBJECT_PUT_REF_AND_RESET(context);
        BT_OBJECT_PUT_REF_AND_RESET(payload_type);
@@ -342,14 +342,14 @@ end:
 }
 
 BT_HIDDEN
-enum bt_component_status ctf_copy_event_classes(FILE *err,
-               struct bt_stream_class *stream_class,
-               struct bt_stream_class *writer_stream_class)
+bt_component_status ctf_copy_event_classes(FILE *err,
+               const bt_stream_class *stream_class,
+               const bt_stream_class *writer_stream_class)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-       struct bt_event_class *event_class = NULL, *writer_event_class = NULL;
+       bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       const bt_event_class *event_class = NULL, *writer_event_class = NULL;
        int count, i;
-       struct bt_trace *writer_trace =
+       const bt_trace *writer_trace =
                bt_stream_class_get_trace(writer_stream_class);
 
        BT_ASSERT(writer_trace);
@@ -373,8 +373,8 @@ enum bt_component_status ctf_copy_event_classes(FILE *err,
                                 * event_classes after a trace has become
                                 * static.
                                 */
-                               BT_OBJECT_PUT_REF_AND_RESET(writer_event_class);
-                               BT_OBJECT_PUT_REF_AND_RESET(event_class);
+                               BT_EVENT_CLASS_PUT_REF_AND_RESET(writer_event_class);
+                               BT_EVENT_CLASS_PUT_REF_AND_RESET(event_class);
                                continue;
                        }
                }
@@ -394,29 +394,29 @@ enum bt_component_status ctf_copy_event_classes(FILE *err,
                        ret = BT_COMPONENT_STATUS_ERROR;
                        goto error;
                }
-               BT_OBJECT_PUT_REF_AND_RESET(writer_event_class);
-               BT_OBJECT_PUT_REF_AND_RESET(event_class);
+               BT_EVENT_CLASS_PUT_REF_AND_RESET(writer_event_class);
+               BT_EVENT_CLASS_PUT_REF_AND_RESET(event_class);
        }
 
        goto end;
 
 error:
-       bt_object_put_ref(event_class);
-       bt_object_put_ref(writer_event_class);
+       bt_event_class_put_ref(event_class);
+       bt_event_class_put_ref(writer_event_class);
 end:
-       bt_object_put_ref(writer_trace);
+       bt_trace_put_ref(writer_trace);
        return ret;
 }
 
 BT_HIDDEN
-struct bt_stream_class *ctf_copy_stream_class(FILE *err,
-               struct bt_stream_class *stream_class,
-               struct bt_trace *writer_trace,
+const bt_stream_class *ctf_copy_stream_class(FILE *err,
+               const bt_stream_class *stream_class,
+               const bt_trace *writer_trace,
                bool override_ts64)
 {
-       struct bt_field_type *type = NULL;
-       struct bt_field_type *type_copy = NULL;
-       struct bt_stream_class *writer_stream_class = NULL;
+       bt_field_type *type = NULL;
+       bt_field_type *type_copy = NULL;
+       const bt_stream_class *writer_stream_class = NULL;
        int ret_int;
        const char *name = bt_stream_class_get_name(stream_class);
 
@@ -451,7 +451,7 @@ struct bt_stream_class *ctf_copy_stream_class(FILE *err,
                ret_int = bt_trace_get_clock_class_count(writer_trace);
                BT_ASSERT(ret_int >= 0);
                if (override_ts64 && ret_int > 0) {
-                       struct bt_field_type *new_event_header_type;
+                       bt_field_type *new_event_header_type;
 
                        new_event_header_type = override_header_type(err, type_copy,
                                        writer_trace);
@@ -502,7 +502,7 @@ struct bt_stream_class *ctf_copy_stream_class(FILE *err,
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class);
+       BT_STREAM_CLASS_PUT_REF_AND_RESET(writer_stream_class);
 end:
        bt_object_put_ref(type);
        bt_object_put_ref(type_copy);
@@ -510,10 +510,10 @@ end:
 }
 
 BT_HIDDEN
-int ctf_stream_copy_packet_header(FILE *err, struct bt_packet *packet,
-               struct bt_stream *writer_stream)
+int ctf_stream_copy_packet_header(FILE *err, const bt_packet *packet,
+               const bt_stream *writer_stream)
 {
-       struct bt_field *packet_header = NULL, *writer_packet_header = NULL;
+       const bt_field *packet_header = NULL, *writer_packet_header = NULL;
        int ret = 0;
 
        packet_header = bt_packet_get_header(packet);
@@ -545,10 +545,10 @@ end:
 }
 
 BT_HIDDEN
-int ctf_packet_copy_header(FILE *err, struct bt_packet *packet,
-               struct bt_packet *writer_packet)
+int ctf_packet_copy_header(FILE *err, const bt_packet *packet,
+               const bt_packet *writer_packet)
 {
-       struct bt_field *packet_header = NULL, *writer_packet_header = NULL;
+       const bt_field *packet_header = NULL, *writer_packet_header = NULL;
        int ret = 0;
 
        packet_header = bt_packet_get_header(packet);
@@ -579,10 +579,10 @@ end:
 }
 
 BT_HIDDEN
-int ctf_stream_copy_packet_context(FILE *err, struct bt_packet *packet,
-               struct bt_stream *writer_stream)
+int ctf_stream_copy_packet_context(FILE *err, const bt_packet *packet,
+               const bt_stream *writer_stream)
 {
-       struct bt_field *packet_context = NULL, *writer_packet_context = NULL;
+       const bt_field *packet_context = NULL, *writer_packet_context = NULL;
        int ret = 0;
 
        packet_context = bt_packet_get_context(packet);
@@ -614,11 +614,11 @@ end:
 }
 
 BT_HIDDEN
-int ctf_packet_copy_context(FILE *err, struct bt_packet *packet,
-               struct bt_stream *writer_stream,
-               struct bt_packet *writer_packet)
+int ctf_packet_copy_context(FILE *err, const bt_packet *packet,
+               const bt_stream *writer_stream,
+               const bt_packet *writer_packet)
 {
-       struct bt_field *packet_context = NULL, *writer_packet_context = NULL;
+       const bt_field *packet_context = NULL, *writer_packet_context = NULL;
        int ret = 0;
 
        packet_context = bt_packet_get_context(packet);
@@ -649,16 +649,16 @@ end:
 }
 
 BT_HIDDEN
-int ctf_copy_event_header(FILE *err, struct bt_event *event,
-               struct bt_event_class *writer_event_class,
-               struct bt_event *writer_event,
-               struct bt_field *event_header)
+int ctf_copy_event_header(FILE *err, const bt_event *event,
+               const bt_event_class *writer_event_class,
+               const bt_event *writer_event,
+               const bt_field *event_header)
 {
-       struct bt_clock_class *clock_class = NULL, *writer_clock_class = NULL;
-       struct bt_clock_value *clock_value = NULL, *writer_clock_value = NULL;
+       const bt_clock_class *clock_class = NULL, *writer_clock_class = NULL;
+       bt_clock_snapshot *clock_snapshot = NULL, *writer_clock_snapshot = NULL;
 
        int ret;
-       struct bt_field *writer_event_header = NULL;
+       const bt_field *writer_event_header = NULL;
        uint64_t value;
 
        clock_class = event_get_clock_class(err, event);
@@ -667,12 +667,12 @@ int ctf_copy_event_header(FILE *err, struct bt_event *event,
                goto error;
        }
 
-       clock_value = bt_event_get_clock_value(event, clock_class);
-       BT_OBJECT_PUT_REF_AND_RESET(clock_class);
-       BT_ASSERT(clock_value);
+       clock_snapshot = bt_event_get_clock_snapshot(event, clock_class);
+       BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock_class);
+       BT_ASSERT(clock_snapshot);
 
-       ret = bt_clock_value_get_value(clock_value, &value);
-       BT_OBJECT_PUT_REF_AND_RESET(clock_value);
+       ret = bt_clock_snapshot_get_value(clock_snapshot, &value);
+       BT_OBJECT_PUT_REF_AND_RESET(clock_snapshot);
        if (ret) {
                BT_LOGE_STR("Failed to get clock value.");
                goto error;
@@ -684,15 +684,15 @@ int ctf_copy_event_header(FILE *err, struct bt_event *event,
                goto error;
        }
 
-       writer_clock_value = bt_clock_value_create(writer_clock_class, value);
-       BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class);
-       if (!writer_clock_value) {
+       writer_clock_snapshot = bt_clock_snapshot_create(writer_clock_class, value);
+       BT_CLOCK_CLASS_PUT_REF_AND_RESET(writer_clock_class);
+       if (!writer_clock_snapshot) {
                BT_LOGE_STR("Failed to create clock value.");
                goto error;
        }
 
-       ret = bt_event_set_clock_value(writer_event, writer_clock_value);
-       BT_OBJECT_PUT_REF_AND_RESET(writer_clock_value);
+       ret = bt_event_set_clock_snapshot(writer_event, writer_clock_snapshot);
+       BT_OBJECT_PUT_REF_AND_RESET(writer_clock_snapshot);
        if (ret) {
                BT_LOGE_STR("Failed to set clock value.");
                goto error;
@@ -722,11 +722,11 @@ end:
 }
 
 static
-struct bt_trace *event_class_get_trace(FILE *err,
-               struct bt_event_class *event_class)
+const bt_trace *event_class_get_trace(FILE *err,
+               const bt_event_class *event_class)
 {
-       struct bt_trace *trace = NULL;
-       struct bt_stream_class *stream_class = NULL;
+       const bt_trace *trace = NULL;
+       const bt_stream_class *stream_class = NULL;
 
        stream_class = bt_event_class_get_stream_class(event_class);
        BT_ASSERT(stream_class);
@@ -734,18 +734,18 @@ struct bt_trace *event_class_get_trace(FILE *err,
        trace = bt_stream_class_get_trace(stream_class);
        BT_ASSERT(trace);
 
-       bt_object_put_ref(stream_class);
+       bt_stream_class_put_ref(stream_class);
        return trace;
 }
 
 BT_HIDDEN
-struct bt_event *ctf_copy_event(FILE *err, struct bt_event *event,
-               struct bt_event_class *writer_event_class,
+const bt_event *ctf_copy_event(FILE *err, const bt_event *event,
+               const bt_event_class *writer_event_class,
                bool override_ts64)
 {
-       struct bt_event *writer_event = NULL;
-       struct bt_field *field = NULL, *copy_field = NULL;
-       struct bt_trace *writer_trace = NULL;
+       const bt_event *writer_event = NULL;
+       const bt_field *field = NULL, *copy_field = NULL;
+       const bt_trace *writer_trace = NULL;
        int ret;
 
        writer_event = bt_event_create(writer_event_class);
@@ -850,18 +850,18 @@ error:
 end:
        bt_object_put_ref(field);
        bt_object_put_ref(copy_field);
-       bt_object_put_ref(writer_trace);
+       bt_trace_put_ref(writer_trace);
        return writer_event;
 }
 
 BT_HIDDEN
-enum bt_component_status ctf_copy_trace(FILE *err, struct bt_trace *trace,
-               struct bt_trace *writer_trace)
+bt_component_status ctf_copy_trace(FILE *err, const bt_trace *trace,
+               const bt_trace *writer_trace)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       bt_component_status ret = BT_COMPONENT_STATUS_OK;
        int field_count, i, int_ret;
-       struct bt_field_type *header_type = NULL;
-       enum bt_byte_order order;
+       bt_field_type *header_type = NULL;
+       bt_byte_order order;
        const char *trace_name;
        const unsigned char *trace_uuid;
 
@@ -869,7 +869,7 @@ enum bt_component_status ctf_copy_trace(FILE *err, struct bt_trace *trace,
        for (i = 0; i < field_count; i++) {
                int ret_int;
                const char *name;
-               struct bt_value *value = NULL;
+               bt_value *value = NULL;
 
                name = bt_trace_get_environment_field_name_by_index(
                        trace, i);
@@ -881,7 +881,7 @@ enum bt_component_status ctf_copy_trace(FILE *err, struct bt_trace *trace,
 
                ret_int = bt_trace_set_environment_field(writer_trace,
                                name, value);
-               BT_OBJECT_PUT_REF_AND_RESET(value);
+               BT_VALUE_PUT_REF_AND_RESET(value);
                if (ret_int < 0) {
                        BT_LOGE("Failed to set environment: field-name=\"%s\"",
                                        name);
This page took 0.033239 seconds and 4 git commands to generate.