1 #ifndef BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
2 #define BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H
5 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include "common/babeltrace.h"
30 struct bt_ctf_trace_common
;
31 struct bt_ctf_stream_class_common
;
32 struct bt_ctf_event_class_common
;
33 struct bt_ctf_field_type_common
;
35 typedef struct bt_ctf_field_type_common
*(*bt_ctf_validation_flag_copy_field_type_func
)(
36 struct bt_ctf_field_type_common
*);
38 enum bt_ctf_validation_flag
{
39 BT_CTF_VALIDATION_FLAG_TRACE
= 1,
40 BT_CTF_VALIDATION_FLAG_STREAM
= 2,
41 BT_CTF_VALIDATION_FLAG_EVENT
= 4,
45 * Validation output structure.
47 * This is where the results of the validation function go. The field
48 * types are the validated ones which should replace the original field
49 * types of a trace, a stream class, and an event class.
51 * `valid_flags` contains the results of the validation.
53 struct bt_ctf_validation_output
{
54 struct bt_ctf_field_type_common
*packet_header_type
;
55 struct bt_ctf_field_type_common
*packet_context_type
;
56 struct bt_ctf_field_type_common
*event_header_type
;
57 struct bt_ctf_field_type_common
*stream_event_ctx_type
;
58 struct bt_ctf_field_type_common
*event_context_type
;
59 struct bt_ctf_field_type_common
*event_payload_type
;
60 enum bt_ctf_validation_flag valid_flags
;
64 * This function resolves and validates the field types of an event
65 * class, a stream class, and a trace. Copies are created if needed
66 * and the resulting field types to use are placed in the `output`
67 * validation structure, which also contains the results of the
68 * validation. Copies can replace the original field types of a trace,
69 * a stream class, and an event class using
70 * bt_ctf_validation_replace_types().
72 * The current known validity of the field types of the trace,
73 * stream class, and event class must be indicated with the
74 * `trace_valid`, `stream_class_valid`, and `event_class_valid`
75 * parameters. If a class is valid, its field types are not copied,
76 * validated, or resolved during this call.
78 * The validation flags `validate_flags` indicate which classes should
79 * have their field types validated.
81 * All parameters are owned by the caller.
84 int bt_ctf_validate_class_types(struct bt_ctf_private_value
*environment
,
85 struct bt_ctf_field_type_common
*packet_header_type
,
86 struct bt_ctf_field_type_common
*packet_context_type
,
87 struct bt_ctf_field_type_common
*event_header_type
,
88 struct bt_ctf_field_type_common
*stream_event_ctx_type
,
89 struct bt_ctf_field_type_common
*event_context_type
,
90 struct bt_ctf_field_type_common
*event_payload_type
,
91 int trace_valid
, int stream_class_valid
, int event_class_valid
,
92 struct bt_ctf_validation_output
*output
,
93 enum bt_ctf_validation_flag validate_flags
,
94 bt_ctf_validation_flag_copy_field_type_func copy_field_type_func
);
97 * This function replaces the actual field types of a trace, a stream
98 * class, and an event class with the appropriate field types contained
99 * in a validation output structure.
101 * The replace flags `replace_flags` indicate which classes should have
102 * their field types replaced.
104 * Note that the field types that are not used in the validation output
105 * structure are still owned by it at the end of this call.
106 * bt_ctf_validation_output_put_types() should be called to clean the
109 * All parameters are owned by the caller.
112 void bt_ctf_validation_replace_types(struct bt_ctf_trace_common
*trace
,
113 struct bt_ctf_stream_class_common
*stream_class
,
114 struct bt_ctf_event_class_common
*event_class
,
115 struct bt_ctf_validation_output
*output
,
116 enum bt_ctf_validation_flag replace_flags
);
119 * This function puts all the field types contained in a given
120 * validation output structure.
122 * `output` is owned by the caller and is not freed here.
125 void bt_ctf_validation_output_put_types(
126 struct bt_ctf_validation_output
*output
);
128 #endif /* BABELTRACE_CTF_WRITER_VALIDATION_INTERNAL_H */