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