cpp-common/bt2: add missing `noexcept` to static methods
[babeltrace.git] / src / cpp-common / bt2 / message.hpp
index 65404f3c270ca5453a4d0cf9ee1805a435366e21..b74be2c50213c91ac2e55d4f2ebb1ab48b65a16b 100644 (file)
@@ -7,41 +7,40 @@
 #ifndef BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP
 #define BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP
 
-#include <type_traits>
 #include <cstdint>
-#include <functional>
+#include <type_traits>
+
 #include <babeltrace2/babeltrace.h>
 
 #include "common/assert.h"
-#include "common/common.h"
-#include "internal/borrowed-obj.hpp"
-#include "internal/shared-obj.hpp"
-#include "internal/utils.hpp"
+#include "cpp-common/bt2/clock-snapshot.hpp"
+#include "cpp-common/bt2/trace-ir.hpp"
 #include "cpp-common/optional.hpp"
-#include "cpp-common/string_view.hpp"
-#include "lib-error.hpp"
 
-namespace bt2 {
+#include "borrowed-object.hpp"
+#include "internal/utils.hpp"
+#include "shared-object.hpp"
 
+namespace bt2 {
 namespace internal {
 
 struct MessageRefFuncs final
 {
-    static void get(const bt_message * const libObjPtr)
+    static void get(const bt_message * const libObjPtr) noexcept
     {
         bt_message_get_ref(libObjPtr);
     }
 
-    static void put(const bt_message * const libObjPtr)
+    static void put(const bt_message * const libObjPtr) noexcept
     {
         bt_message_put_ref(libObjPtr);
     }
 };
 
-template <typename ObjT, typename LibObjT>
-using SharedMessage = internal::SharedObj<ObjT, LibObjT, internal::MessageRefFuncs>;
+} /* namespace internal */
 
-} // namespace internal
+template <typename ObjT, typename LibObjT>
+using SharedMessage = SharedObject<ObjT, LibObjT, internal::MessageRefFuncs>;
 
 template <typename LibObjT>
 class CommonStreamBeginningMessage;
@@ -80,37 +79,37 @@ enum class MessageType
 };
 
 template <typename LibObjT>
-class CommonMessage : public internal::BorrowedObj<LibObjT>
+class CommonMessage : public BorrowedObject<LibObjT>
 {
 private:
-    using typename internal::BorrowedObj<LibObjT>::_ThisBorrowedObj;
+    using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
 
 protected:
-    using typename internal::BorrowedObj<LibObjT>::_LibObjPtr;
+    using typename BorrowedObject<LibObjT>::_LibObjPtr;
     using _ThisCommonMessage = CommonMessage<LibObjT>;
 
 public:
-    using Shared = internal::SharedMessage<CommonMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonMessage<LibObjT>, LibObjT>;
 
-    explicit CommonMessage(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr}
+    explicit CommonMessage(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
     {
     }
 
     template <typename OtherLibObjT>
-    CommonMessage(const CommonMessage<OtherLibObjT>& val) noexcept : _ThisBorrowedObj {val}
+    CommonMessage(const CommonMessage<OtherLibObjT> val) noexcept : _ThisBorrowedObject {val}
     {
     }
 
     template <typename OtherLibObjT>
-    _ThisCommonMessage& operator=(const CommonMessage<OtherLibObjT>& val) noexcept
+    _ThisCommonMessage& operator=(const CommonMessage<OtherLibObjT> val) noexcept
     {
-        _ThisBorrowedObj::operator=(val);
+        _ThisBorrowedObject::operator=(val);
         return *this;
     }
 
     MessageType type() const noexcept
     {
-        return static_cast<MessageType>(bt_message_get_type(this->_libObjPtr()));
+        return static_cast<MessageType>(bt_message_get_type(this->libObjPtr()));
     }
 
     bool isStreamBeginning() const noexcept
@@ -155,7 +154,13 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
+    }
+
+    template <typename MessageT>
+    MessageT as() const noexcept
+    {
+        return MessageT {this->libObjPtr()};
     }
 
     CommonStreamBeginningMessage<LibObjT> asStreamBeginning() const noexcept;
@@ -173,10 +178,26 @@ using ConstMessage = CommonMessage<const bt_message>;
 
 namespace internal {
 
+struct MessageTypeDescr
+{
+    using Const = ConstMessage;
+    using NonConst = Message;
+};
+
+template <>
+struct TypeDescr<Message> : public MessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstMessage> : public MessageTypeDescr
+{
+};
+
 template <typename LibObjT>
 struct CommonStreamBeginningMessageSpec;
 
-// Functions specific to mutable stream beginning messages
+/* Functions specific to mutable stream beginning messages */
 template <>
 struct CommonStreamBeginningMessageSpec<bt_message> final
 {
@@ -186,7 +207,7 @@ struct CommonStreamBeginningMessageSpec<bt_message> final
     }
 };
 
-// Functions specific to constant stream beginning messages
+/* Functions specific to constant stream beginning messages */
 template <>
 struct CommonStreamBeginningMessageSpec<const bt_message> final
 {
@@ -196,7 +217,7 @@ struct CommonStreamBeginningMessageSpec<const bt_message> final
     }
 };
 
-} // namespace internal
+} /* namespace internal */
 
 template <typename LibObjT>
 class CommonStreamBeginningMessage final : public CommonMessage<LibObjT>
@@ -210,7 +231,7 @@ private:
                                   CommonStream<bt_stream>>::type;
 
 public:
-    using Shared = internal::SharedMessage<CommonStreamBeginningMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonStreamBeginningMessage<LibObjT>, LibObjT>;
 
     explicit CommonStreamBeginningMessage(const _LibObjPtr libObjPtr) noexcept :
         _ThisCommonMessage {libObjPtr}
@@ -219,14 +240,14 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonStreamBeginningMessage(const CommonStreamBeginningMessage<OtherLibObjT>& val) noexcept :
+    CommonStreamBeginningMessage(const CommonStreamBeginningMessage<OtherLibObjT> val) noexcept :
         _ThisCommonMessage {val}
     {
     }
 
     template <typename OtherLibObjT>
     CommonStreamBeginningMessage<LibObjT>&
-    operator=(const CommonStreamBeginningMessage<OtherLibObjT>& val) noexcept
+    operator=(const CommonStreamBeginningMessage<OtherLibObjT> val) noexcept
     {
         _ThisCommonMessage::operator=(val);
         return *this;
@@ -235,27 +256,27 @@ public:
     ConstStream stream() const noexcept
     {
         return ConstStream {internal::CommonStreamBeginningMessageSpec<const bt_message>::stream(
-            this->_libObjPtr())};
+            this->libObjPtr())};
     }
 
     _Stream stream() noexcept
     {
         return _Stream {
-            internal::CommonStreamBeginningMessageSpec<LibObjT>::stream(this->_libObjPtr())};
+            internal::CommonStreamBeginningMessageSpec<LibObjT>::stream(this->libObjPtr())};
     }
 
     void defaultClockSnapshot(const std::uint64_t val) noexcept
     {
         static_assert(!std::is_const<LibObjT>::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<ConstClockSnapshot> 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 +287,7 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
@@ -275,10 +296,26 @@ using ConstStreamBeginningMessage = CommonStreamBeginningMessage<const bt_messag
 
 namespace internal {
 
+struct StreamBeginningMessageTypeDescr
+{
+    using Const = ConstStreamBeginningMessage;
+    using NonConst = StreamBeginningMessage;
+};
+
+template <>
+struct TypeDescr<StreamBeginningMessage> : public StreamBeginningMessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstStreamBeginningMessage> : public StreamBeginningMessageTypeDescr
+{
+};
+
 template <typename LibObjT>
 struct CommonStreamEndMessageSpec;
 
-// Functions specific to mutable stream end messages
+/* Functions specific to mutable stream end messages */
 template <>
 struct CommonStreamEndMessageSpec<bt_message> final
 {
@@ -288,7 +325,7 @@ struct CommonStreamEndMessageSpec<bt_message> final
     }
 };
 
-// Functions specific to constant stream end messages
+/* Functions specific to constant stream end messages */
 template <>
 struct CommonStreamEndMessageSpec<const bt_message> final
 {
@@ -298,7 +335,7 @@ struct CommonStreamEndMessageSpec<const bt_message> final
     }
 };
 
-} // namespace internal
+} /* namespace internal */
 
 template <typename LibObjT>
 class CommonStreamEndMessage final : public CommonMessage<LibObjT>
@@ -312,7 +349,7 @@ private:
                                   CommonStream<bt_stream>>::type;
 
 public:
-    using Shared = internal::SharedMessage<CommonStreamEndMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonStreamEndMessage<LibObjT>, LibObjT>;
 
     explicit CommonStreamEndMessage(const _LibObjPtr libObjPtr) noexcept :
         _ThisCommonMessage {libObjPtr}
@@ -321,14 +358,14 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonStreamEndMessage(const CommonStreamEndMessage<OtherLibObjT>& val) noexcept :
+    CommonStreamEndMessage(const CommonStreamEndMessage<OtherLibObjT> val) noexcept :
         _ThisCommonMessage {val}
     {
     }
 
     template <typename OtherLibObjT>
     CommonStreamEndMessage<LibObjT>&
-    operator=(const CommonStreamEndMessage<OtherLibObjT>& val) noexcept
+    operator=(const CommonStreamEndMessage<OtherLibObjT> val) noexcept
     {
         _ThisCommonMessage::operator=(val);
         return *this;
@@ -337,26 +374,26 @@ public:
     ConstStream stream() const noexcept
     {
         return ConstStream {
-            internal::CommonStreamEndMessageSpec<const bt_message>::stream(this->_libObjPtr())};
+            internal::CommonStreamEndMessageSpec<const bt_message>::stream(this->libObjPtr())};
     }
 
     _Stream stream() noexcept
     {
-        return _Stream {internal::CommonStreamEndMessageSpec<LibObjT>::stream(this->_libObjPtr())};
+        return _Stream {internal::CommonStreamEndMessageSpec<LibObjT>::stream(this->libObjPtr())};
     }
 
     void defaultClockSnapshot(const std::uint64_t val) noexcept
     {
         static_assert(!std::is_const<LibObjT>::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<ConstClockSnapshot> 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 +404,7 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
@@ -376,10 +413,26 @@ using ConstStreamEndMessage = CommonStreamEndMessage<const bt_message>;
 
 namespace internal {
 
+struct StreamEndMessageTypeDescr
+{
+    using Const = ConstStreamEndMessage;
+    using NonConst = StreamEndMessage;
+};
+
+template <>
+struct TypeDescr<StreamEndMessage> : public StreamEndMessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstStreamEndMessage> : public StreamEndMessageTypeDescr
+{
+};
+
 template <typename LibObjT>
 struct CommonPacketBeginningMessageSpec;
 
-// Functions specific to mutable packet beginning messages
+/* Functions specific to mutable packet beginning messages */
 template <>
 struct CommonPacketBeginningMessageSpec<bt_message> final
 {
@@ -389,7 +442,7 @@ struct CommonPacketBeginningMessageSpec<bt_message> final
     }
 };
 
-// Functions specific to constant packet beginning messages
+/* Functions specific to constant packet beginning messages */
 template <>
 struct CommonPacketBeginningMessageSpec<const bt_message> final
 {
@@ -399,7 +452,7 @@ struct CommonPacketBeginningMessageSpec<const bt_message> final
     }
 };
 
-} // namespace internal
+} /* namespace internal */
 
 template <typename LibObjT>
 class CommonPacketBeginningMessage final : public CommonMessage<LibObjT>
@@ -413,7 +466,7 @@ private:
                                   CommonPacket<bt_packet>>::type;
 
 public:
-    using Shared = internal::SharedMessage<CommonPacketBeginningMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonPacketBeginningMessage<LibObjT>, LibObjT>;
 
     explicit CommonPacketBeginningMessage(const _LibObjPtr libObjPtr) noexcept :
         _ThisCommonMessage {libObjPtr}
@@ -422,14 +475,14 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonPacketBeginningMessage(const CommonPacketBeginningMessage<OtherLibObjT>& val) noexcept :
+    CommonPacketBeginningMessage(const CommonPacketBeginningMessage<OtherLibObjT> val) noexcept :
         _ThisCommonMessage {val}
     {
     }
 
     template <typename OtherLibObjT>
     CommonPacketBeginningMessage<LibObjT>&
-    operator=(const CommonPacketBeginningMessage<OtherLibObjT>& val) noexcept
+    operator=(const CommonPacketBeginningMessage<OtherLibObjT> val) noexcept
     {
         _ThisCommonMessage::operator=(val);
         return *this;
@@ -438,33 +491,33 @@ public:
     ConstPacket packet() const noexcept
     {
         return ConstPacket {internal::CommonPacketBeginningMessageSpec<const bt_message>::packet(
-            this->_libObjPtr())};
+            this->libObjPtr())};
     }
 
     _Packet packet() noexcept
     {
         return _Packet {
-            internal::CommonPacketBeginningMessageSpec<LibObjT>::packet(this->_libObjPtr())};
+            internal::CommonPacketBeginningMessageSpec<LibObjT>::packet(this->libObjPtr())};
     }
 
     void defaultClockSnapshot(const std::uint64_t val) noexcept
     {
         static_assert(!std::is_const<LibObjT>::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 +526,26 @@ using ConstPacketBeginningMessage = CommonPacketBeginningMessage<const bt_messag
 
 namespace internal {
 
+struct PacketBeginningMessageTypeDescr
+{
+    using Const = ConstPacketBeginningMessage;
+    using NonConst = PacketBeginningMessage;
+};
+
+template <>
+struct TypeDescr<PacketBeginningMessage> : public PacketBeginningMessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstPacketBeginningMessage> : public PacketBeginningMessageTypeDescr
+{
+};
+
 template <typename LibObjT>
 struct CommonPacketEndMessageSpec;
 
-// Functions specific to mutable packet end messages
+/* Functions specific to mutable packet end messages */
 template <>
 struct CommonPacketEndMessageSpec<bt_message> final
 {
@@ -486,7 +555,7 @@ struct CommonPacketEndMessageSpec<bt_message> final
     }
 };
 
-// Functions specific to constant packet end messages
+/* Functions specific to constant packet end messages */
 template <>
 struct CommonPacketEndMessageSpec<const bt_message> final
 {
@@ -496,7 +565,7 @@ struct CommonPacketEndMessageSpec<const bt_message> final
     }
 };
 
-} // namespace internal
+} /* namespace internal */
 
 template <typename LibObjT>
 class CommonPacketEndMessage final : public CommonMessage<LibObjT>
@@ -510,7 +579,7 @@ private:
                                   CommonPacket<bt_packet>>::type;
 
 public:
-    using Shared = internal::SharedMessage<CommonPacketEndMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonPacketEndMessage<LibObjT>, LibObjT>;
 
     explicit CommonPacketEndMessage(const _LibObjPtr libObjPtr) noexcept :
         _ThisCommonMessage {libObjPtr}
@@ -519,14 +588,14 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonPacketEndMessage(const CommonPacketEndMessage<OtherLibObjT>& val) noexcept :
+    CommonPacketEndMessage(const CommonPacketEndMessage<OtherLibObjT> val) noexcept :
         _ThisCommonMessage {val}
     {
     }
 
     template <typename OtherLibObjT>
     CommonPacketEndMessage<LibObjT>&
-    operator=(const CommonPacketEndMessage<OtherLibObjT>& val) noexcept
+    operator=(const CommonPacketEndMessage<OtherLibObjT> val) noexcept
     {
         _ThisCommonMessage::operator=(val);
         return *this;
@@ -535,32 +604,32 @@ public:
     ConstPacket packet() const noexcept
     {
         return ConstPacket {
-            internal::CommonPacketEndMessageSpec<const bt_message>::packet(this->_libObjPtr())};
+            internal::CommonPacketEndMessageSpec<const bt_message>::packet(this->libObjPtr())};
     }
 
     _Packet packet() noexcept
     {
-        return _Packet {internal::CommonPacketEndMessageSpec<LibObjT>::packet(this->_libObjPtr())};
+        return _Packet {internal::CommonPacketEndMessageSpec<LibObjT>::packet(this->libObjPtr())};
     }
 
     void defaultClockSnapshot(const std::uint64_t val) noexcept
     {
         static_assert(!std::is_const<LibObjT>::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 +638,26 @@ using ConstPacketEndMessage = CommonPacketEndMessage<const bt_message>;
 
 namespace internal {
 
+struct PacketEndMessageTypeDescr
+{
+    using Const = ConstPacketEndMessage;
+    using NonConst = PacketEndMessage;
+};
+
+template <>
+struct TypeDescr<PacketEndMessage> : public PacketEndMessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstPacketEndMessage> : public PacketEndMessageTypeDescr
+{
+};
+
 template <typename LibObjT>
 struct CommonEventMessageSpec;
 
-// Functions specific to mutable event messages
+/* Functions specific to mutable event messages */
 template <>
 struct CommonEventMessageSpec<bt_message> final
 {
@@ -582,7 +667,7 @@ struct CommonEventMessageSpec<bt_message> final
     }
 };
 
-// Functions specific to constant event messages
+/* Functions specific to constant event messages */
 template <>
 struct CommonEventMessageSpec<const bt_message> final
 {
@@ -592,7 +677,7 @@ struct CommonEventMessageSpec<const bt_message> final
     }
 };
 
-} // namespace internal
+} /* namespace internal */
 
 template <typename LibObjT>
 class CommonEventMessage final : public CommonMessage<LibObjT>
@@ -606,7 +691,7 @@ private:
                                   CommonEvent<bt_event>>::type;
 
 public:
-    using Shared = internal::SharedMessage<CommonEventMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonEventMessage<LibObjT>, LibObjT>;
 
     explicit CommonEventMessage(const _LibObjPtr libObjPtr) noexcept :
         _ThisCommonMessage {libObjPtr}
@@ -615,13 +700,13 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonEventMessage(const CommonEventMessage<OtherLibObjT>& val) noexcept :
+    CommonEventMessage(const CommonEventMessage<OtherLibObjT> val) noexcept :
         _ThisCommonMessage {val}
     {
     }
 
     template <typename OtherLibObjT>
-    CommonEventMessage<LibObjT>& operator=(const CommonEventMessage<OtherLibObjT>& val) noexcept
+    CommonEventMessage<LibObjT>& operator=(const CommonEventMessage<OtherLibObjT> val) noexcept
     {
         _ThisCommonMessage::operator=(val);
         return *this;
@@ -630,25 +715,25 @@ public:
     ConstEvent event() const noexcept
     {
         return ConstEvent {
-            internal::CommonEventMessageSpec<const bt_message>::event(this->_libObjPtr())};
+            internal::CommonEventMessageSpec<const bt_message>::event(this->libObjPtr())};
     }
 
     _Event event() noexcept
     {
-        return _Event {internal::CommonEventMessageSpec<LibObjT>::event(this->_libObjPtr())};
+        return _Event {internal::CommonEventMessageSpec<LibObjT>::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 +742,26 @@ using ConstEventMessage = CommonEventMessage<const bt_message>;
 
 namespace internal {
 
+struct EventMessageTypeDescr
+{
+    using Const = ConstEventMessage;
+    using NonConst = EventMessage;
+};
+
+template <>
+struct TypeDescr<EventMessage> : public EventMessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstEventMessage> : public EventMessageTypeDescr
+{
+};
+
 template <typename LibObjT>
 struct CommonDiscardedEventsMessageSpec;
 
-// Functions specific to mutable discarded events messages
+/* Functions specific to mutable discarded events messages */
 template <>
 struct CommonDiscardedEventsMessageSpec<bt_message> final
 {
@@ -670,7 +771,7 @@ struct CommonDiscardedEventsMessageSpec<bt_message> final
     }
 };
 
-// Functions specific to constant discarded events messages
+/* Functions specific to constant discarded events messages */
 template <>
 struct CommonDiscardedEventsMessageSpec<const bt_message> final
 {
@@ -680,7 +781,7 @@ struct CommonDiscardedEventsMessageSpec<const bt_message> final
     }
 };
 
-} // namespace internal
+} /* namespace internal */
 
 template <typename LibObjT>
 class CommonDiscardedEventsMessage final : public CommonMessage<LibObjT>
@@ -694,7 +795,7 @@ private:
                                   CommonStream<bt_stream>>::type;
 
 public:
-    using Shared = internal::SharedMessage<CommonDiscardedEventsMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonDiscardedEventsMessage<LibObjT>, LibObjT>;
 
     explicit CommonDiscardedEventsMessage(const _LibObjPtr libObjPtr) noexcept :
         _ThisCommonMessage {libObjPtr}
@@ -703,14 +804,14 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonDiscardedEventsMessage(const CommonDiscardedEventsMessage<OtherLibObjT>& val) noexcept :
+    CommonDiscardedEventsMessage(const CommonDiscardedEventsMessage<OtherLibObjT> val) noexcept :
         _ThisCommonMessage {val}
     {
     }
 
     template <typename OtherLibObjT>
     CommonDiscardedEventsMessage<LibObjT>&
-    operator=(const CommonDiscardedEventsMessage<OtherLibObjT>& val) noexcept
+    operator=(const CommonDiscardedEventsMessage<OtherLibObjT> val) noexcept
     {
         _ThisCommonMessage::operator=(val);
         return *this;
@@ -719,20 +820,20 @@ public:
     ConstStream stream() const noexcept
     {
         return ConstStream {internal::CommonDiscardedEventsMessageSpec<const bt_message>::stream(
-            this->_libObjPtr())};
+            this->libObjPtr())};
     }
 
     _Stream stream() noexcept
     {
         return _Stream {
-            internal::CommonDiscardedEventsMessageSpec<LibObjT>::stream(this->_libObjPtr())};
+            internal::CommonDiscardedEventsMessageSpec<LibObjT>::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 +841,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 +850,13 @@ public:
     {
         static_assert(!std::is_const<LibObjT>::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<std::uint64_t> 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 +867,7 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
@@ -775,10 +876,26 @@ using ConstDiscardedEventsMessage = CommonDiscardedEventsMessage<const bt_messag
 
 namespace internal {
 
+struct DiscardedEventsMessageTypeDescr
+{
+    using Const = ConstDiscardedEventsMessage;
+    using NonConst = DiscardedEventsMessage;
+};
+
+template <>
+struct TypeDescr<DiscardedEventsMessage> : public DiscardedEventsMessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstDiscardedEventsMessage> : public DiscardedEventsMessageTypeDescr
+{
+};
+
 template <typename LibObjT>
 struct CommonDiscardedPacketsMessageSpec;
 
-// Functions specific to mutable discarded packets messages
+/* Functions specific to mutable discarded packets messages */
 template <>
 struct CommonDiscardedPacketsMessageSpec<bt_message> final
 {
@@ -788,7 +905,7 @@ struct CommonDiscardedPacketsMessageSpec<bt_message> final
     }
 };
 
-// Functions specific to constant discarded packets messages
+/* Functions specific to constant discarded packets messages */
 template <>
 struct CommonDiscardedPacketsMessageSpec<const bt_message> final
 {
@@ -798,7 +915,7 @@ struct CommonDiscardedPacketsMessageSpec<const bt_message> final
     }
 };
 
-} // namespace internal
+} /* namespace internal */
 
 template <typename LibObjT>
 class CommonDiscardedPacketsMessage final : public CommonMessage<LibObjT>
@@ -812,7 +929,7 @@ private:
                                   CommonStream<bt_stream>>::type;
 
 public:
-    using Shared = internal::SharedMessage<CommonDiscardedPacketsMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonDiscardedPacketsMessage<LibObjT>, LibObjT>;
 
     explicit CommonDiscardedPacketsMessage(const _LibObjPtr libObjPtr) noexcept :
         _ThisCommonMessage {libObjPtr}
@@ -821,14 +938,14 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonDiscardedPacketsMessage(const CommonDiscardedPacketsMessage<OtherLibObjT>& val) noexcept :
+    CommonDiscardedPacketsMessage(const CommonDiscardedPacketsMessage<OtherLibObjT> val) noexcept :
         _ThisCommonMessage {val}
     {
     }
 
     template <typename OtherLibObjT>
     CommonDiscardedPacketsMessage<LibObjT>&
-    operator=(const CommonDiscardedPacketsMessage<OtherLibObjT>& val) noexcept
+    operator=(const CommonDiscardedPacketsMessage<OtherLibObjT> val) noexcept
     {
         _ThisCommonMessage::operator=(val);
         return *this;
@@ -837,28 +954,28 @@ public:
     ConstStream stream() const noexcept
     {
         return ConstStream {internal::CommonDiscardedPacketsMessageSpec<const bt_message>::stream(
-            this->_libObjPtr())};
+            this->libObjPtr())};
     }
 
     _Stream stream() noexcept
     {
         return _Stream {
-            internal::CommonDiscardedPacketsMessageSpec<LibObjT>::stream(this->_libObjPtr())};
+            internal::CommonDiscardedPacketsMessageSpec<LibObjT>::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 +984,13 @@ public:
     {
         static_assert(!std::is_const<LibObjT>::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<std::uint64_t> 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 +1001,33 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
 using DiscardedPacketsMessage = CommonDiscardedPacketsMessage<bt_message>;
 using ConstDiscardedPacketsMessage = CommonDiscardedPacketsMessage<const bt_message>;
 
+namespace internal {
+
+struct DiscardedPacketsMessageTypeDescr
+{
+    using Const = ConstDiscardedPacketsMessage;
+    using NonConst = DiscardedPacketsMessage;
+};
+
+template <>
+struct TypeDescr<DiscardedPacketsMessage> : public DiscardedPacketsMessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstDiscardedPacketsMessage> : public DiscardedPacketsMessageTypeDescr
+{
+};
+
+} /* namespace internal */
+
 template <typename LibObjT>
 class CommonMessageIteratorInactivityMessage final : public CommonMessage<LibObjT>
 {
@@ -899,8 +1036,7 @@ private:
     using typename CommonMessage<LibObjT>::_ThisCommonMessage;
 
 public:
-    using Shared =
-        internal::SharedMessage<CommonMessageIteratorInactivityMessage<LibObjT>, LibObjT>;
+    using Shared = SharedMessage<CommonMessageIteratorInactivityMessage<LibObjT>, LibObjT>;
 
     explicit CommonMessageIteratorInactivityMessage(const _LibObjPtr libObjPtr) noexcept :
         _ThisCommonMessage {libObjPtr}
@@ -910,14 +1046,14 @@ public:
 
     template <typename OtherLibObjT>
     CommonMessageIteratorInactivityMessage(
-        const CommonMessageIteratorInactivityMessage<OtherLibObjT>& val) noexcept :
+        const CommonMessageIteratorInactivityMessage<OtherLibObjT> val) noexcept :
         _ThisCommonMessage {val}
     {
     }
 
     template <typename OtherLibObjT>
     CommonMessageIteratorInactivityMessage<LibObjT>&
-    operator=(const CommonMessageIteratorInactivityMessage<OtherLibObjT>& val) noexcept
+    operator=(const CommonMessageIteratorInactivityMessage<OtherLibObjT> val) noexcept
     {
         _ThisCommonMessage::operator=(val);
         return *this;
@@ -926,14 +1062,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 +1077,75 @@ using MessageIteratorInactivityMessage = CommonMessageIteratorInactivityMessage<
 using ConstMessageIteratorInactivityMessage =
     CommonMessageIteratorInactivityMessage<const bt_message>;
 
+namespace internal {
+
+struct MessageIteratorInactivityMessageTypeDescr
+{
+    using Const = ConstMessageIteratorInactivityMessage;
+    using NonConst = MessageIteratorInactivityMessage;
+};
+
+template <>
+struct TypeDescr<MessageIteratorInactivityMessage> :
+    public MessageIteratorInactivityMessageTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstMessageIteratorInactivityMessage> :
+    public MessageIteratorInactivityMessageTypeDescr
+{
+};
+
+} /* namespace internal */
+
 template <typename LibObjT>
 CommonStreamBeginningMessage<LibObjT> CommonMessage<LibObjT>::asStreamBeginning() const noexcept
 {
     BT_ASSERT_DBG(this->isStreamBeginning());
-    return CommonStreamBeginningMessage<LibObjT> {this->_libObjPtr()};
+    return CommonStreamBeginningMessage<LibObjT> {this->libObjPtr()};
 }
 
 template <typename LibObjT>
 CommonStreamEndMessage<LibObjT> CommonMessage<LibObjT>::asStreamEnd() const noexcept
 {
     BT_ASSERT_DBG(this->isStreamEnd());
-    return CommonStreamEndMessage<LibObjT> {this->_libObjPtr()};
+    return CommonStreamEndMessage<LibObjT> {this->libObjPtr()};
 }
 
 template <typename LibObjT>
 CommonPacketBeginningMessage<LibObjT> CommonMessage<LibObjT>::asPacketBeginning() const noexcept
 {
     BT_ASSERT_DBG(this->isPacketBeginning());
-    return CommonPacketBeginningMessage<LibObjT> {this->_libObjPtr()};
+    return CommonPacketBeginningMessage<LibObjT> {this->libObjPtr()};
 }
 
 template <typename LibObjT>
 CommonPacketEndMessage<LibObjT> CommonMessage<LibObjT>::asPacketEnd() const noexcept
 {
     BT_ASSERT_DBG(this->isPacketEnd());
-    return CommonPacketEndMessage<LibObjT> {this->_libObjPtr()};
+    return CommonPacketEndMessage<LibObjT> {this->libObjPtr()};
 }
 
 template <typename LibObjT>
 CommonEventMessage<LibObjT> CommonMessage<LibObjT>::asEvent() const noexcept
 {
     BT_ASSERT_DBG(this->isEvent());
-    return CommonEventMessage<LibObjT> {this->_libObjPtr()};
+    return CommonEventMessage<LibObjT> {this->libObjPtr()};
 }
 
 template <typename LibObjT>
 CommonDiscardedEventsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedEvents() const noexcept
 {
     BT_ASSERT_DBG(this->isDiscardedEvents());
-    return CommonDiscardedEventsMessage<LibObjT> {this->_libObjPtr()};
+    return CommonDiscardedEventsMessage<LibObjT> {this->libObjPtr()};
+}
+
+template <typename LibObjT>
+CommonDiscardedPacketsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedPackets() const noexcept
+{
+    BT_ASSERT_DBG(this->isDiscardedPackets());
+    return CommonDiscardedPacketsMessage<LibObjT> {this->libObjPtr()};
 }
 
 template <typename LibObjT>
@@ -988,9 +1153,9 @@ CommonMessageIteratorInactivityMessage<LibObjT>
 CommonMessage<LibObjT>::asMessageIteratorInactivity() const noexcept
 {
     BT_ASSERT_DBG(this->isMessageIteratorInactivity());
-    return CommonMessageIteratorInactivityMessage<LibObjT> {this->_libObjPtr()};
+    return CommonMessageIteratorInactivityMessage<LibObjT> {this->libObjPtr()};
 }
 
-} // namespace bt2
+} /* namespace bt2 */
 
-#endif // BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP
+#endif /* BABELTRACE_CPP_COMMON_BT2_MESSAGE_HPP */
This page took 0.039619 seconds and 4 git commands to generate.