Visibility hidden by default
[babeltrace.git] / src / plugins / ctf / common / metadata / ctf-meta-update-stream-class-config.cpp
CommitLineData
afd45274 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
afd45274 3 *
0235b0db 4 * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
afd45274
PP
5 */
6
3fadfbc0 7#include <babeltrace2/babeltrace.h>
91d81473 8#include "common/macros.h"
578e048b 9#include "common/assert.h"
afd45274
PP
10#include <glib.h>
11#include <stdint.h>
12#include <string.h>
13#include <inttypes.h>
14
087cd0f5 15#include "ctf-meta-visitors.hpp"
afd45274 16
afd45274
PP
17int ctf_trace_class_update_stream_class_config(struct ctf_trace_class *ctf_tc)
18{
4164020e
SM
19 struct ctf_field_class_int *int_fc;
20 uint64_t i;
afd45274 21
4164020e
SM
22 for (i = 0; i < ctf_tc->stream_classes->len; i++) {
23 struct ctf_stream_class *sc = (ctf_stream_class *) ctf_tc->stream_classes->pdata[i];
afd45274 24
4164020e
SM
25 if (sc->is_translated) {
26 continue;
27 }
afd45274 28
4164020e
SM
29 if (!sc->packet_context_fc) {
30 continue;
31 }
afd45274 32
4164020e
SM
33 int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
34 ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_begin");
35 if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME) {
36 sc->packets_have_ts_begin = true;
37 }
afd45274 38
4164020e
SM
39 int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
40 ctf_field_class_as_struct(sc->packet_context_fc), "timestamp_end");
41 if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_END_TIME) {
42 sc->packets_have_ts_end = true;
43 }
afd45274 44
4164020e
SM
45 int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
46 ctf_field_class_as_struct(sc->packet_context_fc), "events_discarded");
47 if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT) {
48 sc->has_discarded_events = true;
49 }
afd45274 50
4164020e
SM
51 sc->discarded_events_have_default_cs =
52 sc->has_discarded_events && sc->packets_have_ts_begin && sc->packets_have_ts_end;
53 int_fc = ctf_field_class_struct_borrow_member_int_field_class_by_name(
54 ctf_field_class_as_struct(sc->packet_context_fc), "packet_seq_num");
55 if (int_fc && int_fc->meaning == CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT) {
56 sc->has_discarded_packets = true;
57 }
afd45274 58
4164020e
SM
59 sc->discarded_packets_have_default_cs =
60 sc->has_discarded_packets && sc->packets_have_ts_begin && sc->packets_have_ts_end;
61 }
afd45274 62
4164020e 63 return 0;
afd45274 64}
This page took 0.065026 seconds and 4 git commands to generate.