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