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