Commit | Line | Data |
---|---|---|
09840de5 PP |
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 | ||
2e33ac5a | 28 | #include <babeltrace/ctf-ir/field-types.h> |
09840de5 PP |
29 | #include <babeltrace/ctf-ir/event.h> |
30 | #include <babeltrace/ctf-ir/stream-class.h> | |
31 | #include <babeltrace/ctf-ir/trace.h> | |
32 | #include <babeltrace/values.h> | |
33 | #include <babeltrace/babeltrace-internal.h> | |
34 | ||
35 | enum bt_ctf_validation_flag { | |
36 | BT_CTF_VALIDATION_FLAG_TRACE = 1, | |
37 | BT_CTF_VALIDATION_FLAG_STREAM = 2, | |
38 | BT_CTF_VALIDATION_FLAG_EVENT = 4, | |
39 | }; | |
40 | ||
41 | /* | |
42 | * Validation output structure. | |
43 | * | |
44 | * This is where the results of the validation function go. The field | |
45 | * types are the validated ones which should replace the original field | |
46 | * types of a trace, a stream class, and an event class. | |
47 | * | |
48 | * `valid_flags` contains the results of the validation. | |
49 | */ | |
50 | struct bt_ctf_validation_output { | |
51 | struct bt_ctf_field_type *packet_header_type; | |
52 | struct bt_ctf_field_type *packet_context_type; | |
53 | struct bt_ctf_field_type *event_header_type; | |
54 | struct bt_ctf_field_type *stream_event_ctx_type; | |
55 | struct bt_ctf_field_type *event_context_type; | |
56 | struct bt_ctf_field_type *event_payload_type; | |
57 | enum bt_ctf_validation_flag valid_flags; | |
58 | }; | |
59 | ||
60 | /* | |
61 | * This function resolves and validates the field types of an event | |
62 | * class, a stream class, and a trace. Copies are created if needed | |
63 | * and the resulting field types to use are placed in the `output` | |
64 | * validation structure, which also contains the results of the | |
65 | * validation. Copies can replace the original field types of a trace, | |
66 | * a stream class, and an event class using | |
67 | * bt_ctf_validation_replace_types(). | |
68 | * | |
69 | * The current known validity of the field types of the trace, | |
70 | * stream class, and event class must be indicated with the | |
71 | * `trace_valid`, `stream_class_valid`, and `event_class_valid` | |
72 | * parameters. If a class is valid, its field types are not copied, | |
73 | * validated, or resolved during this call. | |
74 | * | |
75 | * The validation flags `validate_flags` indicate which classes should | |
76 | * have their field types validated. | |
77 | * | |
78 | * All parameters are owned by the caller. | |
79 | */ | |
80 | BT_HIDDEN | |
81 | int bt_ctf_validate_class_types(struct bt_value *environment, | |
82 | struct bt_ctf_field_type *packet_header_type, | |
83 | struct bt_ctf_field_type *packet_context_type, | |
84 | struct bt_ctf_field_type *event_header_type, | |
85 | struct bt_ctf_field_type *stream_event_ctx_type, | |
86 | struct bt_ctf_field_type *event_context_type, | |
87 | struct bt_ctf_field_type *event_payload_type, | |
88 | int trace_valid, int stream_class_valid, int event_class_valid, | |
89 | struct bt_ctf_validation_output *output, | |
90 | enum bt_ctf_validation_flag validate_flags); | |
91 | ||
92 | /* | |
93 | * This function replaces the actual field types of a trace, a stream | |
94 | * class, and an event class with the appropriate field types contained | |
95 | * in a validation output structure. | |
96 | * | |
97 | * The replace flags `replace_flags` indicate which classes should have | |
98 | * their field types replaced. | |
99 | * | |
100 | * Note that the field types that are not used in the validation output | |
101 | * structure are still owned by it at the end of this call. | |
102 | * bt_ctf_validation_output_put_types() should be called to clean the | |
103 | * structure. | |
104 | * | |
105 | * All parameters are owned by the caller. | |
106 | */ | |
107 | BT_HIDDEN | |
108 | void bt_ctf_validation_replace_types(struct bt_ctf_trace *trace, | |
109 | struct bt_ctf_stream_class *stream_class, | |
110 | struct bt_ctf_event_class *event_class, | |
111 | struct bt_ctf_validation_output *output, | |
112 | enum bt_ctf_validation_flag replace_flags); | |
113 | ||
114 | /* | |
115 | * This function puts all the field types contained in a given | |
116 | * validation output structure. | |
117 | * | |
118 | * `output` is owned by the caller and is not freed here. | |
119 | */ | |
120 | BT_HIDDEN | |
121 | void bt_ctf_validation_output_put_types( | |
122 | struct bt_ctf_validation_output *output); | |
123 | ||
124 | #endif /* BABELTRACE_CTF_IR_VALIDATION_INTERNAL_H */ |