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