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 | { | |
73 | STREAM_BEGINNING = BT_MESSAGE_TYPE_STREAM_BEGINNING, | |
74 | STREAM_END = BT_MESSAGE_TYPE_STREAM_END, | |
75 | EVENT = BT_MESSAGE_TYPE_EVENT, | |
76 | PACKET_BEGINNING = BT_MESSAGE_TYPE_PACKET_BEGINNING, | |
77 | PACKET_END = BT_MESSAGE_TYPE_PACKET_END, | |
78 | DISCARDED_EVENTS = BT_MESSAGE_TYPE_DISCARDED_EVENTS, | |
79 | DISCARDED_PACKETS = BT_MESSAGE_TYPE_DISCARDED_PACKETS, | |
80 | MESSAGE_ITERATOR_INACTIVITY = BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY, | |
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 | { | |
124 | return this->type() == MessageType::STREAM_BEGINNING; | |
125 | } | |
126 | ||
127 | bool isStreamEnd() const noexcept | |
128 | { | |
129 | return this->type() == MessageType::STREAM_END; | |
130 | } | |
131 | ||
132 | bool isEvent() const noexcept | |
133 | { | |
134 | return this->type() == MessageType::EVENT; | |
135 | } | |
136 | ||
137 | bool isPacketBeginning() const noexcept | |
138 | { | |
139 | return this->type() == MessageType::PACKET_BEGINNING; | |
140 | } | |
141 | ||
142 | bool isPacketEnd() const noexcept | |
143 | { | |
144 | return this->type() == MessageType::PACKET_END; | |
145 | } | |
146 | ||
147 | bool isDiscardedEvents() const noexcept | |
148 | { | |
149 | return this->type() == MessageType::DISCARDED_EVENTS; | |
150 | } | |
151 | ||
152 | bool isDiscardedPackets() const noexcept | |
153 | { | |
154 | return this->type() == MessageType::DISCARDED_PACKETS; | |
155 | } | |
156 | ||
157 | bool isMessageIteratorInactivity() const noexcept | |
158 | { | |
159 | return this->type() == MessageType::MESSAGE_ITERATOR_INACTIVITY; | |
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 | ||
2a24eba8 | 271 | CommonStreamBeginningMessage defaultClockSnapshot(const std::uint64_t val) const noexcept |
508053d4 | 272 | { |
5c895f64 PP |
273 | static_assert(!std::is_const<LibObjT>::value, |
274 | "Not available with `bt2::ConstStreamBeginningMessage`."); | |
508053d4 | 275 | |
341a67c4 | 276 | bt_message_stream_beginning_set_default_clock_snapshot(this->libObjPtr(), val); |
2a24eba8 | 277 | return *this; |
508053d4 PP |
278 | } |
279 | ||
ca61ecbc | 280 | OptionalBorrowedObject<ConstClockSnapshot> defaultClockSnapshot() const noexcept |
508053d4 PP |
281 | { |
282 | const bt_clock_snapshot *libObjPtr; | |
283 | const auto state = bt_message_stream_beginning_borrow_default_clock_snapshot_const( | |
341a67c4 | 284 | this->libObjPtr(), &libObjPtr); |
508053d4 PP |
285 | |
286 | if (state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) { | |
ca61ecbc | 287 | return libObjPtr; |
508053d4 PP |
288 | } |
289 | ||
ca61ecbc | 290 | return {}; |
508053d4 PP |
291 | } |
292 | ||
293 | Shared shared() const noexcept | |
294 | { | |
c9c0b6e2 | 295 | return Shared::createWithRef(*this); |
508053d4 PP |
296 | } |
297 | }; | |
298 | ||
299 | using StreamBeginningMessage = CommonStreamBeginningMessage<bt_message>; | |
300 | using ConstStreamBeginningMessage = CommonStreamBeginningMessage<const bt_message>; | |
301 | ||
302 | namespace internal { | |
303 | ||
4927bae7 PP |
304 | struct StreamBeginningMessageTypeDescr |
305 | { | |
306 | using Const = ConstStreamBeginningMessage; | |
307 | using NonConst = StreamBeginningMessage; | |
308 | }; | |
309 | ||
310 | template <> | |
311 | struct TypeDescr<StreamBeginningMessage> : public StreamBeginningMessageTypeDescr | |
312 | { | |
313 | }; | |
314 | ||
315 | template <> | |
316 | struct TypeDescr<ConstStreamBeginningMessage> : public StreamBeginningMessageTypeDescr | |
317 | { | |
318 | }; | |
319 | ||
508053d4 PP |
320 | template <typename LibObjT> |
321 | struct CommonStreamEndMessageSpec; | |
322 | ||
b5f55e9f | 323 | /* Functions specific to mutable stream end messages */ |
508053d4 PP |
324 | template <> |
325 | struct CommonStreamEndMessageSpec<bt_message> final | |
326 | { | |
327 | static bt_stream *stream(bt_message * const libObjPtr) noexcept | |
328 | { | |
329 | return bt_message_stream_end_borrow_stream(libObjPtr); | |
330 | } | |
331 | }; | |
332 | ||
b5f55e9f | 333 | /* Functions specific to constant stream end messages */ |
508053d4 PP |
334 | template <> |
335 | struct CommonStreamEndMessageSpec<const bt_message> final | |
336 | { | |
337 | static const bt_stream *stream(const bt_message * const libObjPtr) noexcept | |
338 | { | |
339 | return bt_message_stream_end_borrow_stream_const(libObjPtr); | |
340 | } | |
341 | }; | |
342 | ||
b5f55e9f | 343 | } /* namespace internal */ |
508053d4 PP |
344 | |
345 | template <typename LibObjT> | |
346 | class CommonStreamEndMessage final : public CommonMessage<LibObjT> | |
347 | { | |
348 | private: | |
508053d4 | 349 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 350 | using _Stream = internal::DepStream<LibObjT>; |
508053d4 PP |
351 | |
352 | public: | |
d246c457 | 353 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 354 | using Shared = SharedMessage<CommonStreamEndMessage<LibObjT>, LibObjT>; |
508053d4 | 355 | |
d246c457 | 356 | explicit CommonStreamEndMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
357 | _ThisCommonMessage {libObjPtr} |
358 | { | |
359 | BT_ASSERT_DBG(this->isStreamEnd()); | |
360 | } | |
361 | ||
362 | template <typename OtherLibObjT> | |
100fa861 | 363 | CommonStreamEndMessage(const CommonStreamEndMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
364 | _ThisCommonMessage {val} |
365 | { | |
366 | } | |
367 | ||
368 | template <typename OtherLibObjT> | |
ac30a470 | 369 | CommonStreamEndMessage<LibObjT> |
100fa861 | 370 | operator=(const CommonStreamEndMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
371 | { |
372 | _ThisCommonMessage::operator=(val); | |
373 | return *this; | |
374 | } | |
375 | ||
328a274a PP |
376 | CommonStreamEndMessage<const bt_message> asConst() const noexcept |
377 | { | |
378 | return CommonStreamEndMessage<const bt_message> {*this}; | |
379 | } | |
380 | ||
dcb8ae9b | 381 | _Stream stream() const noexcept |
508053d4 | 382 | { |
341a67c4 | 383 | return _Stream {internal::CommonStreamEndMessageSpec<LibObjT>::stream(this->libObjPtr())}; |
508053d4 PP |
384 | } |
385 | ||
2a24eba8 | 386 | CommonStreamEndMessage defaultClockSnapshot(const std::uint64_t val) const noexcept |
508053d4 | 387 | { |
5c895f64 PP |
388 | static_assert(!std::is_const<LibObjT>::value, |
389 | "Not available with `bt2::ConstStreamEndMessage`."); | |
508053d4 | 390 | |
341a67c4 | 391 | bt_message_stream_end_set_default_clock_snapshot(this->libObjPtr(), val); |
2a24eba8 | 392 | return *this; |
508053d4 PP |
393 | } |
394 | ||
ca61ecbc | 395 | OptionalBorrowedObject<ConstClockSnapshot> defaultClockSnapshot() const noexcept |
508053d4 PP |
396 | { |
397 | const bt_clock_snapshot *libObjPtr; | |
398 | const auto state = bt_message_stream_end_borrow_default_clock_snapshot_const( | |
341a67c4 | 399 | this->libObjPtr(), &libObjPtr); |
508053d4 PP |
400 | |
401 | if (state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) { | |
ca61ecbc | 402 | return libObjPtr; |
508053d4 PP |
403 | } |
404 | ||
ca61ecbc | 405 | return {}; |
508053d4 PP |
406 | } |
407 | ||
408 | Shared shared() const noexcept | |
409 | { | |
c9c0b6e2 | 410 | return Shared::createWithRef(*this); |
508053d4 PP |
411 | } |
412 | }; | |
413 | ||
414 | using StreamEndMessage = CommonStreamEndMessage<bt_message>; | |
415 | using ConstStreamEndMessage = CommonStreamEndMessage<const bt_message>; | |
416 | ||
417 | namespace internal { | |
418 | ||
4927bae7 PP |
419 | struct StreamEndMessageTypeDescr |
420 | { | |
421 | using Const = ConstStreamEndMessage; | |
422 | using NonConst = StreamEndMessage; | |
423 | }; | |
424 | ||
425 | template <> | |
426 | struct TypeDescr<StreamEndMessage> : public StreamEndMessageTypeDescr | |
427 | { | |
428 | }; | |
429 | ||
430 | template <> | |
431 | struct TypeDescr<ConstStreamEndMessage> : public StreamEndMessageTypeDescr | |
432 | { | |
433 | }; | |
434 | ||
508053d4 PP |
435 | template <typename LibObjT> |
436 | struct CommonPacketBeginningMessageSpec; | |
437 | ||
b5f55e9f | 438 | /* Functions specific to mutable packet beginning messages */ |
508053d4 PP |
439 | template <> |
440 | struct CommonPacketBeginningMessageSpec<bt_message> final | |
441 | { | |
442 | static bt_packet *packet(bt_message * const libObjPtr) noexcept | |
443 | { | |
444 | return bt_message_packet_beginning_borrow_packet(libObjPtr); | |
445 | } | |
446 | }; | |
447 | ||
b5f55e9f | 448 | /* Functions specific to constant packet beginning messages */ |
508053d4 PP |
449 | template <> |
450 | struct CommonPacketBeginningMessageSpec<const bt_message> final | |
451 | { | |
452 | static const bt_packet *packet(const bt_message * const libObjPtr) noexcept | |
453 | { | |
454 | return bt_message_packet_beginning_borrow_packet_const(libObjPtr); | |
455 | } | |
456 | }; | |
457 | ||
b5f55e9f | 458 | } /* namespace internal */ |
508053d4 PP |
459 | |
460 | template <typename LibObjT> | |
461 | class CommonPacketBeginningMessage final : public CommonMessage<LibObjT> | |
462 | { | |
463 | private: | |
508053d4 | 464 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 465 | using _Packet = internal::DepPacket<LibObjT>; |
508053d4 PP |
466 | |
467 | public: | |
d246c457 | 468 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 469 | using Shared = SharedMessage<CommonPacketBeginningMessage<LibObjT>, LibObjT>; |
508053d4 | 470 | |
d246c457 | 471 | explicit CommonPacketBeginningMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
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> | |
ac30a470 | 484 | CommonPacketBeginningMessage<LibObjT> |
100fa861 | 485 | operator=(const CommonPacketBeginningMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
486 | { |
487 | _ThisCommonMessage::operator=(val); | |
488 | return *this; | |
489 | } | |
490 | ||
328a274a PP |
491 | CommonPacketBeginningMessage<const bt_message> asConst() const noexcept |
492 | { | |
493 | return CommonPacketBeginningMessage<const bt_message> {*this}; | |
494 | } | |
495 | ||
dcb8ae9b | 496 | _Packet packet() const noexcept |
508053d4 PP |
497 | { |
498 | return _Packet { | |
341a67c4 | 499 | internal::CommonPacketBeginningMessageSpec<LibObjT>::packet(this->libObjPtr())}; |
508053d4 PP |
500 | } |
501 | ||
2a24eba8 | 502 | CommonPacketBeginningMessage defaultClockSnapshot(const std::uint64_t val) const noexcept |
508053d4 | 503 | { |
5c895f64 PP |
504 | static_assert(!std::is_const<LibObjT>::value, |
505 | "Not available with `bt2::ConstPacketBeginningMessage`."); | |
508053d4 | 506 | |
341a67c4 | 507 | bt_message_packet_beginning_set_default_clock_snapshot(this->libObjPtr(), val); |
2a24eba8 | 508 | return *this; |
508053d4 PP |
509 | } |
510 | ||
511 | ConstClockSnapshot defaultClockSnapshot() const noexcept | |
512 | { | |
513 | const auto libObjPtr = | |
341a67c4 | 514 | bt_message_packet_beginning_borrow_default_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
515 | |
516 | return ConstClockSnapshot {libObjPtr}; | |
517 | } | |
518 | ||
519 | Shared shared() const noexcept | |
520 | { | |
c9c0b6e2 | 521 | return Shared::createWithRef(*this); |
508053d4 PP |
522 | } |
523 | }; | |
524 | ||
525 | using PacketBeginningMessage = CommonPacketBeginningMessage<bt_message>; | |
526 | using ConstPacketBeginningMessage = CommonPacketBeginningMessage<const bt_message>; | |
527 | ||
528 | namespace internal { | |
529 | ||
4927bae7 PP |
530 | struct PacketBeginningMessageTypeDescr |
531 | { | |
532 | using Const = ConstPacketBeginningMessage; | |
533 | using NonConst = PacketBeginningMessage; | |
534 | }; | |
535 | ||
536 | template <> | |
537 | struct TypeDescr<PacketBeginningMessage> : public PacketBeginningMessageTypeDescr | |
538 | { | |
539 | }; | |
540 | ||
541 | template <> | |
542 | struct TypeDescr<ConstPacketBeginningMessage> : public PacketBeginningMessageTypeDescr | |
543 | { | |
544 | }; | |
545 | ||
508053d4 PP |
546 | template <typename LibObjT> |
547 | struct CommonPacketEndMessageSpec; | |
548 | ||
b5f55e9f | 549 | /* Functions specific to mutable packet end messages */ |
508053d4 PP |
550 | template <> |
551 | struct CommonPacketEndMessageSpec<bt_message> final | |
552 | { | |
553 | static bt_packet *packet(bt_message * const libObjPtr) noexcept | |
554 | { | |
555 | return bt_message_packet_end_borrow_packet(libObjPtr); | |
556 | } | |
557 | }; | |
558 | ||
b5f55e9f | 559 | /* Functions specific to constant packet end messages */ |
508053d4 PP |
560 | template <> |
561 | struct CommonPacketEndMessageSpec<const bt_message> final | |
562 | { | |
563 | static const bt_packet *packet(const bt_message * const libObjPtr) noexcept | |
564 | { | |
565 | return bt_message_packet_end_borrow_packet_const(libObjPtr); | |
566 | } | |
567 | }; | |
568 | ||
b5f55e9f | 569 | } /* namespace internal */ |
508053d4 PP |
570 | |
571 | template <typename LibObjT> | |
572 | class CommonPacketEndMessage final : public CommonMessage<LibObjT> | |
573 | { | |
574 | private: | |
508053d4 | 575 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 576 | using _Packet = internal::DepPacket<LibObjT>; |
508053d4 PP |
577 | |
578 | public: | |
d246c457 | 579 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 580 | using Shared = SharedMessage<CommonPacketEndMessage<LibObjT>, LibObjT>; |
508053d4 | 581 | |
d246c457 | 582 | explicit CommonPacketEndMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
583 | _ThisCommonMessage {libObjPtr} |
584 | { | |
585 | BT_ASSERT_DBG(this->isPacketEnd()); | |
586 | } | |
587 | ||
588 | template <typename OtherLibObjT> | |
100fa861 | 589 | CommonPacketEndMessage(const CommonPacketEndMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
590 | _ThisCommonMessage {val} |
591 | { | |
592 | } | |
593 | ||
594 | template <typename OtherLibObjT> | |
ac30a470 | 595 | CommonPacketEndMessage<LibObjT> |
100fa861 | 596 | operator=(const CommonPacketEndMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
597 | { |
598 | _ThisCommonMessage::operator=(val); | |
599 | return *this; | |
600 | } | |
601 | ||
328a274a PP |
602 | CommonPacketEndMessage<const bt_message> asConst() const noexcept |
603 | { | |
604 | return CommonPacketEndMessage<const bt_message> {*this}; | |
605 | } | |
606 | ||
dcb8ae9b | 607 | _Packet packet() const noexcept |
508053d4 | 608 | { |
341a67c4 | 609 | return _Packet {internal::CommonPacketEndMessageSpec<LibObjT>::packet(this->libObjPtr())}; |
508053d4 PP |
610 | } |
611 | ||
2a24eba8 | 612 | CommonPacketEndMessage defaultClockSnapshot(const std::uint64_t val) const noexcept |
508053d4 | 613 | { |
5c895f64 PP |
614 | static_assert(!std::is_const<LibObjT>::value, |
615 | "Not available with `bt2::ConstPacketEndMessage`."); | |
508053d4 | 616 | |
341a67c4 | 617 | bt_message_packet_end_set_default_clock_snapshot(this->libObjPtr(), val); |
2a24eba8 | 618 | return *this; |
508053d4 PP |
619 | } |
620 | ||
621 | ConstClockSnapshot defaultClockSnapshot() const noexcept | |
622 | { | |
623 | const auto libObjPtr = | |
341a67c4 | 624 | bt_message_packet_end_borrow_default_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
625 | |
626 | return ConstClockSnapshot {libObjPtr}; | |
627 | } | |
628 | ||
629 | Shared shared() const noexcept | |
630 | { | |
c9c0b6e2 | 631 | return Shared::createWithRef(*this); |
508053d4 PP |
632 | } |
633 | }; | |
634 | ||
635 | using PacketEndMessage = CommonPacketEndMessage<bt_message>; | |
636 | using ConstPacketEndMessage = CommonPacketEndMessage<const bt_message>; | |
637 | ||
638 | namespace internal { | |
639 | ||
4927bae7 PP |
640 | struct PacketEndMessageTypeDescr |
641 | { | |
642 | using Const = ConstPacketEndMessage; | |
643 | using NonConst = PacketEndMessage; | |
644 | }; | |
645 | ||
646 | template <> | |
647 | struct TypeDescr<PacketEndMessage> : public PacketEndMessageTypeDescr | |
648 | { | |
649 | }; | |
650 | ||
651 | template <> | |
652 | struct TypeDescr<ConstPacketEndMessage> : public PacketEndMessageTypeDescr | |
653 | { | |
654 | }; | |
655 | ||
508053d4 PP |
656 | template <typename LibObjT> |
657 | struct CommonEventMessageSpec; | |
658 | ||
b5f55e9f | 659 | /* Functions specific to mutable event messages */ |
508053d4 PP |
660 | template <> |
661 | struct CommonEventMessageSpec<bt_message> final | |
662 | { | |
663 | static bt_event *event(bt_message * const libObjPtr) noexcept | |
664 | { | |
665 | return bt_message_event_borrow_event(libObjPtr); | |
666 | } | |
667 | }; | |
668 | ||
b5f55e9f | 669 | /* Functions specific to constant event messages */ |
508053d4 PP |
670 | template <> |
671 | struct CommonEventMessageSpec<const bt_message> final | |
672 | { | |
673 | static const bt_event *event(const bt_message * const libObjPtr) noexcept | |
674 | { | |
675 | return bt_message_event_borrow_event_const(libObjPtr); | |
676 | } | |
677 | }; | |
678 | ||
b5f55e9f | 679 | } /* namespace internal */ |
508053d4 PP |
680 | |
681 | template <typename LibObjT> | |
682 | class CommonEventMessage final : public CommonMessage<LibObjT> | |
683 | { | |
684 | private: | |
508053d4 | 685 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 686 | using _Event = internal::DepType<LibObjT, CommonEvent<bt_event>, CommonEvent<const bt_event>>; |
508053d4 PP |
687 | |
688 | public: | |
d246c457 | 689 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 690 | using Shared = SharedMessage<CommonEventMessage<LibObjT>, LibObjT>; |
508053d4 | 691 | |
d246c457 | 692 | explicit CommonEventMessage(const LibObjPtr libObjPtr) noexcept : _ThisCommonMessage {libObjPtr} |
508053d4 PP |
693 | { |
694 | BT_ASSERT_DBG(this->isEvent()); | |
695 | } | |
696 | ||
697 | template <typename OtherLibObjT> | |
100fa861 | 698 | CommonEventMessage(const CommonEventMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
699 | _ThisCommonMessage {val} |
700 | { | |
701 | } | |
702 | ||
703 | template <typename OtherLibObjT> | |
ac30a470 | 704 | CommonEventMessage<LibObjT> operator=(const CommonEventMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
705 | { |
706 | _ThisCommonMessage::operator=(val); | |
707 | return *this; | |
708 | } | |
709 | ||
328a274a PP |
710 | CommonEventMessage<const bt_message> asConst() const noexcept |
711 | { | |
712 | return CommonEventMessage<const bt_message> {*this}; | |
713 | } | |
714 | ||
dcb8ae9b | 715 | _Event event() const noexcept |
508053d4 | 716 | { |
341a67c4 | 717 | return _Event {internal::CommonEventMessageSpec<LibObjT>::event(this->libObjPtr())}; |
508053d4 PP |
718 | } |
719 | ||
ca61ecbc | 720 | OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept |
84cef782 | 721 | { |
ca61ecbc | 722 | return bt_message_event_borrow_stream_class_default_clock_class_const(this->libObjPtr()); |
84cef782 PP |
723 | } |
724 | ||
508053d4 PP |
725 | ConstClockSnapshot defaultClockSnapshot() const noexcept |
726 | { | |
727 | const auto libObjPtr = | |
341a67c4 | 728 | bt_message_event_borrow_default_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
729 | |
730 | return ConstClockSnapshot {libObjPtr}; | |
731 | } | |
732 | ||
733 | Shared shared() const noexcept | |
734 | { | |
c9c0b6e2 | 735 | return Shared::createWithRef(*this); |
508053d4 PP |
736 | } |
737 | }; | |
738 | ||
739 | using EventMessage = CommonEventMessage<bt_message>; | |
740 | using ConstEventMessage = CommonEventMessage<const bt_message>; | |
741 | ||
742 | namespace internal { | |
743 | ||
4927bae7 PP |
744 | struct EventMessageTypeDescr |
745 | { | |
746 | using Const = ConstEventMessage; | |
747 | using NonConst = EventMessage; | |
748 | }; | |
749 | ||
750 | template <> | |
751 | struct TypeDescr<EventMessage> : public EventMessageTypeDescr | |
752 | { | |
753 | }; | |
754 | ||
755 | template <> | |
756 | struct TypeDescr<ConstEventMessage> : public EventMessageTypeDescr | |
757 | { | |
758 | }; | |
759 | ||
508053d4 PP |
760 | template <typename LibObjT> |
761 | struct CommonDiscardedEventsMessageSpec; | |
762 | ||
b5f55e9f | 763 | /* Functions specific to mutable discarded events messages */ |
508053d4 PP |
764 | template <> |
765 | struct CommonDiscardedEventsMessageSpec<bt_message> final | |
766 | { | |
767 | static bt_stream *stream(bt_message * const libObjPtr) noexcept | |
768 | { | |
769 | return bt_message_discarded_events_borrow_stream(libObjPtr); | |
770 | } | |
771 | }; | |
772 | ||
b5f55e9f | 773 | /* Functions specific to constant discarded events messages */ |
508053d4 PP |
774 | template <> |
775 | struct CommonDiscardedEventsMessageSpec<const bt_message> final | |
776 | { | |
777 | static const bt_stream *stream(const bt_message * const libObjPtr) noexcept | |
778 | { | |
779 | return bt_message_discarded_events_borrow_stream_const(libObjPtr); | |
780 | } | |
781 | }; | |
782 | ||
b5f55e9f | 783 | } /* namespace internal */ |
508053d4 PP |
784 | |
785 | template <typename LibObjT> | |
786 | class CommonDiscardedEventsMessage final : public CommonMessage<LibObjT> | |
787 | { | |
788 | private: | |
508053d4 | 789 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 790 | using _Stream = internal::DepStream<LibObjT>; |
508053d4 PP |
791 | |
792 | public: | |
d246c457 | 793 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 794 | using Shared = SharedMessage<CommonDiscardedEventsMessage<LibObjT>, LibObjT>; |
508053d4 | 795 | |
d246c457 | 796 | explicit CommonDiscardedEventsMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
797 | _ThisCommonMessage {libObjPtr} |
798 | { | |
799 | BT_ASSERT_DBG(this->isDiscardedEvents()); | |
800 | } | |
801 | ||
802 | template <typename OtherLibObjT> | |
100fa861 | 803 | CommonDiscardedEventsMessage(const CommonDiscardedEventsMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
804 | _ThisCommonMessage {val} |
805 | { | |
806 | } | |
807 | ||
808 | template <typename OtherLibObjT> | |
ac30a470 | 809 | CommonDiscardedEventsMessage<LibObjT> |
100fa861 | 810 | operator=(const CommonDiscardedEventsMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
811 | { |
812 | _ThisCommonMessage::operator=(val); | |
813 | return *this; | |
814 | } | |
815 | ||
328a274a PP |
816 | CommonDiscardedEventsMessage<const bt_message> asConst() const noexcept |
817 | { | |
818 | return CommonDiscardedEventsMessage<const bt_message> {*this}; | |
819 | } | |
820 | ||
dcb8ae9b | 821 | _Stream stream() const noexcept |
508053d4 PP |
822 | { |
823 | return _Stream { | |
341a67c4 | 824 | internal::CommonDiscardedEventsMessageSpec<LibObjT>::stream(this->libObjPtr())}; |
508053d4 PP |
825 | } |
826 | ||
827 | ConstClockSnapshot beginningDefaultClockSnapshot() const noexcept | |
828 | { | |
829 | const auto libObjPtr = | |
830 | bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const( | |
341a67c4 | 831 | this->libObjPtr()); |
508053d4 PP |
832 | |
833 | return ConstClockSnapshot {libObjPtr}; | |
834 | } | |
835 | ||
836 | ConstClockSnapshot endDefaultClockSnapshot() const noexcept | |
837 | { | |
838 | const auto libObjPtr = | |
341a67c4 | 839 | bt_message_discarded_events_borrow_end_default_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
840 | |
841 | return ConstClockSnapshot {libObjPtr}; | |
842 | } | |
843 | ||
2a24eba8 | 844 | CommonDiscardedEventsMessage count(const std::uint64_t count) const noexcept |
508053d4 | 845 | { |
5c895f64 PP |
846 | static_assert(!std::is_const<LibObjT>::value, |
847 | "Not available with `bt2::ConstDiscardedEventsMessage`."); | |
508053d4 | 848 | |
341a67c4 | 849 | bt_message_discarded_events_set_count(this->libObjPtr(), count); |
2a24eba8 | 850 | return *this; |
508053d4 PP |
851 | } |
852 | ||
c022776a | 853 | bt2s::optional<std::uint64_t> count() const noexcept |
508053d4 PP |
854 | { |
855 | std::uint64_t count; | |
508053d4 | 856 | |
b3a12e59 | 857 | if (bt_message_discarded_events_get_count(this->libObjPtr(), &count)) { |
508053d4 PP |
858 | return count; |
859 | } | |
860 | ||
c022776a | 861 | return bt2s::nullopt; |
508053d4 PP |
862 | } |
863 | ||
864 | Shared shared() const noexcept | |
865 | { | |
c9c0b6e2 | 866 | return Shared::createWithRef(*this); |
508053d4 PP |
867 | } |
868 | }; | |
869 | ||
870 | using DiscardedEventsMessage = CommonDiscardedEventsMessage<bt_message>; | |
871 | using ConstDiscardedEventsMessage = CommonDiscardedEventsMessage<const bt_message>; | |
872 | ||
873 | namespace internal { | |
874 | ||
4927bae7 PP |
875 | struct DiscardedEventsMessageTypeDescr |
876 | { | |
877 | using Const = ConstDiscardedEventsMessage; | |
878 | using NonConst = DiscardedEventsMessage; | |
879 | }; | |
880 | ||
881 | template <> | |
882 | struct TypeDescr<DiscardedEventsMessage> : public DiscardedEventsMessageTypeDescr | |
883 | { | |
884 | }; | |
885 | ||
886 | template <> | |
887 | struct TypeDescr<ConstDiscardedEventsMessage> : public DiscardedEventsMessageTypeDescr | |
888 | { | |
889 | }; | |
890 | ||
508053d4 PP |
891 | template <typename LibObjT> |
892 | struct CommonDiscardedPacketsMessageSpec; | |
893 | ||
b5f55e9f | 894 | /* Functions specific to mutable discarded packets messages */ |
508053d4 PP |
895 | template <> |
896 | struct CommonDiscardedPacketsMessageSpec<bt_message> final | |
897 | { | |
898 | static bt_stream *stream(bt_message * const libObjPtr) noexcept | |
899 | { | |
900 | return bt_message_discarded_packets_borrow_stream(libObjPtr); | |
901 | } | |
902 | }; | |
903 | ||
b5f55e9f | 904 | /* Functions specific to constant discarded packets messages */ |
508053d4 PP |
905 | template <> |
906 | struct CommonDiscardedPacketsMessageSpec<const bt_message> final | |
907 | { | |
908 | static const bt_stream *stream(const bt_message * const libObjPtr) noexcept | |
909 | { | |
910 | return bt_message_discarded_packets_borrow_stream_const(libObjPtr); | |
911 | } | |
912 | }; | |
913 | ||
b5f55e9f | 914 | } /* namespace internal */ |
508053d4 PP |
915 | |
916 | template <typename LibObjT> | |
917 | class CommonDiscardedPacketsMessage final : public CommonMessage<LibObjT> | |
918 | { | |
919 | private: | |
508053d4 | 920 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
8047a175 | 921 | using _Stream = internal::DepStream<LibObjT>; |
508053d4 PP |
922 | |
923 | public: | |
d246c457 | 924 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 925 | using Shared = SharedMessage<CommonDiscardedPacketsMessage<LibObjT>, LibObjT>; |
508053d4 | 926 | |
d246c457 | 927 | explicit CommonDiscardedPacketsMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
928 | _ThisCommonMessage {libObjPtr} |
929 | { | |
930 | BT_ASSERT_DBG(this->isDiscardedPackets()); | |
931 | } | |
932 | ||
933 | template <typename OtherLibObjT> | |
100fa861 | 934 | CommonDiscardedPacketsMessage(const CommonDiscardedPacketsMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
935 | _ThisCommonMessage {val} |
936 | { | |
937 | } | |
938 | ||
939 | template <typename OtherLibObjT> | |
ac30a470 | 940 | CommonDiscardedPacketsMessage<LibObjT> |
100fa861 | 941 | operator=(const CommonDiscardedPacketsMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
942 | { |
943 | _ThisCommonMessage::operator=(val); | |
944 | return *this; | |
945 | } | |
946 | ||
328a274a PP |
947 | CommonDiscardedPacketsMessage<const bt_message> asConst() const noexcept |
948 | { | |
949 | return CommonDiscardedPacketsMessage<const bt_message> {*this}; | |
950 | } | |
951 | ||
dcb8ae9b | 952 | _Stream stream() const noexcept |
508053d4 PP |
953 | { |
954 | return _Stream { | |
341a67c4 | 955 | internal::CommonDiscardedPacketsMessageSpec<LibObjT>::stream(this->libObjPtr())}; |
508053d4 PP |
956 | } |
957 | ||
958 | ConstClockSnapshot beginningDefaultClockSnapshot() const noexcept | |
959 | { | |
960 | const auto libObjPtr = | |
961 | bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const( | |
341a67c4 | 962 | this->libObjPtr()); |
508053d4 PP |
963 | |
964 | return ConstClockSnapshot {libObjPtr}; | |
965 | } | |
966 | ||
967 | ConstClockSnapshot endDefaultClockSnapshot() const noexcept | |
968 | { | |
341a67c4 FD |
969 | const auto libObjPtr = |
970 | bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(this->libObjPtr()); | |
508053d4 PP |
971 | |
972 | return ConstClockSnapshot {libObjPtr}; | |
973 | } | |
974 | ||
2a24eba8 | 975 | CommonDiscardedPacketsMessage count(const std::uint64_t count) const noexcept |
508053d4 | 976 | { |
5c895f64 PP |
977 | static_assert(!std::is_const<LibObjT>::value, |
978 | "Not available with `bt2::ConstDiscardedPacketsMessage`."); | |
508053d4 | 979 | |
341a67c4 | 980 | bt_message_discarded_packets_set_count(this->libObjPtr(), count); |
2a24eba8 | 981 | return *this; |
508053d4 PP |
982 | } |
983 | ||
c022776a | 984 | bt2s::optional<std::uint64_t> count() const noexcept |
508053d4 PP |
985 | { |
986 | std::uint64_t count; | |
508053d4 | 987 | |
b3a12e59 | 988 | if (bt_message_discarded_packets_get_count(this->libObjPtr(), &count)) { |
508053d4 PP |
989 | return count; |
990 | } | |
991 | ||
c022776a | 992 | return bt2s::nullopt; |
508053d4 PP |
993 | } |
994 | ||
995 | Shared shared() const noexcept | |
996 | { | |
c9c0b6e2 | 997 | return Shared::createWithRef(*this); |
508053d4 PP |
998 | } |
999 | }; | |
1000 | ||
1001 | using DiscardedPacketsMessage = CommonDiscardedPacketsMessage<bt_message>; | |
1002 | using ConstDiscardedPacketsMessage = CommonDiscardedPacketsMessage<const bt_message>; | |
1003 | ||
4927bae7 PP |
1004 | namespace internal { |
1005 | ||
1006 | struct DiscardedPacketsMessageTypeDescr | |
1007 | { | |
1008 | using Const = ConstDiscardedPacketsMessage; | |
1009 | using NonConst = DiscardedPacketsMessage; | |
1010 | }; | |
1011 | ||
1012 | template <> | |
1013 | struct TypeDescr<DiscardedPacketsMessage> : public DiscardedPacketsMessageTypeDescr | |
1014 | { | |
1015 | }; | |
1016 | ||
1017 | template <> | |
1018 | struct TypeDescr<ConstDiscardedPacketsMessage> : public DiscardedPacketsMessageTypeDescr | |
1019 | { | |
1020 | }; | |
1021 | ||
1022 | } /* namespace internal */ | |
1023 | ||
508053d4 PP |
1024 | template <typename LibObjT> |
1025 | class CommonMessageIteratorInactivityMessage final : public CommonMessage<LibObjT> | |
1026 | { | |
1027 | private: | |
508053d4 PP |
1028 | using typename CommonMessage<LibObjT>::_ThisCommonMessage; |
1029 | ||
1030 | public: | |
d246c457 | 1031 | using typename CommonMessage<LibObjT>::LibObjPtr; |
26b9d24c | 1032 | using Shared = SharedMessage<CommonMessageIteratorInactivityMessage<LibObjT>, LibObjT>; |
508053d4 | 1033 | |
d246c457 | 1034 | explicit CommonMessageIteratorInactivityMessage(const LibObjPtr libObjPtr) noexcept : |
508053d4 PP |
1035 | _ThisCommonMessage {libObjPtr} |
1036 | { | |
1037 | BT_ASSERT_DBG(this->isMessageIteratorInactivity()); | |
1038 | } | |
1039 | ||
1040 | template <typename OtherLibObjT> | |
1041 | CommonMessageIteratorInactivityMessage( | |
100fa861 | 1042 | const CommonMessageIteratorInactivityMessage<OtherLibObjT> val) noexcept : |
508053d4 PP |
1043 | _ThisCommonMessage {val} |
1044 | { | |
1045 | } | |
1046 | ||
1047 | template <typename OtherLibObjT> | |
ac30a470 | 1048 | CommonMessageIteratorInactivityMessage<LibObjT> |
100fa861 | 1049 | operator=(const CommonMessageIteratorInactivityMessage<OtherLibObjT> val) noexcept |
508053d4 PP |
1050 | { |
1051 | _ThisCommonMessage::operator=(val); | |
1052 | return *this; | |
1053 | } | |
1054 | ||
328a274a PP |
1055 | CommonMessageIteratorInactivityMessage<const bt_message> asConst() const noexcept |
1056 | { | |
1057 | return CommonMessageIteratorInactivityMessage<const bt_message> {*this}; | |
1058 | } | |
1059 | ||
508053d4 PP |
1060 | ConstClockSnapshot clockSnapshot() const noexcept |
1061 | { | |
1062 | const auto libObjPtr = | |
341a67c4 | 1063 | bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(this->libObjPtr()); |
508053d4 PP |
1064 | |
1065 | return ConstClockSnapshot {libObjPtr}; | |
1066 | } | |
1067 | ||
1068 | Shared shared() const noexcept | |
1069 | { | |
c9c0b6e2 | 1070 | return Shared::createWithRef(*this); |
508053d4 PP |
1071 | } |
1072 | }; | |
1073 | ||
1074 | using MessageIteratorInactivityMessage = CommonMessageIteratorInactivityMessage<bt_message>; | |
1075 | using ConstMessageIteratorInactivityMessage = | |
1076 | CommonMessageIteratorInactivityMessage<const bt_message>; | |
1077 | ||
4927bae7 PP |
1078 | namespace internal { |
1079 | ||
1080 | struct MessageIteratorInactivityMessageTypeDescr | |
1081 | { | |
1082 | using Const = ConstMessageIteratorInactivityMessage; | |
1083 | using NonConst = MessageIteratorInactivityMessage; | |
1084 | }; | |
1085 | ||
1086 | template <> | |
1087 | struct TypeDescr<MessageIteratorInactivityMessage> : | |
1088 | public MessageIteratorInactivityMessageTypeDescr | |
1089 | { | |
1090 | }; | |
1091 | ||
1092 | template <> | |
1093 | struct TypeDescr<ConstMessageIteratorInactivityMessage> : | |
1094 | public MessageIteratorInactivityMessageTypeDescr | |
1095 | { | |
1096 | }; | |
1097 | ||
1098 | } /* namespace internal */ | |
1099 | ||
508053d4 PP |
1100 | template <typename LibObjT> |
1101 | CommonStreamBeginningMessage<LibObjT> CommonMessage<LibObjT>::asStreamBeginning() const noexcept | |
1102 | { | |
341a67c4 | 1103 | return CommonStreamBeginningMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1104 | } |
1105 | ||
1106 | template <typename LibObjT> | |
1107 | CommonStreamEndMessage<LibObjT> CommonMessage<LibObjT>::asStreamEnd() const noexcept | |
1108 | { | |
341a67c4 | 1109 | return CommonStreamEndMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1110 | } |
1111 | ||
1112 | template <typename LibObjT> | |
1113 | CommonPacketBeginningMessage<LibObjT> CommonMessage<LibObjT>::asPacketBeginning() const noexcept | |
1114 | { | |
341a67c4 | 1115 | return CommonPacketBeginningMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1116 | } |
1117 | ||
1118 | template <typename LibObjT> | |
1119 | CommonPacketEndMessage<LibObjT> CommonMessage<LibObjT>::asPacketEnd() const noexcept | |
1120 | { | |
341a67c4 | 1121 | return CommonPacketEndMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1122 | } |
1123 | ||
1124 | template <typename LibObjT> | |
1125 | CommonEventMessage<LibObjT> CommonMessage<LibObjT>::asEvent() const noexcept | |
1126 | { | |
341a67c4 | 1127 | return CommonEventMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1128 | } |
1129 | ||
1130 | template <typename LibObjT> | |
1131 | CommonDiscardedEventsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedEvents() const noexcept | |
1132 | { | |
341a67c4 | 1133 | return CommonDiscardedEventsMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1134 | } |
1135 | ||
bd7dbf87 FD |
1136 | template <typename LibObjT> |
1137 | CommonDiscardedPacketsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedPackets() const noexcept | |
1138 | { | |
bd7dbf87 FD |
1139 | return CommonDiscardedPacketsMessage<LibObjT> {this->libObjPtr()}; |
1140 | } | |
1141 | ||
508053d4 PP |
1142 | template <typename LibObjT> |
1143 | CommonMessageIteratorInactivityMessage<LibObjT> | |
1144 | CommonMessage<LibObjT>::asMessageIteratorInactivity() const noexcept | |
1145 | { | |
341a67c4 | 1146 | return CommonMessageIteratorInactivityMessage<LibObjT> {this->libObjPtr()}; |
508053d4 PP |
1147 | } |
1148 | ||
b5f55e9f | 1149 | } /* namespace bt2 */ |
508053d4 | 1150 | |
b5f55e9f | 1151 | #endif /* BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP */ |