1 #ifndef BABELTRACE_CTF_IR_TRACE_INTERNAL_H
2 #define BABELTRACE_CTF_IR_TRACE_INTERNAL_H
5 * BabelTrace - CTF IR: Trace internal
7 * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <babeltrace/assert-pre-internal.h>
31 #include <babeltrace/ctf-ir/trace.h>
32 #include <babeltrace/ctf-ir/stream-class-internal.h>
33 #include <babeltrace/ctf-ir/field-types.h>
34 #include <babeltrace/ctf-ir/fields.h>
35 #include <babeltrace/ctf-ir/validation-internal.h>
36 #include <babeltrace/ctf-ir/attributes-internal.h>
37 #include <babeltrace/ctf-ir/clock-class-internal.h>
38 #include <babeltrace/object-internal.h>
39 #include <babeltrace/object-pool-internal.h>
40 #include <babeltrace/babeltrace-internal.h>
41 #include <babeltrace/values.h>
42 #include <babeltrace/types.h>
44 #include <sys/types.h>
45 #include <babeltrace/compat/uuid-internal.h>
48 struct bt_object base
;
51 unsigned char uuid
[BABELTRACE_UUID_LEN
];
53 enum bt_byte_order native_byte_order
;
54 struct bt_value
*environment
;
55 GPtrArray
*clock_classes
; /* Array of pointers to bt_clock_class */
56 GPtrArray
*stream_classes
; /* Array of ptrs to bt_stream_class */
57 GPtrArray
*streams
; /* Array of ptrs to bt_stream */
58 struct bt_field_type
*packet_header_field_type
;
59 int64_t next_stream_id
;
62 * This flag indicates if the trace is valid. A valid
63 * trace is _always_ frozen.
67 GPtrArray
*listeners
; /* Array of struct listener_wrapper */
68 GArray
*is_static_listeners
;
70 bt_bool in_remove_listener
;
72 /* Pool of `struct bt_field_wrapper *` */
73 struct bt_object_pool packet_header_field_pool
;
77 int bt_trace_object_modification(struct bt_visitor_object
*object
,
81 bt_bool
bt_trace_has_clock_class(struct bt_trace
*trace
,
82 struct bt_clock_class
*clock_class
);
85 @brief User function type to use with bt_trace_add_listener().
87 @param[in] obj New CTF IR object which is part of the trace
89 @param[in] data User data.
93 typedef void (*bt_listener_cb
)(struct bt_visitor_object
*obj
, void *data
);
96 @brief Adds the trace class modification listener \p listener to
97 the CTF IR trace class \p trace_class.
99 Once you add \p listener to \p trace_class, whenever \p trace_class
100 is modified, \p listener is called with the new element and with
103 @param[in] trace_class Trace class to which to add \p listener.
104 @param[in] listener Modification listener function.
105 @param[in] data User data.
106 @returns 0 on success, or a negative value on error.
108 @prenotnull{trace_class}
109 @prenotnull{listener}
110 @postrefcountsame{trace_class}
113 int bt_trace_add_listener(struct bt_trace
*trace_class
,
114 bt_listener_cb listener
, void *data
);
117 void bt_trace_freeze(struct bt_trace
*trace
)
125 BT_LOGD("Freezing trace: addr=%p, name=\"%s\"",
126 trace
, bt_trace_get_name(trace
));
127 BT_LOGD_STR("Freezing packet header field type.");
128 bt_field_type_freeze(trace
->packet_header_field_type
);
129 BT_LOGD_STR("Freezing environment attributes.");
130 bt_attributes_freeze(trace
->environment
);
132 if (trace
->clock_classes
->len
> 0) {
133 BT_LOGD_STR("Freezing clock classes.");
136 for (i
= 0; i
< trace
->clock_classes
->len
; i
++) {
137 struct bt_clock_class
*clock_class
=
138 g_ptr_array_index(trace
->clock_classes
, i
);
140 bt_clock_class_freeze(clock_class
);
146 #endif /* BABELTRACE_CTF_IR_TRACE_INTERNAL_H */