Fix: source.ctf.lttng-live: muxing failure on clear (unit conversion)
[babeltrace.git] / src / ctf-writer / validation.h
CommitLineData
16ca5ff0 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
16ca5ff0 3 *
0235b0db 4 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
16ca5ff0
PP
5 */
6
0235b0db
MJ
7#ifndef BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
8#define BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
9
91d81473 10#include "common/macros.h"
578e048b
MJ
11
12#include "values.h"
16ca5ff0
PP
13
14struct bt_ctf_trace_common;
15struct bt_ctf_stream_class_common;
16struct bt_ctf_event_class_common;
17struct bt_ctf_field_type_common;
18
19typedef struct bt_ctf_field_type_common *(*bt_ctf_validation_flag_copy_field_type_func)(
20 struct bt_ctf_field_type_common *);
21
22enum bt_ctf_validation_flag {
23 BT_CTF_VALIDATION_FLAG_TRACE = 1,
24 BT_CTF_VALIDATION_FLAG_STREAM = 2,
25 BT_CTF_VALIDATION_FLAG_EVENT = 4,
26};
27
28/*
29 * Validation output structure.
30 *
31 * This is where the results of the validation function go. The field
32 * types are the validated ones which should replace the original field
33 * types of a trace, a stream class, and an event class.
34 *
35 * `valid_flags` contains the results of the validation.
36 */
37struct bt_ctf_validation_output {
38 struct bt_ctf_field_type_common *packet_header_type;
39 struct bt_ctf_field_type_common *packet_context_type;
40 struct bt_ctf_field_type_common *event_header_type;
41 struct bt_ctf_field_type_common *stream_event_ctx_type;
42 struct bt_ctf_field_type_common *event_context_type;
43 struct bt_ctf_field_type_common *event_payload_type;
44 enum bt_ctf_validation_flag valid_flags;
45};
46
47/*
48 * This function resolves and validates the field types of an event
49 * class, a stream class, and a trace. Copies are created if needed
50 * and the resulting field types to use are placed in the `output`
51 * validation structure, which also contains the results of the
52 * validation. Copies can replace the original field types of a trace,
53 * a stream class, and an event class using
54 * bt_ctf_validation_replace_types().
55 *
56 * The current known validity of the field types of the trace,
57 * stream class, and event class must be indicated with the
58 * `trace_valid`, `stream_class_valid`, and `event_class_valid`
59 * parameters. If a class is valid, its field types are not copied,
60 * validated, or resolved during this call.
61 *
62 * The validation flags `validate_flags` indicate which classes should
63 * have their field types validated.
64 *
65 * All parameters are owned by the caller.
66 */
67BT_HIDDEN
e1e02a22 68int bt_ctf_validate_class_types(struct bt_ctf_private_value *environment,
16ca5ff0
PP
69 struct bt_ctf_field_type_common *packet_header_type,
70 struct bt_ctf_field_type_common *packet_context_type,
71 struct bt_ctf_field_type_common *event_header_type,
72 struct bt_ctf_field_type_common *stream_event_ctx_type,
73 struct bt_ctf_field_type_common *event_context_type,
74 struct bt_ctf_field_type_common *event_payload_type,
75 int trace_valid, int stream_class_valid, int event_class_valid,
76 struct bt_ctf_validation_output *output,
77 enum bt_ctf_validation_flag validate_flags,
78 bt_ctf_validation_flag_copy_field_type_func copy_field_type_func);
79
80/*
81 * This function replaces the actual field types of a trace, a stream
82 * class, and an event class with the appropriate field types contained
83 * in a validation output structure.
84 *
85 * The replace flags `replace_flags` indicate which classes should have
86 * their field types replaced.
87 *
88 * Note that the field types that are not used in the validation output
89 * structure are still owned by it at the end of this call.
90 * bt_ctf_validation_output_put_types() should be called to clean the
91 * structure.
92 *
93 * All parameters are owned by the caller.
94 */
95BT_HIDDEN
96void bt_ctf_validation_replace_types(struct bt_ctf_trace_common *trace,
97 struct bt_ctf_stream_class_common *stream_class,
98 struct bt_ctf_event_class_common *event_class,
99 struct bt_ctf_validation_output *output,
100 enum bt_ctf_validation_flag replace_flags);
101
102/*
103 * This function puts all the field types contained in a given
104 * validation output structure.
105 *
106 * `output` is owned by the caller and is not freed here.
107 */
108BT_HIDDEN
109void bt_ctf_validation_output_put_types(
110 struct bt_ctf_validation_output *output);
111
112#endif /* BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H */
This page took 0.069409 seconds and 4 git commands to generate.