Commit | Line | Data |
---|---|---|
508053d4 PP |
1 | /* |
2 | * Copyright (c) 2021 Philippe Proulx <pproulx@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: MIT | |
5 | */ | |
6 | ||
7 | #ifndef BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP | |
8 | #define BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP | |
9 | ||
508053d4 | 10 | #include <cstdint> |
c802cacb SM |
11 | #include <type_traits> |
12 | ||
508053d4 PP |
13 | #include <babeltrace2/babeltrace.h> |
14 | ||
15 | #include "common/assert.h" | |
7ece2fc0 | 16 | #include "cpp-common/bt2/clock-snapshot.hpp" |
ccae279a | 17 | #include "cpp-common/bt2/trace-ir.hpp" |
c022776a | 18 | #include "cpp-common/bt2s/optional.hpp" |
928d766d | 19 | #include "cpp-common/vendor/wise-enum/wise_enum.h" |
c802cacb | 20 | |
0d218157 | 21 | #include "borrowed-object.hpp" |
c802cacb | 22 | #include "internal/utils.hpp" |
ca61ecbc | 23 | #include "optional-borrowed-object.hpp" |
7f5cdaf0 | 24 | #include "shared-object.hpp" |
9a8d4dcc | 25 | #include "trace-ir.hpp" |
508053d4 PP |
26 | |
27 | namespace bt2 { | |
508053d4 PP |
28 | namespace internal { |
29 | ||
30 | struct MessageRefFuncs final | |
31 | { | |
c677c492 | 32 | static void get(const bt_message * const libObjPtr) noexcept |
508053d4 PP |
33 | { |
34 | bt_message_get_ref(libObjPtr); | |
35 | } | |
36 | ||
c677c492 | 37 | static void put(const bt_message * const libObjPtr) noexcept |
508053d4 PP |
38 | { |
39 | bt_message_put_ref(libObjPtr); | |
40 | } | |
41 | }; | |
42 | ||
b5f55e9f | 43 | } /* namespace internal */ |
508053d4 | 44 | |
26b9d24c | 45 | template <typename ObjT, typename LibObjT> |
7f5cdaf0 | 46 | using SharedMessage = SharedObject<ObjT, LibObjT, internal::MessageRefFuncs>; |
26b9d24c | 47 | |
508053d4 PP |
48 | template <typename LibObjT> |
49 | class CommonStreamBeginningMessage; | |
50 | ||
51 | template <typename LibObjT> | |
52 | class CommonStreamEndMessage; | |
53 | ||
54 | template <typename LibObjT> | |
55 | class CommonEventMessage; | |
56 | ||
57 | template <typename LibObjT> | |
58 | class CommonPacketBeginningMessage; | |
59 | ||
60 | template <typename LibObjT> | |
61 | class CommonPacketEndMessage; | |
62 | ||
63 | template <typename LibObjT> | |
64 | class CommonDiscardedEventsMessage; | |
65 | ||
66 | template <typename LibObjT> | |
67 | class CommonDiscardedPacketsMessage; | |
68 | ||
69 | template <typename LibObjT> | |
70 | class CommonMessageIteratorInactivityMessage; | |
71 | ||
928d766d SM |
72 | /* clang-format off */ |
73 | ||
74 | WISE_ENUM_CLASS(MessageType, | |
75 | (StreamBeginning, BT_MESSAGE_TYPE_STREAM_BEGINNING), | |
76 | (StreamEnd, BT_MESSAGE_TYPE_STREAM_END), | |
77 | (Event, BT_MESSAGE_TYPE_EVENT), | |
78 | (PacketBeginning, BT_MESSAGE_TYPE_PACKET_BEGINNING), | |
79 | (PacketEnd, BT_MESSAGE_TYPE_PACKET_END), | |
80 | (DiscardedEvents, BT_MESSAGE_TYPE_DISCARDED_EVENTS), | |
81 | (DiscardedPackets, BT_MESSAGE_TYPE_DISCARDED_PACKETS), | |
82 | (MessageIteratorInactivity, BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY)); | |
83 | ||
84 | /* clang-format on */ | |
508053d4 PP |
85 | |
86 | template <typename LibObjT> | |
0d218157 | 87 | class CommonMessage : public BorrowedObject<LibObjT> |
508053d4 PP |
88 | { |
89 | private: | |
0d218157 | 90 | using typename BorrowedObject<LibObjT>::_ThisBorrowedObject; |
508053d4 PP |
91 | |
92 | protected: | |
508053d4 PP |
93 | using _ThisCommonMessage = CommonMessage<LibObjT>; |
94 | ||
95 | public: | |
d246c457 | 96 | using typename BorrowedObject<LibObjT>::LibObjPtr; |
26b9d24c | 97 | using Shared = SharedMessage<CommonMessage<LibObjT>, LibObjT>; |
508053d4 | 98 | |
d246c457 | 99 | explicit CommonMessage(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} |
508053d4 PP |
100 | { |
101 | } | |
102 | ||
103 | template <typename OtherLibObjT> | |
0d218157 | 104 | CommonMessage(const CommonMessage<OtherLibObjT> val) noexcept : _ThisBorrowedObject {val} |
508053d4 PP |
105 | { |
106 | } | |
107 | ||
108 | template <typename OtherLibObjT> | |
ac30a470 | 109 | _ThisCommonMessage operator=(const CommonMessage<OtherLibObjT> val) noexcept |
508053d4 | 110 | { |
0d218157 | 111 | _ThisBorrowedObject::operator=(val); |
508053d4 PP |
112 | return *this; |
113 | } | |
114 | ||
328a274a PP |
115 | CommonMessage<const bt_message> asConst() const noexcept |
116 | { | |
117 | return CommonMessage<const bt_message> {*this}; | |
118 | } | |
119 | ||
508053d4 PP |
120 | MessageType type() const noexcept |
121 | { | |
341a67c4 | 122 | return static_cast<MessageType>(bt_message_get_type(this->libObjPtr())); |
508053d4 PP |
123 | } |
124 | ||
125 | bool isStreamBeginning() const noexcept | |
126 | { | |
1c5ea5eb | 127 | return this->type() == MessageType::StreamBeginning; |
508053d4 PP |
128 | } |
129 | ||
130 | bool isStreamEnd() const noexcept | |
131 | { | |
1c5ea5eb | 132 | return this->type() == MessageType::StreamEnd; |
508053d4 PP |
133 | } |
134 | ||
135 | bool isEvent() const noexcept | |
136 | { | |
1c5ea5eb | 137 | return this->type() == MessageType::Event; |
508053d4 PP |
138 | } |
139 | ||
140 | bool isPacketBeginning() const noexcept | |
141 | { | |
1c5ea5eb | 142 | return this->type() == MessageType::PacketBeginning; |
508053d4 PP |
143 | } |
144 | ||
145 | bool isPacketEnd() const noexcept | |
146 | { | |
1c5ea5eb | 147 | return this->type() == MessageType::PacketEnd; |
508053d4 PP |
148 | } |
149 | ||
150 | bool isDiscardedEvents() const noexcept | |
151 | { | |
1c5ea5eb | 152 | return this->type() == MessageType::DiscardedEvents; |
508053d4 PP |
153 | } |
154 | ||
155 | bool isDiscardedPackets() const noexcept | |
156 | { | |
1c5ea5eb | 157 | return this->type() == MessageType::DiscardedPackets; |
508053d4 PP |
158 | } |
159 | ||
160 | bool isMessageIteratorInactivity() const noexcept | |
161 | { | |
1c5ea5eb | 162 | return this->type() == MessageType::MessageIteratorInactivity; |
508053d4 PP |
163 | } |
164 | ||
165 | Shared shared() const noexcept | |
166 | { | |
c9c0b6e2 | 167 | return Shared::createWithRef(*this); |
508053d4 PP |
168 | } |
169 | ||
45e0ded5 PP |
170 | template <typename MessageT> |
171 | MessageT as() const noexcept | |
172 | { | |
173 | return MessageT {this->libObjPtr()}; | |
174 | } | |
175 | ||
508053d4 PP |
176 | CommonStreamBeginningMessage<LibObjT> asStreamBeginning() const noexcept; |
177 | CommonStreamEndMessage<LibObjT> asStreamEnd() const noexcept; | |
178 | CommonEventMessage<LibObjT> asEvent() const noexcept; | |
179 | CommonPacketBeginningMessage<LibObjT> asPacketBeginning() const noexcept; | |
180 | CommonPacketEndMessage<LibObjT> asPacketEnd() const noexcept; | |
181 | CommonDiscardedEventsMessage<LibObjT> asDiscardedEvents() const noexcept; | |
182 | CommonDiscardedPacketsMessage<LibObjT> asDiscardedPackets() const noexcept; | |
183 | CommonMessageIteratorInactivityMessage<LibObjT> asMessageIteratorInactivity() const noexcept; | |
184 | }; | |
185 | ||
186 | using Message = CommonMessage<bt_message>; | |
187 | using ConstMessage = CommonMessage<const bt_message>; | |
188 | ||
189 | namespace internal { | |
190 | ||
4927bae7 PP |
191 | struct MessageTypeDescr |
192 | { | |
193 | using Const = ConstMessage; | |
194 | using NonConst = Message; | |
195 | }; | |
196 | ||
197 | template <> | |
198 | struct TypeDescr<Message> : public MessageTypeDescr | |
199 | { | |
200 | }; | |
201 | ||
202 | template <> | |
203 | struct TypeDescr<ConstMessage> : public MessageTypeDescr | |
204 | { | |
205 | }; | |
206 | ||
508053d4 PP |
207 | template <typename LibObjT> |
208 | struct CommonStreamBeginningMessageSpec; | |
209 | ||
b5f55e9f | 210 | /* Functions specific to mutable stream beginning messages */ |
508053d4 PP |
211 | template <> |
212 | struct CommonStreamBeginningMessageSpec<bt_message> final | |
213 | { | |
214 | static bt_stream *stream(bt_message * const libObjPtr) noexcept | |
215 | { | |
216 | return bt_message_stream_beginning_borrow_stream(libObjPtr); | |
217 | } | |
218 | }; | |
219 | ||
b5f55e9f | 220 | /* Functions specific to constant stream beginning messages */ |
508053d4 PP |
221 | template <> |
222 | struct CommonStreamBeginningMessageSpec<const bt_message> final | |
223 | { | |
224 | static const bt_stream *stream(const bt_message * const libObjPtr) noexcept | |
225 | { | |
226 | return bt_message_stream_beginning_borrow_stream_const(libObjPtr); | |
227 | } | |
228 | }; | |
229 | ||
b5f55e9f | 230 | } /* namespace internal */ |
508053d4 PP |
231 | |
232 | template <typename LibObjT> | |
233 | class CommonStreamBeginningMessage final : public CommonMessage<LibObjT> | |
234 | { | |
235 | private: | |
508053d4 | 236 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 237 | using _Stream = internal::DepStream<LibObjT>; |
508053d4 PP |
238 | |
239 | public: | |
d246c457 | 240 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 241 | using Shared = SharedMessage<CommonStreamBeginningMessage<LibObjT>, LibObjT>; |
508053d4 | 242 | |
d246c457 | 243 | explicit CommonStreamBeginningMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
244 | _ThisCommonMessage {libObjPtr} |
245 | { | |
246 | BT_ASSERT_DBG(this->isStreamBeginning()); | |
247 | } | |
248 | ||
249 | template <typename OtherLibObjT> | |
100fa861 | 250 | CommonStreamBeginningMessage(const CommonStreamBeginningMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
251 | _ThisCommonMessage {val} |
252 | { | |
253 | } | |
254 | ||
255 | template <typename OtherLibObjT> | |
ac30a470 | 256 | CommonStreamBeginningMessage<LibObjT> |
100fa861 | 257 | operator=(const CommonStreamBeginningMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
258 | { |
259 | _ThisCommonMessage::operator=(val); | |
260 | return *this; | |
261 | } | |
262 | ||
328a274a PP |
263 | CommonStreamBeginningMessage<const bt_message> asConst() const noexcept |
264 | { | |
265 | return CommonStreamBeginningMessage<const bt_message> {*this}; | |
266 | } | |
267 | ||
dcb8ae9b | 268 | _Stream stream() const noexcept |
508053d4 PP |
269 | { |
270 | return _Stream { | |
341a67c4 | 271 | internal::CommonStreamBeginningMessageSpec<LibObjT>::stream(this->libObjPtr())}; |
508053d4 PP |
272 | } |
273 | ||
afe77d4f SM |
274 | OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept |
275 | { | |
276 | return bt_message_stream_beginning_borrow_stream_class_default_clock_class_const( | |
277 | this->libObjPtr()); | |
278 | } | |
279 | ||
2a24eba8 | 280 | CommonStreamBeginningMessage defaultClockSnapshot(const std::uint64_t val) const noexcept |
508053d4 | 281 | { |
5c895f64 PP |
282 | static_assert(!std::is_const<LibObjT>::value, |
283 | "Not available with `bt2::ConstStreamBeginningMessage`."); | |
508053d4 | 284 | |
341a67c4 | 285 | bt_message_stream_beginning_set_default_clock_snapshot(this->libObjPtr(), val); |
2a24eba8 | 286 | return *this; |
508053d4 PP |
287 | } |
288 | ||
ca61ecbc | 289 | OptionalBorrowedObject<ConstClockSnapshot> defaultClockSnapshot() const noexcept |
508053d4 PP |
290 | { |
291 | const bt_clock_snapshot *libObjPtr; | |
292 | const auto state = bt_message_stream_beginning_borrow_default_clock_snapshot_const( | |
341a67c4 | 293 | this->libObjPtr(), &libObjPtr); |
508053d4 PP |
294 | |
295 | if (state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) { | |
ca61ecbc | 296 | return libObjPtr; |
508053d4 PP |
297 | } |
298 | ||
ca61ecbc | 299 | return {}; |
508053d4 PP |
300 | } |
301 | ||
302 | Shared shared() const noexcept | |
303 | { | |
c9c0b6e2 | 304 | return Shared::createWithRef(*this); |
508053d4 PP |
305 | } |
306 | }; | |
307 | ||
308 | using StreamBeginningMessage = CommonStreamBeginningMessage<bt_message>; | |
309 | using ConstStreamBeginningMessage = CommonStreamBeginningMessage<const bt_message>; | |
310 | ||
311 | namespace internal { | |
312 | ||
4927bae7 PP |
313 | struct StreamBeginningMessageTypeDescr |
314 | { | |
315 | using Const = ConstStreamBeginningMessage; | |
316 | using NonConst = StreamBeginningMessage; | |
317 | }; | |
318 | ||
319 | template <> | |
320 | struct TypeDescr<StreamBeginningMessage> : public StreamBeginningMessageTypeDescr | |
321 | { | |
322 | }; | |
323 | ||
324 | template <> | |
325 | struct TypeDescr<ConstStreamBeginningMessage> : public StreamBeginningMessageTypeDescr | |
326 | { | |
327 | }; | |
328 | ||
508053d4 PP |
329 | template <typename LibObjT> |
330 | struct CommonStreamEndMessageSpec; | |
331 | ||
b5f55e9f | 332 | /* Functions specific to mutable stream end messages */ |
508053d4 PP |
333 | template <> |
334 | struct CommonStreamEndMessageSpec<bt_message> final | |
335 | { | |
336 | static bt_stream *stream(bt_message * const libObjPtr) noexcept | |
337 | { | |
338 | return bt_message_stream_end_borrow_stream(libObjPtr); | |
339 | } | |
340 | }; | |
341 | ||
b5f55e9f | 342 | /* Functions specific to constant stream end messages */ |
508053d4 PP |
343 | template <> |
344 | struct CommonStreamEndMessageSpec<const bt_message> final | |
345 | { | |
346 | static const bt_stream *stream(const bt_message * const libObjPtr) noexcept | |
347 | { | |
348 | return bt_message_stream_end_borrow_stream_const(libObjPtr); | |
349 | } | |
350 | }; | |
351 | ||
b5f55e9f | 352 | } /* namespace internal */ |
508053d4 PP |
353 | |
354 | template <typename LibObjT> | |
355 | class CommonStreamEndMessage final : public CommonMessage<LibObjT> | |
356 | { | |
357 | private: | |
508053d4 | 358 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 359 | using _Stream = internal::DepStream<LibObjT>; |
508053d4 PP |
360 | |
361 | public: | |
d246c457 | 362 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 363 | using Shared = SharedMessage<CommonStreamEndMessage<LibObjT>, LibObjT>; |
508053d4 | 364 | |
d246c457 | 365 | explicit CommonStreamEndMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
366 | _ThisCommonMessage {libObjPtr} |
367 | { | |
368 | BT_ASSERT_DBG(this->isStreamEnd()); | |
369 | } | |
370 | ||
371 | template <typename OtherLibObjT> | |
100fa861 | 372 | CommonStreamEndMessage(const CommonStreamEndMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
373 | _ThisCommonMessage {val} |
374 | { | |
375 | } | |
376 | ||
377 | template <typename OtherLibObjT> | |
ac30a470 | 378 | CommonStreamEndMessage<LibObjT> |
100fa861 | 379 | operator=(const CommonStreamEndMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
380 | { |
381 | _ThisCommonMessage::operator=(val); | |
382 | return *this; | |
383 | } | |
384 | ||
328a274a PP |
385 | CommonStreamEndMessage<const bt_message> asConst() const noexcept |
386 | { | |
387 | return CommonStreamEndMessage<const bt_message> {*this}; | |
388 | } | |
389 | ||
dcb8ae9b | 390 | _Stream stream() const noexcept |
508053d4 | 391 | { |
341a67c4 | 392 | return _Stream {internal::CommonStreamEndMessageSpec<LibObjT>::stream(this->libObjPtr())}; |
508053d4 PP |
393 | } |
394 | ||
afe77d4f SM |
395 | OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept |
396 | { | |
397 | return bt_message_stream_end_borrow_stream_class_default_clock_class_const( | |
398 | this->libObjPtr()); | |
399 | } | |
400 | ||
2a24eba8 | 401 | CommonStreamEndMessage defaultClockSnapshot(const std::uint64_t val) const noexcept |
508053d4 | 402 | { |
5c895f64 PP |
403 | static_assert(!std::is_const<LibObjT>::value, |
404 | "Not available with `bt2::ConstStreamEndMessage`."); | |
508053d4 | 405 | |
341a67c4 | 406 | bt_message_stream_end_set_default_clock_snapshot(this->libObjPtr(), val); |
2a24eba8 | 407 | return *this; |
508053d4 PP |
408 | } |
409 | ||
ca61ecbc | 410 | OptionalBorrowedObject<ConstClockSnapshot> defaultClockSnapshot() const noexcept |
508053d4 PP |
411 | { |
412 | const bt_clock_snapshot *libObjPtr; | |
413 | const auto state = bt_message_stream_end_borrow_default_clock_snapshot_const( | |
341a67c4 | 414 | this->libObjPtr(), &libObjPtr); |
508053d4 PP |
415 | |
416 | if (state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) { | |
ca61ecbc | 417 | return libObjPtr; |
508053d4 PP |
418 | } |
419 | ||
ca61ecbc | 420 | return {}; |
508053d4 PP |
421 | } |
422 | ||
423 | Shared shared() const noexcept | |
424 | { | |
c9c0b6e2 | 425 | return Shared::createWithRef(*this); |
508053d4 PP |
426 | } |
427 | }; | |
428 | ||
429 | using StreamEndMessage = CommonStreamEndMessage<bt_message>; | |
430 | using ConstStreamEndMessage = CommonStreamEndMessage<const bt_message>; | |
431 | ||
432 | namespace internal { | |
433 | ||
4927bae7 PP |
434 | struct StreamEndMessageTypeDescr |
435 | { | |
436 | using Const = ConstStreamEndMessage; | |
437 | using NonConst = StreamEndMessage; | |
438 | }; | |
439 | ||
440 | template <> | |
441 | struct TypeDescr<StreamEndMessage> : public StreamEndMessageTypeDescr | |
442 | { | |
443 | }; | |
444 | ||
445 | template <> | |
446 | struct TypeDescr<ConstStreamEndMessage> : public StreamEndMessageTypeDescr | |
447 | { | |
448 | }; | |
449 | ||
508053d4 PP |
450 | template <typename LibObjT> |
451 | struct CommonPacketBeginningMessageSpec; | |
452 | ||
b5f55e9f | 453 | /* Functions specific to mutable packet beginning messages */ |
508053d4 PP |
454 | template <> |
455 | struct CommonPacketBeginningMessageSpec<bt_message> final | |
456 | { | |
457 | static bt_packet *packet(bt_message * const libObjPtr) noexcept | |
458 | { | |
459 | return bt_message_packet_beginning_borrow_packet(libObjPtr); | |
460 | } | |
461 | }; | |
462 | ||
b5f55e9f | 463 | /* Functions specific to constant packet beginning messages */ |
508053d4 PP |
464 | template <> |
465 | struct CommonPacketBeginningMessageSpec<const bt_message> final | |
466 | { | |
467 | static const bt_packet *packet(const bt_message * const libObjPtr) noexcept | |
468 | { | |
469 | return bt_message_packet_beginning_borrow_packet_const(libObjPtr); | |
470 | } | |
471 | }; | |
472 | ||
b5f55e9f | 473 | } /* namespace internal */ |
508053d4 PP |
474 | |
475 | template <typename LibObjT> | |
476 | class CommonPacketBeginningMessage final : public CommonMessage<LibObjT> | |
477 | { | |
478 | private: | |
508053d4 | 479 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 480 | using _Packet = internal::DepPacket<LibObjT>; |
508053d4 PP |
481 | |
482 | public: | |
d246c457 | 483 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 484 | using Shared = SharedMessage<CommonPacketBeginningMessage<LibObjT>, LibObjT>; |
508053d4 | 485 | |
d246c457 | 486 | explicit CommonPacketBeginningMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
487 | _ThisCommonMessage {libObjPtr} |
488 | { | |
489 | BT_ASSERT_DBG(this->isPacketBeginning()); | |
490 | } | |
491 | ||
492 | template <typename OtherLibObjT> | |
100fa861 | 493 | CommonPacketBeginningMessage(const CommonPacketBeginningMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
494 | _ThisCommonMessage {val} |
495 | { | |
496 | } | |
497 | ||
498 | template <typename OtherLibObjT> | |
ac30a470 | 499 | CommonPacketBeginningMessage<LibObjT> |
100fa861 | 500 | operator=(const CommonPacketBeginningMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
501 | { |
502 | _ThisCommonMessage::operator=(val); | |
503 | return *this; | |
504 | } | |
505 | ||
328a274a PP |
506 | CommonPacketBeginningMessage<const bt_message> asConst() const noexcept |
507 | { | |
508 | return CommonPacketBeginningMessage<const bt_message> {*this}; | |
509 | } | |
510 | ||
dcb8ae9b | 511 | _Packet packet() const noexcept |
508053d4 PP |
512 | { |
513 | return _Packet { | |
341a67c4 | 514 | internal::CommonPacketBeginningMessageSpec<LibObjT>::packet(this->libObjPtr())}; |
508053d4 PP |
515 | } |
516 | ||
afe77d4f SM |
517 | OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept |
518 | { | |
519 | return bt_message_packet_beginning_borrow_stream_class_default_clock_class_const( | |
520 | this->libObjPtr()); | |
521 | } | |
522 | ||
2a24eba8 | 523 | CommonPacketBeginningMessage defaultClockSnapshot(const std::uint64_t val) const noexcept |
508053d4 | 524 | { |
5c895f64 PP |
525 | static_assert(!std::is_const<LibObjT>::value, |
526 | "Not available with `bt2::ConstPacketBeginningMessage`."); | |
508053d4 | 527 | |
341a67c4 | 528 | bt_message_packet_beginning_set_default_clock_snapshot(this->libObjPtr(), val); |
2a24eba8 | 529 | return *this; |
508053d4 PP |
530 | } |
531 | ||
532 | ConstClockSnapshot defaultClockSnapshot() const noexcept | |
533 | { | |
534 | const auto libObjPtr = | |
341a67c4 | 535 | bt_message_packet_beginning_borrow_default_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
536 | |
537 | return ConstClockSnapshot {libObjPtr}; | |
538 | } | |
539 | ||
540 | Shared shared() const noexcept | |
541 | { | |
c9c0b6e2 | 542 | return Shared::createWithRef(*this); |
508053d4 PP |
543 | } |
544 | }; | |
545 | ||
546 | using PacketBeginningMessage = CommonPacketBeginningMessage<bt_message>; | |
547 | using ConstPacketBeginningMessage = CommonPacketBeginningMessage<const bt_message>; | |
548 | ||
549 | namespace internal { | |
550 | ||
4927bae7 PP |
551 | struct PacketBeginningMessageTypeDescr |
552 | { | |
553 | using Const = ConstPacketBeginningMessage; | |
554 | using NonConst = PacketBeginningMessage; | |
555 | }; | |
556 | ||
557 | template <> | |
558 | struct TypeDescr<PacketBeginningMessage> : public PacketBeginningMessageTypeDescr | |
559 | { | |
560 | }; | |
561 | ||
562 | template <> | |
563 | struct TypeDescr<ConstPacketBeginningMessage> : public PacketBeginningMessageTypeDescr | |
564 | { | |
565 | }; | |
566 | ||
508053d4 PP |
567 | template <typename LibObjT> |
568 | struct CommonPacketEndMessageSpec; | |
569 | ||
b5f55e9f | 570 | /* Functions specific to mutable packet end messages */ |
508053d4 PP |
571 | template <> |
572 | struct CommonPacketEndMessageSpec<bt_message> final | |
573 | { | |
574 | static bt_packet *packet(bt_message * const libObjPtr) noexcept | |
575 | { | |
576 | return bt_message_packet_end_borrow_packet(libObjPtr); | |
577 | } | |
578 | }; | |
579 | ||
b5f55e9f | 580 | /* Functions specific to constant packet end messages */ |
508053d4 PP |
581 | template <> |
582 | struct CommonPacketEndMessageSpec<const bt_message> final | |
583 | { | |
584 | static const bt_packet *packet(const bt_message * const libObjPtr) noexcept | |
585 | { | |
586 | return bt_message_packet_end_borrow_packet_const(libObjPtr); | |
587 | } | |
588 | }; | |
589 | ||
b5f55e9f | 590 | } /* namespace internal */ |
508053d4 PP |
591 | |
592 | template <typename LibObjT> | |
593 | class CommonPacketEndMessage final : public CommonMessage<LibObjT> | |
594 | { | |
595 | private: | |
508053d4 | 596 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 597 | using _Packet = internal::DepPacket<LibObjT>; |
508053d4 PP |
598 | |
599 | public: | |
d246c457 | 600 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 601 | using Shared = SharedMessage<CommonPacketEndMessage<LibObjT>, LibObjT>; |
508053d4 | 602 | |
d246c457 | 603 | explicit CommonPacketEndMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
604 | _ThisCommonMessage {libObjPtr} |
605 | { | |
606 | BT_ASSERT_DBG(this->isPacketEnd()); | |
607 | } | |
608 | ||
609 | template <typename OtherLibObjT> | |
100fa861 | 610 | CommonPacketEndMessage(const CommonPacketEndMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
611 | _ThisCommonMessage {val} |
612 | { | |
613 | } | |
614 | ||
615 | template <typename OtherLibObjT> | |
ac30a470 | 616 | CommonPacketEndMessage<LibObjT> |
100fa861 | 617 | operator=(const CommonPacketEndMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
618 | { |
619 | _ThisCommonMessage::operator=(val); | |
620 | return *this; | |
621 | } | |
622 | ||
328a274a PP |
623 | CommonPacketEndMessage<const bt_message> asConst() const noexcept |
624 | { | |
625 | return CommonPacketEndMessage<const bt_message> {*this}; | |
626 | } | |
627 | ||
dcb8ae9b | 628 | _Packet packet() const noexcept |
508053d4 | 629 | { |
341a67c4 | 630 | return _Packet {internal::CommonPacketEndMessageSpec<LibObjT>::packet(this->libObjPtr())}; |
508053d4 PP |
631 | } |
632 | ||
afe77d4f SM |
633 | OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept |
634 | { | |
635 | return bt_message_packet_end_borrow_stream_class_default_clock_class_const( | |
636 | this->libObjPtr()); | |
637 | } | |
638 | ||
2a24eba8 | 639 | CommonPacketEndMessage defaultClockSnapshot(const std::uint64_t val) const noexcept |
508053d4 | 640 | { |
5c895f64 PP |
641 | static_assert(!std::is_const<LibObjT>::value, |
642 | "Not available with `bt2::ConstPacketEndMessage`."); | |
508053d4 | 643 | |
341a67c4 | 644 | bt_message_packet_end_set_default_clock_snapshot(this->libObjPtr(), val); |
2a24eba8 | 645 | return *this; |
508053d4 PP |
646 | } |
647 | ||
648 | ConstClockSnapshot defaultClockSnapshot() const noexcept | |
649 | { | |
650 | const auto libObjPtr = | |
341a67c4 | 651 | bt_message_packet_end_borrow_default_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
652 | |
653 | return ConstClockSnapshot {libObjPtr}; | |
654 | } | |
655 | ||
656 | Shared shared() const noexcept | |
657 | { | |
c9c0b6e2 | 658 | return Shared::createWithRef(*this); |
508053d4 PP |
659 | } |
660 | }; | |
661 | ||
662 | using PacketEndMessage = CommonPacketEndMessage<bt_message>; | |
663 | using ConstPacketEndMessage = CommonPacketEndMessage<const bt_message>; | |
664 | ||
665 | namespace internal { | |
666 | ||
4927bae7 PP |
667 | struct PacketEndMessageTypeDescr |
668 | { | |
669 | using Const = ConstPacketEndMessage; | |
670 | using NonConst = PacketEndMessage; | |
671 | }; | |
672 | ||
673 | template <> | |
674 | struct TypeDescr<PacketEndMessage> : public PacketEndMessageTypeDescr | |
675 | { | |
676 | }; | |
677 | ||
678 | template <> | |
679 | struct TypeDescr<ConstPacketEndMessage> : public PacketEndMessageTypeDescr | |
680 | { | |
681 | }; | |
682 | ||
508053d4 PP |
683 | template <typename LibObjT> |
684 | struct CommonEventMessageSpec; | |
685 | ||
b5f55e9f | 686 | /* Functions specific to mutable event messages */ |
508053d4 PP |
687 | template <> |
688 | struct CommonEventMessageSpec<bt_message> final | |
689 | { | |
690 | static bt_event *event(bt_message * const libObjPtr) noexcept | |
691 | { | |
692 | return bt_message_event_borrow_event(libObjPtr); | |
693 | } | |
694 | }; | |
695 | ||
b5f55e9f | 696 | /* Functions specific to constant event messages */ |
508053d4 PP |
697 | template <> |
698 | struct CommonEventMessageSpec<const bt_message> final | |
699 | { | |
700 | static const bt_event *event(const bt_message * const libObjPtr) noexcept | |
701 | { | |
702 | return bt_message_event_borrow_event_const(libObjPtr); | |
703 | } | |
704 | }; | |
705 | ||
b5f55e9f | 706 | } /* namespace internal */ |
508053d4 PP |
707 | |
708 | template <typename LibObjT> | |
709 | class CommonEventMessage final : public CommonMessage<LibObjT> | |
710 | { | |
711 | private: | |
508053d4 | 712 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 713 | using _Event = internal::DepType<LibObjT, CommonEvent<bt_event>, CommonEvent<const bt_event>>; |
508053d4 PP |
714 | |
715 | public: | |
d246c457 | 716 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 717 | using Shared = SharedMessage<CommonEventMessage<LibObjT>, LibObjT>; |
508053d4 | 718 | |
d246c457 | 719 | explicit CommonEventMessage(const LibObjPtr libObjPtr) noexcept : _ThisCommonMessage {libObjPtr} |
508053d4 PP |
720 | { |
721 | BT_ASSERT_DBG(this->isEvent()); | |
722 | } | |
723 | ||
724 | template <typename OtherLibObjT> | |
100fa861 | 725 | CommonEventMessage(const CommonEventMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
726 | _ThisCommonMessage {val} |
727 | { | |
728 | } | |
729 | ||
730 | template <typename OtherLibObjT> | |
ac30a470 | 731 | CommonEventMessage<LibObjT> operator=(const CommonEventMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
732 | { |
733 | _ThisCommonMessage::operator=(val); | |
734 | return *this; | |
735 | } | |
736 | ||
328a274a PP |
737 | CommonEventMessage<const bt_message> asConst() const noexcept |
738 | { | |
739 | return CommonEventMessage<const bt_message> {*this}; | |
740 | } | |
741 | ||
dcb8ae9b | 742 | _Event event() const noexcept |
508053d4 | 743 | { |
341a67c4 | 744 | return _Event {internal::CommonEventMessageSpec<LibObjT>::event(this->libObjPtr())}; |
508053d4 PP |
745 | } |
746 | ||
ca61ecbc | 747 | OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept |
84cef782 | 748 | { |
ca61ecbc | 749 | return bt_message_event_borrow_stream_class_default_clock_class_const(this->libObjPtr()); |
84cef782 PP |
750 | } |
751 | ||
508053d4 PP |
752 | ConstClockSnapshot defaultClockSnapshot() const noexcept |
753 | { | |
754 | const auto libObjPtr = | |
341a67c4 | 755 | bt_message_event_borrow_default_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
756 | |
757 | return ConstClockSnapshot {libObjPtr}; | |
758 | } | |
759 | ||
760 | Shared shared() const noexcept | |
761 | { | |
c9c0b6e2 | 762 | return Shared::createWithRef(*this); |
508053d4 PP |
763 | } |
764 | }; | |
765 | ||
766 | using EventMessage = CommonEventMessage<bt_message>; | |
767 | using ConstEventMessage = CommonEventMessage<const bt_message>; | |
768 | ||
769 | namespace internal { | |
770 | ||
4927bae7 PP |
771 | struct EventMessageTypeDescr |
772 | { | |
773 | using Const = ConstEventMessage; | |
774 | using NonConst = EventMessage; | |
775 | }; | |
776 | ||
777 | template <> | |
778 | struct TypeDescr<EventMessage> : public EventMessageTypeDescr | |
779 | { | |
780 | }; | |
781 | ||
782 | template <> | |
783 | struct TypeDescr<ConstEventMessage> : public EventMessageTypeDescr | |
784 | { | |
785 | }; | |
786 | ||
508053d4 PP |
787 | template <typename LibObjT> |
788 | struct CommonDiscardedEventsMessageSpec; | |
789 | ||
b5f55e9f | 790 | /* Functions specific to mutable discarded events messages */ |
508053d4 PP |
791 | template <> |
792 | struct CommonDiscardedEventsMessageSpec<bt_message> final | |
793 | { | |
794 | static bt_stream *stream(bt_message * const libObjPtr) noexcept | |
795 | { | |
796 | return bt_message_discarded_events_borrow_stream(libObjPtr); | |
797 | } | |
798 | }; | |
799 | ||
b5f55e9f | 800 | /* Functions specific to constant discarded events messages */ |
508053d4 PP |
801 | template <> |
802 | struct CommonDiscardedEventsMessageSpec<const bt_message> final | |
803 | { | |
804 | static const bt_stream *stream(const bt_message * const libObjPtr) noexcept | |
805 | { | |
806 | return bt_message_discarded_events_borrow_stream_const(libObjPtr); | |
807 | } | |
808 | }; | |
809 | ||
b5f55e9f | 810 | } /* namespace internal */ |
508053d4 PP |
811 | |
812 | template <typename LibObjT> | |
813 | class CommonDiscardedEventsMessage final : public CommonMessage<LibObjT> | |
814 | { | |
815 | private: | |
508053d4 | 816 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 817 | using _Stream = internal::DepStream<LibObjT>; |
508053d4 PP |
818 | |
819 | public: | |
d246c457 | 820 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 821 | using Shared = SharedMessage<CommonDiscardedEventsMessage<LibObjT>, LibObjT>; |
508053d4 | 822 | |
d246c457 | 823 | explicit CommonDiscardedEventsMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
824 | _ThisCommonMessage {libObjPtr} |
825 | { | |
826 | BT_ASSERT_DBG(this->isDiscardedEvents()); | |
827 | } | |
828 | ||
829 | template <typename OtherLibObjT> | |
100fa861 | 830 | CommonDiscardedEventsMessage(const CommonDiscardedEventsMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
831 | _ThisCommonMessage {val} |
832 | { | |
833 | } | |
834 | ||
835 | template <typename OtherLibObjT> | |
ac30a470 | 836 | CommonDiscardedEventsMessage<LibObjT> |
100fa861 | 837 | operator=(const CommonDiscardedEventsMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
838 | { |
839 | _ThisCommonMessage::operator=(val); | |
840 | return *this; | |
841 | } | |
842 | ||
328a274a PP |
843 | CommonDiscardedEventsMessage<const bt_message> asConst() const noexcept |
844 | { | |
845 | return CommonDiscardedEventsMessage<const bt_message> {*this}; | |
846 | } | |
847 | ||
dcb8ae9b | 848 | _Stream stream() const noexcept |
508053d4 PP |
849 | { |
850 | return _Stream { | |
341a67c4 | 851 | internal::CommonDiscardedEventsMessageSpec<LibObjT>::stream(this->libObjPtr())}; |
508053d4 PP |
852 | } |
853 | ||
afe77d4f SM |
854 | OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept |
855 | { | |
856 | return bt_message_discarded_events_borrow_stream_class_default_clock_class_const( | |
857 | this->libObjPtr()); | |
858 | } | |
859 | ||
508053d4 PP |
860 | ConstClockSnapshot beginningDefaultClockSnapshot() const noexcept |
861 | { | |
862 | const auto libObjPtr = | |
863 | bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const( | |
341a67c4 | 864 | this->libObjPtr()); |
508053d4 PP |
865 | |
866 | return ConstClockSnapshot {libObjPtr}; | |
867 | } | |
868 | ||
869 | ConstClockSnapshot endDefaultClockSnapshot() const noexcept | |
870 | { | |
871 | const auto libObjPtr = | |
341a67c4 | 872 | bt_message_discarded_events_borrow_end_default_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
873 | |
874 | return ConstClockSnapshot {libObjPtr}; | |
875 | } | |
876 | ||
2a24eba8 | 877 | CommonDiscardedEventsMessage count(const std::uint64_t count) const noexcept |
508053d4 | 878 | { |
5c895f64 PP |
879 | static_assert(!std::is_const<LibObjT>::value, |
880 | "Not available with `bt2::ConstDiscardedEventsMessage`."); | |
508053d4 | 881 | |
341a67c4 | 882 | bt_message_discarded_events_set_count(this->libObjPtr(), count); |
2a24eba8 | 883 | return *this; |
508053d4 PP |
884 | } |
885 | ||
c022776a | 886 | bt2s::optional<std::uint64_t> count() const noexcept |
508053d4 PP |
887 | { |
888 | std::uint64_t count; | |
508053d4 | 889 | |
b3a12e59 | 890 | if (bt_message_discarded_events_get_count(this->libObjPtr(), &count)) { |
508053d4 PP |
891 | return count; |
892 | } | |
893 | ||
c022776a | 894 | return bt2s::nullopt; |
508053d4 PP |
895 | } |
896 | ||
897 | Shared shared() const noexcept | |
898 | { | |
c9c0b6e2 | 899 | return Shared::createWithRef(*this); |
508053d4 PP |
900 | } |
901 | }; | |
902 | ||
903 | using DiscardedEventsMessage = CommonDiscardedEventsMessage<bt_message>; | |
904 | using ConstDiscardedEventsMessage = CommonDiscardedEventsMessage<const bt_message>; | |
905 | ||
906 | namespace internal { | |
907 | ||
4927bae7 PP |
908 | struct DiscardedEventsMessageTypeDescr |
909 | { | |
910 | using Const = ConstDiscardedEventsMessage; | |
911 | using NonConst = DiscardedEventsMessage; | |
912 | }; | |
913 | ||
914 | template <> | |
915 | struct TypeDescr<DiscardedEventsMessage> : public DiscardedEventsMessageTypeDescr | |
916 | { | |
917 | }; | |
918 | ||
919 | template <> | |
920 | struct TypeDescr<ConstDiscardedEventsMessage> : public DiscardedEventsMessageTypeDescr | |
921 | { | |
922 | }; | |
923 | ||
508053d4 PP |
924 | template <typename LibObjT> |
925 | struct CommonDiscardedPacketsMessageSpec; | |
926 | ||
b5f55e9f | 927 | /* Functions specific to mutable discarded packets messages */ |
508053d4 PP |
928 | template <> |
929 | struct CommonDiscardedPacketsMessageSpec<bt_message> final | |
930 | { | |
931 | static bt_stream *stream(bt_message * const libObjPtr) noexcept | |
932 | { | |
933 | return bt_message_discarded_packets_borrow_stream(libObjPtr); | |
934 | } | |
935 | }; | |
936 | ||
b5f55e9f | 937 | /* Functions specific to constant discarded packets messages */ |
508053d4 PP |
938 | template <> |
939 | struct CommonDiscardedPacketsMessageSpec<const bt_message> final | |
940 | { | |
941 | static const bt_stream *stream(const bt_message * const libObjPtr) noexcept | |
942 | { | |
943 | return bt_message_discarded_packets_borrow_stream_const(libObjPtr); | |
944 | } | |
945 | }; | |
946 | ||
b5f55e9f | 947 | } /* namespace internal */ |
508053d4 PP |
948 | |
949 | template <typename LibObjT> | |
950 | class CommonDiscardedPacketsMessage final : public CommonMessage<LibObjT> | |
951 | { | |
952 | private: | |
508053d4 | 953 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 954 | using _Stream = internal::DepStream<LibObjT>; |
508053d4 PP |
955 | |
956 | public: | |
d246c457 | 957 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 958 | using Shared = SharedMessage<CommonDiscardedPacketsMessage<LibObjT>, LibObjT>; |
508053d4 | 959 | |
d246c457 | 960 | explicit CommonDiscardedPacketsMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
961 | _ThisCommonMessage {libObjPtr} |
962 | { | |
963 | BT_ASSERT_DBG(this->isDiscardedPackets()); | |
964 | } | |
965 | ||
966 | template <typename OtherLibObjT> | |
100fa861 | 967 | CommonDiscardedPacketsMessage(const CommonDiscardedPacketsMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
968 | _ThisCommonMessage {val} |
969 | { | |
970 | } | |
971 | ||
972 | template <typename OtherLibObjT> | |
ac30a470 | 973 | CommonDiscardedPacketsMessage<LibObjT> |
100fa861 | 974 | operator=(const CommonDiscardedPacketsMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
975 | { |
976 | _ThisCommonMessage::operator=(val); | |
977 | return *this; | |
978 | } | |
979 | ||
328a274a PP |
980 | CommonDiscardedPacketsMessage<const bt_message> asConst() const noexcept |
981 | { | |
982 | return CommonDiscardedPacketsMessage<const bt_message> {*this}; | |
983 | } | |
984 | ||
dcb8ae9b | 985 | _Stream stream() const noexcept |
508053d4 PP |
986 | { |
987 | return _Stream { | |
341a67c4 | 988 | internal::CommonDiscardedPacketsMessageSpec<LibObjT>::stream(this->libObjPtr())}; |
508053d4 PP |
989 | } |
990 | ||
afe77d4f SM |
991 | OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept |
992 | { | |
993 | return bt_message_discarded_packets_borrow_stream_class_default_clock_class_const( | |
994 | this->libObjPtr()); | |
995 | } | |
996 | ||
508053d4 PP |
997 | ConstClockSnapshot beginningDefaultClockSnapshot() const noexcept |
998 | { | |
999 | const auto libObjPtr = | |
1000 | bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const( | |
341a67c4 | 1001 | this->libObjPtr()); |
508053d4 PP |
1002 | |
1003 | return ConstClockSnapshot {libObjPtr}; | |
1004 | } | |
1005 | ||
1006 | ConstClockSnapshot endDefaultClockSnapshot() const noexcept | |
1007 | { | |
341a67c4 FD |
1008 | const auto libObjPtr = |
1009 | bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(this->libObjPtr()); | |
508053d4 PP |
1010 | |
1011 | return ConstClockSnapshot {libObjPtr}; | |
1012 | } | |
1013 | ||
2a24eba8 | 1014 | CommonDiscardedPacketsMessage count(const std::uint64_t count) const noexcept |
508053d4 | 1015 | { |
5c895f64 PP |
1016 | static_assert(!std::is_const<LibObjT>::value, |
1017 | "Not available with `bt2::ConstDiscardedPacketsMessage`."); | |
508053d4 | 1018 | |
341a67c4 | 1019 | bt_message_discarded_packets_set_count(this->libObjPtr(), count); |
2a24eba8 | 1020 | return *this; |
508053d4 PP |
1021 | } |
1022 | ||
c022776a | 1023 | bt2s::optional<std::uint64_t> count() const noexcept |
508053d4 PP |
1024 | { |
1025 | std::uint64_t count; | |
508053d4 | 1026 | |
b3a12e59 | 1027 | if (bt_message_discarded_packets_get_count(this->libObjPtr(), &count)) { |
508053d4 PP |
1028 | return count; |
1029 | } | |
1030 | ||
c022776a | 1031 | return bt2s::nullopt; |
508053d4 PP |
1032 | } |
1033 | ||
1034 | Shared shared() const noexcept | |
1035 | { | |
c9c0b6e2 | 1036 | return Shared::createWithRef(*this); |
508053d4 PP |
1037 | } |
1038 | }; | |
1039 | ||
1040 | using DiscardedPacketsMessage = CommonDiscardedPacketsMessage<bt_message>; | |
1041 | using ConstDiscardedPacketsMessage = CommonDiscardedPacketsMessage<const bt_message>; | |
1042 | ||
4927bae7 PP |
1043 | namespace internal { |
1044 | ||
1045 | struct DiscardedPacketsMessageTypeDescr | |
1046 | { | |
1047 | using Const = ConstDiscardedPacketsMessage; | |
1048 | using NonConst = DiscardedPacketsMessage; | |
1049 | }; | |
1050 | ||
1051 | template <> | |
1052 | struct TypeDescr<DiscardedPacketsMessage> : public DiscardedPacketsMessageTypeDescr | |
1053 | { | |
1054 | }; | |
1055 | ||
1056 | template <> | |
1057 | struct TypeDescr<ConstDiscardedPacketsMessage> : public DiscardedPacketsMessageTypeDescr | |
1058 | { | |
1059 | }; | |
1060 | ||
1061 | } /* namespace internal */ | |
1062 | ||
508053d4 PP |
1063 | template <typename LibObjT> |
1064 | class CommonMessageIteratorInactivityMessage final : public CommonMessage<LibObjT> | |
1065 | { | |
1066 | private: | |
508053d4 PP |
1067 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
1068 | ||
1069 | public: | |
d246c457 | 1070 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 1071 | using Shared = SharedMessage<CommonMessageIteratorInactivityMessage<LibObjT>, LibObjT>; |
508053d4 | 1072 | |
d246c457 | 1073 | explicit CommonMessageIteratorInactivityMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
1074 | _ThisCommonMessage {libObjPtr} |
1075 | { | |
1076 | BT_ASSERT_DBG(this->isMessageIteratorInactivity()); | |
1077 | } | |
1078 | ||
1079 | template <typename OtherLibObjT> | |
1080 | CommonMessageIteratorInactivityMessage( | |
100fa861 | 1081 | const CommonMessageIteratorInactivityMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
1082 | _ThisCommonMessage {val} |
1083 | { | |
1084 | } | |
1085 | ||
1086 | template <typename OtherLibObjT> | |
ac30a470 | 1087 | CommonMessageIteratorInactivityMessage<LibObjT> |
100fa861 | 1088 | operator=(const CommonMessageIteratorInactivityMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
1089 | { |
1090 | _ThisCommonMessage::operator=(val); | |
1091 | return *this; | |
1092 | } | |
1093 | ||
328a274a PP |
1094 | CommonMessageIteratorInactivityMessage<const bt_message> asConst() const noexcept |
1095 | { | |
1096 | return CommonMessageIteratorInactivityMessage<const bt_message> {*this}; | |
1097 | } | |
1098 | ||
508053d4 PP |
1099 | ConstClockSnapshot clockSnapshot() const noexcept |
1100 | { | |
1101 | const auto libObjPtr = | |
341a67c4 | 1102 | bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
1103 | |
1104 | return ConstClockSnapshot {libObjPtr}; | |
1105 | } | |
1106 | ||
1107 | Shared shared() const noexcept | |
1108 | { | |
c9c0b6e2 | 1109 | return Shared::createWithRef(*this); |
508053d4 PP |
1110 | } |
1111 | }; | |
1112 | ||
1113 | using MessageIteratorInactivityMessage = CommonMessageIteratorInactivityMessage<bt_message>; | |
1114 | using ConstMessageIteratorInactivityMessage = | |
1115 | CommonMessageIteratorInactivityMessage<const bt_message>; | |
1116 | ||
4927bae7 PP |
1117 | namespace internal { |
1118 | ||
1119 | struct MessageIteratorInactivityMessageTypeDescr | |
1120 | { | |
1121 | using Const = ConstMessageIteratorInactivityMessage; | |
1122 | using NonConst = MessageIteratorInactivityMessage; | |
1123 | }; | |
1124 | ||
1125 | template <> | |
1126 | struct TypeDescr<MessageIteratorInactivityMessage> : | |
1127 | public MessageIteratorInactivityMessageTypeDescr | |
1128 | { | |
1129 | }; | |
1130 | ||
1131 | template <> | |
1132 | struct TypeDescr<ConstMessageIteratorInactivityMessage> : | |
1133 | public MessageIteratorInactivityMessageTypeDescr | |
1134 | { | |
1135 | }; | |
1136 | ||
1137 | } /* namespace internal */ | |
1138 | ||
508053d4 PP |
1139 | template <typename LibObjT> |
1140 | CommonStreamBeginningMessage<LibObjT> CommonMessage<LibObjT>::asStreamBeginning() const noexcept | |
1141 | { | |
341a67c4 | 1142 | return CommonStreamBeginningMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1143 | } |
1144 | ||
1145 | template <typename LibObjT> | |
1146 | CommonStreamEndMessage<LibObjT> CommonMessage<LibObjT>::asStreamEnd() const noexcept | |
1147 | { | |
341a67c4 | 1148 | return CommonStreamEndMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1149 | } |
1150 | ||
1151 | template <typename LibObjT> | |
1152 | CommonPacketBeginningMessage<LibObjT> CommonMessage<LibObjT>::asPacketBeginning() const noexcept | |
1153 | { | |
341a67c4 | 1154 | return CommonPacketBeginningMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1155 | } |
1156 | ||
1157 | template <typename LibObjT> | |
1158 | CommonPacketEndMessage<LibObjT> CommonMessage<LibObjT>::asPacketEnd() const noexcept | |
1159 | { | |
341a67c4 | 1160 | return CommonPacketEndMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1161 | } |
1162 | ||
1163 | template <typename LibObjT> | |
1164 | CommonEventMessage<LibObjT> CommonMessage<LibObjT>::asEvent() const noexcept | |
1165 | { | |
341a67c4 | 1166 | return CommonEventMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1167 | } |
1168 | ||
1169 | template <typename LibObjT> | |
1170 | CommonDiscardedEventsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedEvents() const noexcept | |
1171 | { | |
341a67c4 | 1172 | return CommonDiscardedEventsMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1173 | } |
1174 | ||
bd7dbf87 FD |
1175 | template <typename LibObjT> |
1176 | CommonDiscardedPacketsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedPackets() const noexcept | |
1177 | { | |
bd7dbf87 FD |
1178 | return CommonDiscardedPacketsMessage<LibObjT> {this->libObjPtr()}; |
1179 | } | |
1180 | ||
508053d4 PP |
1181 | template <typename LibObjT> |
1182 | CommonMessageIteratorInactivityMessage<LibObjT> | |
1183 | CommonMessage<LibObjT>::asMessageIteratorInactivity() const noexcept | |
1184 | { | |
341a67c4 | 1185 | return CommonMessageIteratorInactivityMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1186 | } |
1187 | ||
b5f55e9f | 1188 | } /* namespace bt2 */ |
508053d4 | 1189 | |
b5f55e9f | 1190 | #endif /* BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP */ |