| 1 | #ifndef BABELTRACE_CTF_WRITER_EVENT_H |
| 2 | #define BABELTRACE_CTF_WRITER_EVENT_H |
| 3 | |
| 4 | /* |
| 5 | * BabelTrace - CTF Writer: Event |
| 6 | * |
| 7 | * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 8 | * |
| 9 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 10 | * |
| 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: |
| 17 | * |
| 18 | * The above copyright notice and this permission notice shall be included in |
| 19 | * all copies or substantial portions of the Software. |
| 20 | * |
| 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 |
| 27 | * SOFTWARE. |
| 28 | * |
| 29 | * The Common Trace Format (CTF) Specification is available at |
| 30 | * http://www.efficios.com/ctf |
| 31 | */ |
| 32 | |
| 33 | #include <babeltrace/object.h> |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | |
| 39 | struct bt_ctf_event; |
| 40 | struct bt_ctf_event_class; |
| 41 | struct bt_ctf_stream; |
| 42 | struct bt_ctf_field; |
| 43 | struct bt_ctf_field_type; |
| 44 | |
| 45 | enum bt_ctf_event_class_log_level { |
| 46 | /// Unknown, used for errors. |
| 47 | BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN = -1, |
| 48 | |
| 49 | /// Unspecified log level. |
| 50 | BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED = 255, |
| 51 | |
| 52 | /// System is unusable. |
| 53 | BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY = 0, |
| 54 | |
| 55 | /// Action must be taken immediately. |
| 56 | BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT = 1, |
| 57 | |
| 58 | /// Critical conditions. |
| 59 | BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL = 2, |
| 60 | |
| 61 | /// Error conditions. |
| 62 | BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR = 3, |
| 63 | |
| 64 | /// Warning conditions. |
| 65 | BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING = 4, |
| 66 | |
| 67 | /// Normal, but significant, condition. |
| 68 | BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE = 5, |
| 69 | |
| 70 | /// Informational message. |
| 71 | BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO = 6, |
| 72 | |
| 73 | /// Debug information with system-level scope (set of programs). |
| 74 | BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM = 7, |
| 75 | |
| 76 | /// Debug information with program-level scope (set of processes). |
| 77 | BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM = 8, |
| 78 | |
| 79 | /// Debug information with process-level scope (set of modules). |
| 80 | BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS = 9, |
| 81 | |
| 82 | /// Debug information with module (executable/library) scope (set of units). |
| 83 | BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE = 10, |
| 84 | |
| 85 | /// Debug information with compilation unit scope (set of functions). |
| 86 | BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT = 11, |
| 87 | |
| 88 | /// Debug information with function-level scope. |
| 89 | BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION = 12, |
| 90 | |
| 91 | /// Debug information with line-level scope (default log level). |
| 92 | BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE = 13, |
| 93 | |
| 94 | /// Debug-level message. |
| 95 | BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG = 14, |
| 96 | }; |
| 97 | |
| 98 | extern struct bt_ctf_event *bt_ctf_event_create( |
| 99 | struct bt_ctf_event_class *event_class); |
| 100 | |
| 101 | extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, |
| 102 | const char *name); |
| 103 | |
| 104 | extern int bt_ctf_event_set_payload(struct bt_ctf_event *event, |
| 105 | const char *name, struct bt_ctf_field *field); |
| 106 | |
| 107 | extern struct bt_ctf_field *bt_ctf_event_get_payload_field( |
| 108 | struct bt_ctf_event *event); |
| 109 | |
| 110 | extern int bt_ctf_event_set_payload_field(struct bt_ctf_event *event, |
| 111 | struct bt_ctf_field *field); |
| 112 | |
| 113 | extern int bt_ctf_event_set_context(struct bt_ctf_event *event, |
| 114 | struct bt_ctf_field *field); |
| 115 | |
| 116 | extern struct bt_ctf_field *bt_ctf_event_get_context( |
| 117 | struct bt_ctf_event *event); |
| 118 | |
| 119 | extern int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event, |
| 120 | struct bt_ctf_field *field); |
| 121 | |
| 122 | extern struct bt_ctf_field *bt_ctf_event_get_stream_event_context( |
| 123 | struct bt_ctf_event *event); |
| 124 | |
| 125 | extern int bt_ctf_event_set_header(struct bt_ctf_event *event, |
| 126 | struct bt_ctf_field *field); |
| 127 | |
| 128 | extern struct bt_ctf_field *bt_ctf_event_get_header( |
| 129 | struct bt_ctf_event *event); |
| 130 | |
| 131 | extern struct bt_ctf_stream *bt_ctf_event_get_stream( |
| 132 | struct bt_ctf_event *event); |
| 133 | |
| 134 | extern struct bt_ctf_event_class *bt_ctf_event_get_class( |
| 135 | struct bt_ctf_event *event); |
| 136 | |
| 137 | /* Pre-2.0 CTF writer compatibility */ |
| 138 | static inline |
| 139 | void bt_ctf_event_get(struct bt_ctf_event *event) |
| 140 | { |
| 141 | bt_object_get_ref(event); |
| 142 | } |
| 143 | |
| 144 | /* Pre-2.0 CTF writer compatibility */ |
| 145 | static inline |
| 146 | void bt_ctf_event_put(struct bt_ctf_event *event) |
| 147 | { |
| 148 | bt_object_put_ref(event); |
| 149 | } |
| 150 | |
| 151 | extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name); |
| 152 | |
| 153 | extern struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class( |
| 154 | struct bt_ctf_event_class *event_class); |
| 155 | |
| 156 | extern const char *bt_ctf_event_class_get_name( |
| 157 | struct bt_ctf_event_class *event_class); |
| 158 | |
| 159 | extern int64_t bt_ctf_event_class_get_id( |
| 160 | struct bt_ctf_event_class *event_class); |
| 161 | |
| 162 | extern int bt_ctf_event_class_set_id( |
| 163 | struct bt_ctf_event_class *event_class, uint64_t id); |
| 164 | |
| 165 | extern enum bt_ctf_event_class_log_level bt_ctf_event_class_get_log_level( |
| 166 | struct bt_ctf_event_class *event_class); |
| 167 | |
| 168 | extern int bt_ctf_event_class_set_log_level( |
| 169 | struct bt_ctf_event_class *event_class, |
| 170 | enum bt_ctf_event_class_log_level log_level); |
| 171 | |
| 172 | extern const char *bt_ctf_event_class_get_emf_uri( |
| 173 | struct bt_ctf_event_class *event_class); |
| 174 | |
| 175 | extern int bt_ctf_event_class_set_emf_uri( |
| 176 | struct bt_ctf_event_class *event_class, |
| 177 | const char *emf_uri); |
| 178 | |
| 179 | extern struct bt_ctf_field_type *bt_ctf_event_class_get_context_field_type( |
| 180 | struct bt_ctf_event_class *event_class); |
| 181 | |
| 182 | extern int bt_ctf_event_class_set_context_field_type( |
| 183 | struct bt_ctf_event_class *event_class, |
| 184 | struct bt_ctf_field_type *context_type); |
| 185 | |
| 186 | extern struct bt_ctf_field_type *bt_ctf_event_class_get_payload_field_type( |
| 187 | struct bt_ctf_event_class *event_class); |
| 188 | |
| 189 | extern int bt_ctf_event_class_set_payload_field_type( |
| 190 | struct bt_ctf_event_class *event_class, |
| 191 | struct bt_ctf_field_type *payload_type); |
| 192 | |
| 193 | extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, |
| 194 | struct bt_ctf_field_type *field_type, |
| 195 | const char *name); |
| 196 | |
| 197 | extern struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name( |
| 198 | struct bt_ctf_event_class *event_class, const char *name); |
| 199 | |
| 200 | /* Pre-2.0 CTF writer compatibility */ |
| 201 | static inline |
| 202 | void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class) |
| 203 | { |
| 204 | bt_object_get_ref(event_class); |
| 205 | } |
| 206 | |
| 207 | /* Pre-2.0 CTF writer compatibility */ |
| 208 | static inline |
| 209 | void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class) |
| 210 | { |
| 211 | bt_object_put_ref(event_class); |
| 212 | } |
| 213 | |
| 214 | #ifdef __cplusplus |
| 215 | } |
| 216 | #endif |
| 217 | |
| 218 | #endif /* BABELTRACE_CTF_WRITER_EVENT_H */ |