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