X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcpp-common%2Fbt2%2Fmessage.hpp;h=1603a6dd7a8bb37aaac4fdf9de30513beff422ce;hb=c802cacb9f0879a42e01575595a75bbefe7d3db9;hp=65404f3c270ca5453a4d0cf9ee1805a435366e21;hpb=508053d4bbf1adfe3194c05192066f7947b55674;p=babeltrace.git diff --git a/src/cpp-common/bt2/message.hpp b/src/cpp-common/bt2/message.hpp index 65404f3c..1603a6dd 100644 --- a/src/cpp-common/bt2/message.hpp +++ b/src/cpp-common/bt2/message.hpp @@ -7,22 +7,24 @@ #ifndef BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP #define BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP -#include #include #include +#include + #include #include "common/assert.h" #include "common/common.h" +#include "cpp-common/bt2/trace-ir.hpp" +#include "cpp-common/optional.hpp" +#include "cpp-common/string_view.hpp" + +#include "exc.hpp" #include "internal/borrowed-obj.hpp" #include "internal/shared-obj.hpp" #include "internal/utils.hpp" -#include "cpp-common/optional.hpp" -#include "cpp-common/string_view.hpp" -#include "lib-error.hpp" namespace bt2 { - namespace internal { struct MessageRefFuncs final @@ -41,7 +43,7 @@ struct MessageRefFuncs final template using SharedMessage = internal::SharedObj; -} // namespace internal +} /* namespace internal */ template class CommonStreamBeginningMessage; @@ -97,12 +99,12 @@ public: } template - CommonMessage(const CommonMessage& val) noexcept : _ThisBorrowedObj {val} + CommonMessage(const CommonMessage val) noexcept : _ThisBorrowedObj {val} { } template - _ThisCommonMessage& operator=(const CommonMessage& val) noexcept + _ThisCommonMessage& operator=(const CommonMessage val) noexcept { _ThisBorrowedObj::operator=(val); return *this; @@ -110,7 +112,7 @@ public: MessageType type() const noexcept { - return static_cast(bt_message_get_type(this->_libObjPtr())); + return static_cast(bt_message_get_type(this->libObjPtr())); } bool isStreamBeginning() const noexcept @@ -155,7 +157,13 @@ public: Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); + } + + template + MessageT as() const noexcept + { + return MessageT {this->libObjPtr()}; } CommonStreamBeginningMessage asStreamBeginning() const noexcept; @@ -173,10 +181,26 @@ using ConstMessage = CommonMessage; namespace internal { +struct MessageTypeDescr +{ + using Const = ConstMessage; + using NonConst = Message; +}; + +template <> +struct TypeDescr : public MessageTypeDescr +{ +}; + +template <> +struct TypeDescr : public MessageTypeDescr +{ +}; + template struct CommonStreamBeginningMessageSpec; -// Functions specific to mutable stream beginning messages +/* Functions specific to mutable stream beginning messages */ template <> struct CommonStreamBeginningMessageSpec final { @@ -186,7 +210,7 @@ struct CommonStreamBeginningMessageSpec final } }; -// Functions specific to constant stream beginning messages +/* Functions specific to constant stream beginning messages */ template <> struct CommonStreamBeginningMessageSpec final { @@ -196,7 +220,7 @@ struct CommonStreamBeginningMessageSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonStreamBeginningMessage final : public CommonMessage @@ -219,14 +243,14 @@ public: } template - CommonStreamBeginningMessage(const CommonStreamBeginningMessage& val) noexcept : + CommonStreamBeginningMessage(const CommonStreamBeginningMessage val) noexcept : _ThisCommonMessage {val} { } template CommonStreamBeginningMessage& - operator=(const CommonStreamBeginningMessage& val) noexcept + operator=(const CommonStreamBeginningMessage val) noexcept { _ThisCommonMessage::operator=(val); return *this; @@ -235,27 +259,27 @@ public: ConstStream stream() const noexcept { return ConstStream {internal::CommonStreamBeginningMessageSpec::stream( - this->_libObjPtr())}; + this->libObjPtr())}; } _Stream stream() noexcept { return _Stream { - internal::CommonStreamBeginningMessageSpec::stream(this->_libObjPtr())}; + internal::CommonStreamBeginningMessageSpec::stream(this->libObjPtr())}; } void defaultClockSnapshot(const std::uint64_t val) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_message_stream_beginning_set_default_clock_snapshot(this->_libObjPtr(), val); + bt_message_stream_beginning_set_default_clock_snapshot(this->libObjPtr(), val); } nonstd::optional defaultClockSnapshot() const noexcept { const bt_clock_snapshot *libObjPtr; const auto state = bt_message_stream_beginning_borrow_default_clock_snapshot_const( - this->_libObjPtr(), &libObjPtr); + this->libObjPtr(), &libObjPtr); if (state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) { return ConstClockSnapshot {libObjPtr}; @@ -266,7 +290,7 @@ public: Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -275,10 +299,26 @@ using ConstStreamBeginningMessage = CommonStreamBeginningMessage +struct TypeDescr : public StreamBeginningMessageTypeDescr +{ +}; + +template <> +struct TypeDescr : public StreamBeginningMessageTypeDescr +{ +}; + template struct CommonStreamEndMessageSpec; -// Functions specific to mutable stream end messages +/* Functions specific to mutable stream end messages */ template <> struct CommonStreamEndMessageSpec final { @@ -288,7 +328,7 @@ struct CommonStreamEndMessageSpec final } }; -// Functions specific to constant stream end messages +/* Functions specific to constant stream end messages */ template <> struct CommonStreamEndMessageSpec final { @@ -298,7 +338,7 @@ struct CommonStreamEndMessageSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonStreamEndMessage final : public CommonMessage @@ -321,14 +361,14 @@ public: } template - CommonStreamEndMessage(const CommonStreamEndMessage& val) noexcept : + CommonStreamEndMessage(const CommonStreamEndMessage val) noexcept : _ThisCommonMessage {val} { } template CommonStreamEndMessage& - operator=(const CommonStreamEndMessage& val) noexcept + operator=(const CommonStreamEndMessage val) noexcept { _ThisCommonMessage::operator=(val); return *this; @@ -337,26 +377,26 @@ public: ConstStream stream() const noexcept { return ConstStream { - internal::CommonStreamEndMessageSpec::stream(this->_libObjPtr())}; + internal::CommonStreamEndMessageSpec::stream(this->libObjPtr())}; } _Stream stream() noexcept { - return _Stream {internal::CommonStreamEndMessageSpec::stream(this->_libObjPtr())}; + return _Stream {internal::CommonStreamEndMessageSpec::stream(this->libObjPtr())}; } void defaultClockSnapshot(const std::uint64_t val) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_message_stream_end_set_default_clock_snapshot(this->_libObjPtr(), val); + bt_message_stream_end_set_default_clock_snapshot(this->libObjPtr(), val); } nonstd::optional defaultClockSnapshot() const noexcept { const bt_clock_snapshot *libObjPtr; const auto state = bt_message_stream_end_borrow_default_clock_snapshot_const( - this->_libObjPtr(), &libObjPtr); + this->libObjPtr(), &libObjPtr); if (state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) { return ConstClockSnapshot {libObjPtr}; @@ -367,7 +407,7 @@ public: Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -376,10 +416,26 @@ using ConstStreamEndMessage = CommonStreamEndMessage; namespace internal { +struct StreamEndMessageTypeDescr +{ + using Const = ConstStreamEndMessage; + using NonConst = StreamEndMessage; +}; + +template <> +struct TypeDescr : public StreamEndMessageTypeDescr +{ +}; + +template <> +struct TypeDescr : public StreamEndMessageTypeDescr +{ +}; + template struct CommonPacketBeginningMessageSpec; -// Functions specific to mutable packet beginning messages +/* Functions specific to mutable packet beginning messages */ template <> struct CommonPacketBeginningMessageSpec final { @@ -389,7 +445,7 @@ struct CommonPacketBeginningMessageSpec final } }; -// Functions specific to constant packet beginning messages +/* Functions specific to constant packet beginning messages */ template <> struct CommonPacketBeginningMessageSpec final { @@ -399,7 +455,7 @@ struct CommonPacketBeginningMessageSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonPacketBeginningMessage final : public CommonMessage @@ -422,14 +478,14 @@ public: } template - CommonPacketBeginningMessage(const CommonPacketBeginningMessage& val) noexcept : + CommonPacketBeginningMessage(const CommonPacketBeginningMessage val) noexcept : _ThisCommonMessage {val} { } template CommonPacketBeginningMessage& - operator=(const CommonPacketBeginningMessage& val) noexcept + operator=(const CommonPacketBeginningMessage val) noexcept { _ThisCommonMessage::operator=(val); return *this; @@ -438,33 +494,33 @@ public: ConstPacket packet() const noexcept { return ConstPacket {internal::CommonPacketBeginningMessageSpec::packet( - this->_libObjPtr())}; + this->libObjPtr())}; } _Packet packet() noexcept { return _Packet { - internal::CommonPacketBeginningMessageSpec::packet(this->_libObjPtr())}; + internal::CommonPacketBeginningMessageSpec::packet(this->libObjPtr())}; } void defaultClockSnapshot(const std::uint64_t val) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_message_packet_beginning_set_default_clock_snapshot(this->_libObjPtr(), val); + bt_message_packet_beginning_set_default_clock_snapshot(this->libObjPtr(), val); } ConstClockSnapshot defaultClockSnapshot() const noexcept { const auto libObjPtr = - bt_message_packet_beginning_borrow_default_clock_snapshot_const(this->_libObjPtr()); + bt_message_packet_beginning_borrow_default_clock_snapshot_const(this->libObjPtr()); return ConstClockSnapshot {libObjPtr}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -473,10 +529,26 @@ using ConstPacketBeginningMessage = CommonPacketBeginningMessage +struct TypeDescr : public PacketBeginningMessageTypeDescr +{ +}; + +template <> +struct TypeDescr : public PacketBeginningMessageTypeDescr +{ +}; + template struct CommonPacketEndMessageSpec; -// Functions specific to mutable packet end messages +/* Functions specific to mutable packet end messages */ template <> struct CommonPacketEndMessageSpec final { @@ -486,7 +558,7 @@ struct CommonPacketEndMessageSpec final } }; -// Functions specific to constant packet end messages +/* Functions specific to constant packet end messages */ template <> struct CommonPacketEndMessageSpec final { @@ -496,7 +568,7 @@ struct CommonPacketEndMessageSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonPacketEndMessage final : public CommonMessage @@ -519,14 +591,14 @@ public: } template - CommonPacketEndMessage(const CommonPacketEndMessage& val) noexcept : + CommonPacketEndMessage(const CommonPacketEndMessage val) noexcept : _ThisCommonMessage {val} { } template CommonPacketEndMessage& - operator=(const CommonPacketEndMessage& val) noexcept + operator=(const CommonPacketEndMessage val) noexcept { _ThisCommonMessage::operator=(val); return *this; @@ -535,32 +607,32 @@ public: ConstPacket packet() const noexcept { return ConstPacket { - internal::CommonPacketEndMessageSpec::packet(this->_libObjPtr())}; + internal::CommonPacketEndMessageSpec::packet(this->libObjPtr())}; } _Packet packet() noexcept { - return _Packet {internal::CommonPacketEndMessageSpec::packet(this->_libObjPtr())}; + return _Packet {internal::CommonPacketEndMessageSpec::packet(this->libObjPtr())}; } void defaultClockSnapshot(const std::uint64_t val) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_message_packet_end_set_default_clock_snapshot(this->_libObjPtr(), val); + bt_message_packet_end_set_default_clock_snapshot(this->libObjPtr(), val); } ConstClockSnapshot defaultClockSnapshot() const noexcept { const auto libObjPtr = - bt_message_packet_end_borrow_default_clock_snapshot_const(this->_libObjPtr()); + bt_message_packet_end_borrow_default_clock_snapshot_const(this->libObjPtr()); return ConstClockSnapshot {libObjPtr}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -569,10 +641,26 @@ using ConstPacketEndMessage = CommonPacketEndMessage; namespace internal { +struct PacketEndMessageTypeDescr +{ + using Const = ConstPacketEndMessage; + using NonConst = PacketEndMessage; +}; + +template <> +struct TypeDescr : public PacketEndMessageTypeDescr +{ +}; + +template <> +struct TypeDescr : public PacketEndMessageTypeDescr +{ +}; + template struct CommonEventMessageSpec; -// Functions specific to mutable event messages +/* Functions specific to mutable event messages */ template <> struct CommonEventMessageSpec final { @@ -582,7 +670,7 @@ struct CommonEventMessageSpec final } }; -// Functions specific to constant event messages +/* Functions specific to constant event messages */ template <> struct CommonEventMessageSpec final { @@ -592,7 +680,7 @@ struct CommonEventMessageSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonEventMessage final : public CommonMessage @@ -615,13 +703,13 @@ public: } template - CommonEventMessage(const CommonEventMessage& val) noexcept : + CommonEventMessage(const CommonEventMessage val) noexcept : _ThisCommonMessage {val} { } template - CommonEventMessage& operator=(const CommonEventMessage& val) noexcept + CommonEventMessage& operator=(const CommonEventMessage val) noexcept { _ThisCommonMessage::operator=(val); return *this; @@ -630,25 +718,25 @@ public: ConstEvent event() const noexcept { return ConstEvent { - internal::CommonEventMessageSpec::event(this->_libObjPtr())}; + internal::CommonEventMessageSpec::event(this->libObjPtr())}; } _Event event() noexcept { - return _Event {internal::CommonEventMessageSpec::event(this->_libObjPtr())}; + return _Event {internal::CommonEventMessageSpec::event(this->libObjPtr())}; } ConstClockSnapshot defaultClockSnapshot() const noexcept { const auto libObjPtr = - bt_message_event_borrow_default_clock_snapshot_const(this->_libObjPtr()); + bt_message_event_borrow_default_clock_snapshot_const(this->libObjPtr()); return ConstClockSnapshot {libObjPtr}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -657,10 +745,26 @@ using ConstEventMessage = CommonEventMessage; namespace internal { +struct EventMessageTypeDescr +{ + using Const = ConstEventMessage; + using NonConst = EventMessage; +}; + +template <> +struct TypeDescr : public EventMessageTypeDescr +{ +}; + +template <> +struct TypeDescr : public EventMessageTypeDescr +{ +}; + template struct CommonDiscardedEventsMessageSpec; -// Functions specific to mutable discarded events messages +/* Functions specific to mutable discarded events messages */ template <> struct CommonDiscardedEventsMessageSpec final { @@ -670,7 +774,7 @@ struct CommonDiscardedEventsMessageSpec final } }; -// Functions specific to constant discarded events messages +/* Functions specific to constant discarded events messages */ template <> struct CommonDiscardedEventsMessageSpec final { @@ -680,7 +784,7 @@ struct CommonDiscardedEventsMessageSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonDiscardedEventsMessage final : public CommonMessage @@ -703,14 +807,14 @@ public: } template - CommonDiscardedEventsMessage(const CommonDiscardedEventsMessage& val) noexcept : + CommonDiscardedEventsMessage(const CommonDiscardedEventsMessage val) noexcept : _ThisCommonMessage {val} { } template CommonDiscardedEventsMessage& - operator=(const CommonDiscardedEventsMessage& val) noexcept + operator=(const CommonDiscardedEventsMessage val) noexcept { _ThisCommonMessage::operator=(val); return *this; @@ -719,20 +823,20 @@ public: ConstStream stream() const noexcept { return ConstStream {internal::CommonDiscardedEventsMessageSpec::stream( - this->_libObjPtr())}; + this->libObjPtr())}; } _Stream stream() noexcept { return _Stream { - internal::CommonDiscardedEventsMessageSpec::stream(this->_libObjPtr())}; + internal::CommonDiscardedEventsMessageSpec::stream(this->libObjPtr())}; } ConstClockSnapshot beginningDefaultClockSnapshot() const noexcept { const auto libObjPtr = bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const( - this->_libObjPtr()); + this->libObjPtr()); return ConstClockSnapshot {libObjPtr}; } @@ -740,7 +844,7 @@ public: ConstClockSnapshot endDefaultClockSnapshot() const noexcept { const auto libObjPtr = - bt_message_discarded_events_borrow_end_default_clock_snapshot_const(this->_libObjPtr()); + bt_message_discarded_events_borrow_end_default_clock_snapshot_const(this->libObjPtr()); return ConstClockSnapshot {libObjPtr}; } @@ -749,13 +853,13 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_message_discarded_events_set_count(this->_libObjPtr(), count); + bt_message_discarded_events_set_count(this->libObjPtr(), count); } nonstd::optional count() const noexcept { std::uint64_t count; - const auto avail = bt_message_discarded_events_get_count(this->_libObjPtr(), &count); + const auto avail = bt_message_discarded_events_get_count(this->libObjPtr(), &count); if (avail) { return count; @@ -766,7 +870,7 @@ public: Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -775,10 +879,26 @@ using ConstDiscardedEventsMessage = CommonDiscardedEventsMessage +struct TypeDescr : public DiscardedEventsMessageTypeDescr +{ +}; + +template <> +struct TypeDescr : public DiscardedEventsMessageTypeDescr +{ +}; + template struct CommonDiscardedPacketsMessageSpec; -// Functions specific to mutable discarded packets messages +/* Functions specific to mutable discarded packets messages */ template <> struct CommonDiscardedPacketsMessageSpec final { @@ -788,7 +908,7 @@ struct CommonDiscardedPacketsMessageSpec final } }; -// Functions specific to constant discarded packets messages +/* Functions specific to constant discarded packets messages */ template <> struct CommonDiscardedPacketsMessageSpec final { @@ -798,7 +918,7 @@ struct CommonDiscardedPacketsMessageSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonDiscardedPacketsMessage final : public CommonMessage @@ -821,14 +941,14 @@ public: } template - CommonDiscardedPacketsMessage(const CommonDiscardedPacketsMessage& val) noexcept : + CommonDiscardedPacketsMessage(const CommonDiscardedPacketsMessage val) noexcept : _ThisCommonMessage {val} { } template CommonDiscardedPacketsMessage& - operator=(const CommonDiscardedPacketsMessage& val) noexcept + operator=(const CommonDiscardedPacketsMessage val) noexcept { _ThisCommonMessage::operator=(val); return *this; @@ -837,28 +957,28 @@ public: ConstStream stream() const noexcept { return ConstStream {internal::CommonDiscardedPacketsMessageSpec::stream( - this->_libObjPtr())}; + this->libObjPtr())}; } _Stream stream() noexcept { return _Stream { - internal::CommonDiscardedPacketsMessageSpec::stream(this->_libObjPtr())}; + internal::CommonDiscardedPacketsMessageSpec::stream(this->libObjPtr())}; } ConstClockSnapshot beginningDefaultClockSnapshot() const noexcept { const auto libObjPtr = bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const( - this->_libObjPtr()); + this->libObjPtr()); return ConstClockSnapshot {libObjPtr}; } ConstClockSnapshot endDefaultClockSnapshot() const noexcept { - const auto libObjPtr = bt_message_discarded_packets_borrow_end_default_clock_snapshot_const( - this->_libObjPtr()); + const auto libObjPtr = + bt_message_discarded_packets_borrow_end_default_clock_snapshot_const(this->libObjPtr()); return ConstClockSnapshot {libObjPtr}; } @@ -867,13 +987,13 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_message_discarded_packets_set_count(this->_libObjPtr(), count); + bt_message_discarded_packets_set_count(this->libObjPtr(), count); } nonstd::optional count() const noexcept { std::uint64_t count; - const auto avail = bt_message_discarded_packets_get_count(this->_libObjPtr(), &count); + const auto avail = bt_message_discarded_packets_get_count(this->libObjPtr(), &count); if (avail) { return count; @@ -884,13 +1004,33 @@ public: Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using DiscardedPacketsMessage = CommonDiscardedPacketsMessage; using ConstDiscardedPacketsMessage = CommonDiscardedPacketsMessage; +namespace internal { + +struct DiscardedPacketsMessageTypeDescr +{ + using Const = ConstDiscardedPacketsMessage; + using NonConst = DiscardedPacketsMessage; +}; + +template <> +struct TypeDescr : public DiscardedPacketsMessageTypeDescr +{ +}; + +template <> +struct TypeDescr : public DiscardedPacketsMessageTypeDescr +{ +}; + +} /* namespace internal */ + template class CommonMessageIteratorInactivityMessage final : public CommonMessage { @@ -910,14 +1050,14 @@ public: template CommonMessageIteratorInactivityMessage( - const CommonMessageIteratorInactivityMessage& val) noexcept : + const CommonMessageIteratorInactivityMessage val) noexcept : _ThisCommonMessage {val} { } template CommonMessageIteratorInactivityMessage& - operator=(const CommonMessageIteratorInactivityMessage& val) noexcept + operator=(const CommonMessageIteratorInactivityMessage val) noexcept { _ThisCommonMessage::operator=(val); return *this; @@ -926,14 +1066,14 @@ public: ConstClockSnapshot clockSnapshot() const noexcept { const auto libObjPtr = - bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(this->_libObjPtr()); + bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(this->libObjPtr()); return ConstClockSnapshot {libObjPtr}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -941,46 +1081,75 @@ using MessageIteratorInactivityMessage = CommonMessageIteratorInactivityMessage< using ConstMessageIteratorInactivityMessage = CommonMessageIteratorInactivityMessage; +namespace internal { + +struct MessageIteratorInactivityMessageTypeDescr +{ + using Const = ConstMessageIteratorInactivityMessage; + using NonConst = MessageIteratorInactivityMessage; +}; + +template <> +struct TypeDescr : + public MessageIteratorInactivityMessageTypeDescr +{ +}; + +template <> +struct TypeDescr : + public MessageIteratorInactivityMessageTypeDescr +{ +}; + +} /* namespace internal */ + template CommonStreamBeginningMessage CommonMessage::asStreamBeginning() const noexcept { BT_ASSERT_DBG(this->isStreamBeginning()); - return CommonStreamBeginningMessage {this->_libObjPtr()}; + return CommonStreamBeginningMessage {this->libObjPtr()}; } template CommonStreamEndMessage CommonMessage::asStreamEnd() const noexcept { BT_ASSERT_DBG(this->isStreamEnd()); - return CommonStreamEndMessage {this->_libObjPtr()}; + return CommonStreamEndMessage {this->libObjPtr()}; } template CommonPacketBeginningMessage CommonMessage::asPacketBeginning() const noexcept { BT_ASSERT_DBG(this->isPacketBeginning()); - return CommonPacketBeginningMessage {this->_libObjPtr()}; + return CommonPacketBeginningMessage {this->libObjPtr()}; } template CommonPacketEndMessage CommonMessage::asPacketEnd() const noexcept { BT_ASSERT_DBG(this->isPacketEnd()); - return CommonPacketEndMessage {this->_libObjPtr()}; + return CommonPacketEndMessage {this->libObjPtr()}; } template CommonEventMessage CommonMessage::asEvent() const noexcept { BT_ASSERT_DBG(this->isEvent()); - return CommonEventMessage {this->_libObjPtr()}; + return CommonEventMessage {this->libObjPtr()}; } template CommonDiscardedEventsMessage CommonMessage::asDiscardedEvents() const noexcept { BT_ASSERT_DBG(this->isDiscardedEvents()); - return CommonDiscardedEventsMessage {this->_libObjPtr()}; + return CommonDiscardedEventsMessage {this->libObjPtr()}; +} + +template +CommonDiscardedPacketsMessage CommonMessage::asDiscardedPackets() const noexcept +{ + BT_ASSERT_DBG(this->isDiscardedPackets()); + return CommonDiscardedPacketsMessage {this->libObjPtr()}; } template @@ -988,9 +1157,9 @@ CommonMessageIteratorInactivityMessage CommonMessage::asMessageIteratorInactivity() const noexcept { BT_ASSERT_DBG(this->isMessageIteratorInactivity()); - return CommonMessageIteratorInactivityMessage {this->_libObjPtr()}; + return CommonMessageIteratorInactivityMessage {this->libObjPtr()}; } -} // namespace bt2 +} /* namespace bt2 */ -#endif // BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP +#endif /* BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP */