ctf plugin: notif iter: use "borrow" functions for metadata where possible
[babeltrace.git] / include / babeltrace / ctf-ir / validation-internal.h
1 #ifndef BABELTRACE_CTF_IR_VALIDATION_INTERNAL_H
2 #define BABELTRACE_CTF_IR_VALIDATION_INTERNAL_H
3
4 /*
5 * Babeltrace - CTF IR: Validation of trace, stream class, and event class
6 *
7 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 */
27
28 #include <babeltrace/values.h>
29 #include <babeltrace/babeltrace-internal.h>
30
31 struct bt_trace_common;
32 struct bt_stream_class_common;
33 struct bt_event_class_common;
34 struct bt_field_type_common;
35
36 typedef struct bt_field_type_common *(*bt_validation_flag_copy_field_type_func)(
37 struct bt_field_type_common *);
38
39 enum bt_validation_flag {
40 BT_VALIDATION_FLAG_TRACE = 1,
41 BT_VALIDATION_FLAG_STREAM = 2,
42 BT_VALIDATION_FLAG_EVENT = 4,
43 };
44
45 /*
46 * Validation output structure.
47 *
48 * This is where the results of the validation function go. The field
49 * types are the validated ones which should replace the original field
50 * types of a trace, a stream class, and an event class.
51 *
52 * `valid_flags` contains the results of the validation.
53 */
54 struct bt_validation_output {
55 struct bt_field_type_common *packet_header_type;
56 struct bt_field_type_common *packet_context_type;
57 struct bt_field_type_common *event_header_type;
58 struct bt_field_type_common *stream_event_ctx_type;
59 struct bt_field_type_common *event_context_type;
60 struct bt_field_type_common *event_payload_type;
61 enum bt_validation_flag valid_flags;
62 };
63
64 /*
65 * This function resolves and validates the field types of an event
66 * class, a stream class, and a trace. Copies are created if needed
67 * and the resulting field types to use are placed in the `output`
68 * validation structure, which also contains the results of the
69 * validation. Copies can replace the original field types of a trace,
70 * a stream class, and an event class using
71 * bt_validation_replace_types().
72 *
73 * The current known validity of the field types of the trace,
74 * stream class, and event class must be indicated with the
75 * `trace_valid`, `stream_class_valid`, and `event_class_valid`
76 * parameters. If a class is valid, its field types are not copied,
77 * validated, or resolved during this call.
78 *
79 * The validation flags `validate_flags` indicate which classes should
80 * have their field types validated.
81 *
82 * All parameters are owned by the caller.
83 */
84 BT_HIDDEN
85 int bt_validate_class_types(struct bt_value *environment,
86 struct bt_field_type_common *packet_header_type,
87 struct bt_field_type_common *packet_context_type,
88 struct bt_field_type_common *event_header_type,
89 struct bt_field_type_common *stream_event_ctx_type,
90 struct bt_field_type_common *event_context_type,
91 struct bt_field_type_common *event_payload_type,
92 int trace_valid, int stream_class_valid, int event_class_valid,
93 struct bt_validation_output *output,
94 enum bt_validation_flag validate_flags,
95 bt_validation_flag_copy_field_type_func copy_field_type_func);
96
97 /*
98 * This function replaces the actual field types of a trace, a stream
99 * class, and an event class with the appropriate field types contained
100 * in a validation output structure.
101 *
102 * The replace flags `replace_flags` indicate which classes should have
103 * their field types replaced.
104 *
105 * Note that the field types that are not used in the validation output
106 * structure are still owned by it at the end of this call.
107 * bt_validation_output_put_types() should be called to clean the
108 * structure.
109 *
110 * All parameters are owned by the caller.
111 */
112 BT_HIDDEN
113 void bt_validation_replace_types(struct bt_trace_common *trace,
114 struct bt_stream_class_common *stream_class,
115 struct bt_event_class_common *event_class,
116 struct bt_validation_output *output,
117 enum bt_validation_flag replace_flags);
118
119 /*
120 * This function puts all the field types contained in a given
121 * validation output structure.
122 *
123 * `output` is owned by the caller and is not freed here.
124 */
125 BT_HIDDEN
126 void bt_validation_output_put_types(
127 struct bt_validation_output *output);
128
129 #endif /* BABELTRACE_CTF_IR_VALIDATION_INTERNAL_H */
This page took 0.033728 seconds and 4 git commands to generate.