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