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