#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 "cpp-common/bt2/clock-snapshot.hpp"
+#include "cpp-common/bt2/trace-ir.hpp"
+#include "cpp-common/bt2s/optional.hpp"
+
+#include "borrowed-object.hpp"
#include "internal/utils.hpp"
-#include "cpp-common/optional.hpp"
-#include "cpp-common/string_view.hpp"
-#include "lib-error.hpp"
+#include "optional-borrowed-object.hpp"
+#include "shared-object.hpp"
+#include "trace-ir.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 */
+template <typename ObjT, typename LibObjT>
+using SharedMessage = SharedObject<ObjT, LibObjT, internal::MessageRefFuncs>;
+
template <typename LibObjT>
class CommonStreamBeginningMessage;
enum class MessageType
{
- STREAM_BEGINNING = BT_MESSAGE_TYPE_STREAM_BEGINNING,
- STREAM_END = BT_MESSAGE_TYPE_STREAM_END,
- EVENT = BT_MESSAGE_TYPE_EVENT,
- PACKET_BEGINNING = BT_MESSAGE_TYPE_PACKET_BEGINNING,
- PACKET_END = BT_MESSAGE_TYPE_PACKET_END,
- DISCARDED_EVENTS = BT_MESSAGE_TYPE_DISCARDED_EVENTS,
- DISCARDED_PACKETS = BT_MESSAGE_TYPE_DISCARDED_PACKETS,
- MESSAGE_ITERATOR_INACTIVITY = BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY,
+ StreamBeginning = BT_MESSAGE_TYPE_STREAM_BEGINNING,
+ StreamEnd = BT_MESSAGE_TYPE_STREAM_END,
+ Event = BT_MESSAGE_TYPE_EVENT,
+ PacketBeginning = BT_MESSAGE_TYPE_PACKET_BEGINNING,
+ PacketEnd = BT_MESSAGE_TYPE_PACKET_END,
+ DiscardedEvents = BT_MESSAGE_TYPE_DISCARDED_EVENTS,
+ DiscardedPackets = BT_MESSAGE_TYPE_DISCARDED_PACKETS,
+ MessageIteratorInactivity = BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY,
};
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 _ThisCommonMessage = CommonMessage<LibObjT>;
public:
- using Shared = internal::SharedMessage<CommonMessage<LibObjT>, LibObjT>;
+ using typename BorrowedObject<LibObjT>::LibObjPtr;
+ 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;
}
+ CommonMessage<const bt_message> asConst() const noexcept
+ {
+ return CommonMessage<const bt_message> {*this};
+ }
+
MessageType type() const noexcept
{
return static_cast<MessageType>(bt_message_get_type(this->libObjPtr()));
bool isStreamBeginning() const noexcept
{
- return this->type() == MessageType::STREAM_BEGINNING;
+ return this->type() == MessageType::StreamBeginning;
}
bool isStreamEnd() const noexcept
{
- return this->type() == MessageType::STREAM_END;
+ return this->type() == MessageType::StreamEnd;
}
bool isEvent() const noexcept
{
- return this->type() == MessageType::EVENT;
+ return this->type() == MessageType::Event;
}
bool isPacketBeginning() const noexcept
{
- return this->type() == MessageType::PACKET_BEGINNING;
+ return this->type() == MessageType::PacketBeginning;
}
bool isPacketEnd() const noexcept
{
- return this->type() == MessageType::PACKET_END;
+ return this->type() == MessageType::PacketEnd;
}
bool isDiscardedEvents() const noexcept
{
- return this->type() == MessageType::DISCARDED_EVENTS;
+ return this->type() == MessageType::DiscardedEvents;
}
bool isDiscardedPackets() const noexcept
{
- return this->type() == MessageType::DISCARDED_PACKETS;
+ return this->type() == MessageType::DiscardedPackets;
}
bool isMessageIteratorInactivity() const noexcept
{
- return this->type() == MessageType::MESSAGE_ITERATOR_INACTIVITY;
+ return this->type() == MessageType::MessageIteratorInactivity;
}
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;
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;
class CommonStreamBeginningMessage final : public CommonMessage<LibObjT>
{
private:
- using typename CommonMessage<LibObjT>::_LibObjPtr;
using typename CommonMessage<LibObjT>::_ThisCommonMessage;
-
- using _Stream =
- typename std::conditional<std::is_const<LibObjT>::value, CommonStream<const bt_stream>,
- CommonStream<bt_stream>>::type;
+ using _Stream = internal::DepStream<LibObjT>;
public:
- using Shared = internal::SharedMessage<CommonStreamBeginningMessage<LibObjT>, LibObjT>;
+ using typename CommonMessage<LibObjT>::LibObjPtr;
+ using Shared = SharedMessage<CommonStreamBeginningMessage<LibObjT>, LibObjT>;
- explicit CommonStreamBeginningMessage(const _LibObjPtr libObjPtr) noexcept :
+ explicit CommonStreamBeginningMessage(const LibObjPtr libObjPtr) noexcept :
_ThisCommonMessage {libObjPtr}
{
BT_ASSERT_DBG(this->isStreamBeginning());
}
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
+ CommonStreamBeginningMessage<LibObjT>
+ operator=(const CommonStreamBeginningMessage<OtherLibObjT> val) noexcept
{
_ThisCommonMessage::operator=(val);
return *this;
}
- ConstStream stream() const noexcept
+ CommonStreamBeginningMessage<const bt_message> asConst() const noexcept
{
- return ConstStream {internal::CommonStreamBeginningMessageSpec<const bt_message>::stream(
- this->libObjPtr())};
+ return CommonStreamBeginningMessage<const bt_message> {*this};
}
- _Stream stream() noexcept
+ _Stream stream() const noexcept
{
return _Stream {
internal::CommonStreamBeginningMessageSpec<LibObjT>::stream(this->libObjPtr())};
}
- void defaultClockSnapshot(const std::uint64_t val) noexcept
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ return bt_message_stream_beginning_borrow_stream_class_default_clock_class_const(
+ this->libObjPtr());
+ }
+
+ CommonStreamBeginningMessage defaultClockSnapshot(const std::uint64_t val) const noexcept
+ {
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstStreamBeginningMessage`.");
bt_message_stream_beginning_set_default_clock_snapshot(this->libObjPtr(), val);
+ return *this;
}
- nonstd::optional<ConstClockSnapshot> defaultClockSnapshot() const noexcept
+ OptionalBorrowedObject<ConstClockSnapshot> defaultClockSnapshot() const noexcept
{
const bt_clock_snapshot *libObjPtr;
const auto state = bt_message_stream_beginning_borrow_default_clock_snapshot_const(
this->libObjPtr(), &libObjPtr);
if (state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) {
- return ConstClockSnapshot {libObjPtr};
+ return libObjPtr;
}
- return nonstd::nullopt;
+ return {};
}
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
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;
class CommonStreamEndMessage final : public CommonMessage<LibObjT>
{
private:
- using typename CommonMessage<LibObjT>::_LibObjPtr;
using typename CommonMessage<LibObjT>::_ThisCommonMessage;
-
- using _Stream =
- typename std::conditional<std::is_const<LibObjT>::value, CommonStream<const bt_stream>,
- CommonStream<bt_stream>>::type;
+ using _Stream = internal::DepStream<LibObjT>;
public:
- using Shared = internal::SharedMessage<CommonStreamEndMessage<LibObjT>, LibObjT>;
+ using typename CommonMessage<LibObjT>::LibObjPtr;
+ using Shared = SharedMessage<CommonStreamEndMessage<LibObjT>, LibObjT>;
- explicit CommonStreamEndMessage(const _LibObjPtr libObjPtr) noexcept :
+ explicit CommonStreamEndMessage(const LibObjPtr libObjPtr) noexcept :
_ThisCommonMessage {libObjPtr}
{
BT_ASSERT_DBG(this->isStreamEnd());
}
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
+ CommonStreamEndMessage<LibObjT>
+ operator=(const CommonStreamEndMessage<OtherLibObjT> val) noexcept
{
_ThisCommonMessage::operator=(val);
return *this;
}
- ConstStream stream() const noexcept
+ CommonStreamEndMessage<const bt_message> asConst() const noexcept
{
- return ConstStream {
- internal::CommonStreamEndMessageSpec<const bt_message>::stream(this->libObjPtr())};
+ return CommonStreamEndMessage<const bt_message> {*this};
}
- _Stream stream() noexcept
+ _Stream stream() const noexcept
{
return _Stream {internal::CommonStreamEndMessageSpec<LibObjT>::stream(this->libObjPtr())};
}
- void defaultClockSnapshot(const std::uint64_t val) noexcept
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
+ {
+ return bt_message_stream_end_borrow_stream_class_default_clock_class_const(
+ this->libObjPtr());
+ }
+
+ CommonStreamEndMessage defaultClockSnapshot(const std::uint64_t val) const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstStreamEndMessage`.");
bt_message_stream_end_set_default_clock_snapshot(this->libObjPtr(), val);
+ return *this;
}
- nonstd::optional<ConstClockSnapshot> defaultClockSnapshot() const noexcept
+ OptionalBorrowedObject<ConstClockSnapshot> defaultClockSnapshot() const noexcept
{
const bt_clock_snapshot *libObjPtr;
const auto state = bt_message_stream_end_borrow_default_clock_snapshot_const(
this->libObjPtr(), &libObjPtr);
if (state == BT_MESSAGE_STREAM_CLOCK_SNAPSHOT_STATE_KNOWN) {
- return ConstClockSnapshot {libObjPtr};
+ return libObjPtr;
}
- return nonstd::nullopt;
+ return {};
}
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
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;
class CommonPacketBeginningMessage final : public CommonMessage<LibObjT>
{
private:
- using typename CommonMessage<LibObjT>::_LibObjPtr;
using typename CommonMessage<LibObjT>::_ThisCommonMessage;
-
- using _Packet =
- typename std::conditional<std::is_const<LibObjT>::value, CommonPacket<const bt_packet>,
- CommonPacket<bt_packet>>::type;
+ using _Packet = internal::DepPacket<LibObjT>;
public:
- using Shared = internal::SharedMessage<CommonPacketBeginningMessage<LibObjT>, LibObjT>;
+ using typename CommonMessage<LibObjT>::LibObjPtr;
+ using Shared = SharedMessage<CommonPacketBeginningMessage<LibObjT>, LibObjT>;
- explicit CommonPacketBeginningMessage(const _LibObjPtr libObjPtr) noexcept :
+ explicit CommonPacketBeginningMessage(const LibObjPtr libObjPtr) noexcept :
_ThisCommonMessage {libObjPtr}
{
BT_ASSERT_DBG(this->isPacketBeginning());
}
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
+ CommonPacketBeginningMessage<LibObjT>
+ operator=(const CommonPacketBeginningMessage<OtherLibObjT> val) noexcept
{
_ThisCommonMessage::operator=(val);
return *this;
}
- ConstPacket packet() const noexcept
+ CommonPacketBeginningMessage<const bt_message> asConst() const noexcept
{
- return ConstPacket {internal::CommonPacketBeginningMessageSpec<const bt_message>::packet(
- this->libObjPtr())};
+ return CommonPacketBeginningMessage<const bt_message> {*this};
}
- _Packet packet() noexcept
+ _Packet packet() const noexcept
{
return _Packet {
internal::CommonPacketBeginningMessageSpec<LibObjT>::packet(this->libObjPtr())};
}
- void defaultClockSnapshot(const std::uint64_t val) noexcept
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
+ {
+ return bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
+ this->libObjPtr());
+ }
+
+ CommonPacketBeginningMessage defaultClockSnapshot(const std::uint64_t val) const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstPacketBeginningMessage`.");
bt_message_packet_beginning_set_default_clock_snapshot(this->libObjPtr(), val);
+ return *this;
}
ConstClockSnapshot defaultClockSnapshot() const noexcept
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
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;
class CommonPacketEndMessage final : public CommonMessage<LibObjT>
{
private:
- using typename CommonMessage<LibObjT>::_LibObjPtr;
using typename CommonMessage<LibObjT>::_ThisCommonMessage;
-
- using _Packet =
- typename std::conditional<std::is_const<LibObjT>::value, CommonPacket<const bt_packet>,
- CommonPacket<bt_packet>>::type;
+ using _Packet = internal::DepPacket<LibObjT>;
public:
- using Shared = internal::SharedMessage<CommonPacketEndMessage<LibObjT>, LibObjT>;
+ using typename CommonMessage<LibObjT>::LibObjPtr;
+ using Shared = SharedMessage<CommonPacketEndMessage<LibObjT>, LibObjT>;
- explicit CommonPacketEndMessage(const _LibObjPtr libObjPtr) noexcept :
+ explicit CommonPacketEndMessage(const LibObjPtr libObjPtr) noexcept :
_ThisCommonMessage {libObjPtr}
{
BT_ASSERT_DBG(this->isPacketEnd());
}
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
+ CommonPacketEndMessage<LibObjT>
+ operator=(const CommonPacketEndMessage<OtherLibObjT> val) noexcept
{
_ThisCommonMessage::operator=(val);
return *this;
}
- ConstPacket packet() const noexcept
+ CommonPacketEndMessage<const bt_message> asConst() const noexcept
{
- return ConstPacket {
- internal::CommonPacketEndMessageSpec<const bt_message>::packet(this->libObjPtr())};
+ return CommonPacketEndMessage<const bt_message> {*this};
}
- _Packet packet() noexcept
+ _Packet packet() const noexcept
{
return _Packet {internal::CommonPacketEndMessageSpec<LibObjT>::packet(this->libObjPtr())};
}
- void defaultClockSnapshot(const std::uint64_t val) noexcept
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
+ {
+ return bt_message_packet_end_borrow_stream_class_default_clock_class_const(
+ this->libObjPtr());
+ }
+
+ CommonPacketEndMessage defaultClockSnapshot(const std::uint64_t val) const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstPacketEndMessage`.");
bt_message_packet_end_set_default_clock_snapshot(this->libObjPtr(), val);
+ return *this;
}
ConstClockSnapshot defaultClockSnapshot() const noexcept
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
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;
class CommonEventMessage final : public CommonMessage<LibObjT>
{
private:
- using typename CommonMessage<LibObjT>::_LibObjPtr;
using typename CommonMessage<LibObjT>::_ThisCommonMessage;
-
- using _Event =
- typename std::conditional<std::is_const<LibObjT>::value, CommonEvent<const bt_event>,
- CommonEvent<bt_event>>::type;
+ using _Event = internal::DepType<LibObjT, CommonEvent<bt_event>, CommonEvent<const bt_event>>;
public:
- using Shared = internal::SharedMessage<CommonEventMessage<LibObjT>, LibObjT>;
+ using typename CommonMessage<LibObjT>::LibObjPtr;
+ using Shared = SharedMessage<CommonEventMessage<LibObjT>, LibObjT>;
- explicit CommonEventMessage(const _LibObjPtr libObjPtr) noexcept :
- _ThisCommonMessage {libObjPtr}
+ explicit CommonEventMessage(const LibObjPtr libObjPtr) noexcept : _ThisCommonMessage {libObjPtr}
{
BT_ASSERT_DBG(this->isEvent());
}
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;
}
- ConstEvent event() const noexcept
+ CommonEventMessage<const bt_message> asConst() const noexcept
{
- return ConstEvent {
- internal::CommonEventMessageSpec<const bt_message>::event(this->libObjPtr())};
+ return CommonEventMessage<const bt_message> {*this};
}
- _Event event() noexcept
+ _Event event() const noexcept
{
return _Event {internal::CommonEventMessageSpec<LibObjT>::event(this->libObjPtr())};
}
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
+ {
+ return bt_message_event_borrow_stream_class_default_clock_class_const(this->libObjPtr());
+ }
+
ConstClockSnapshot defaultClockSnapshot() const noexcept
{
const auto libObjPtr =
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
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;
class CommonDiscardedEventsMessage final : public CommonMessage<LibObjT>
{
private:
- using typename CommonMessage<LibObjT>::_LibObjPtr;
using typename CommonMessage<LibObjT>::_ThisCommonMessage;
-
- using _Stream =
- typename std::conditional<std::is_const<LibObjT>::value, CommonStream<const bt_stream>,
- CommonStream<bt_stream>>::type;
+ using _Stream = internal::DepStream<LibObjT>;
public:
- using Shared = internal::SharedMessage<CommonDiscardedEventsMessage<LibObjT>, LibObjT>;
+ using typename CommonMessage<LibObjT>::LibObjPtr;
+ using Shared = SharedMessage<CommonDiscardedEventsMessage<LibObjT>, LibObjT>;
- explicit CommonDiscardedEventsMessage(const _LibObjPtr libObjPtr) noexcept :
+ explicit CommonDiscardedEventsMessage(const LibObjPtr libObjPtr) noexcept :
_ThisCommonMessage {libObjPtr}
{
BT_ASSERT_DBG(this->isDiscardedEvents());
}
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
+ CommonDiscardedEventsMessage<LibObjT>
+ operator=(const CommonDiscardedEventsMessage<OtherLibObjT> val) noexcept
{
_ThisCommonMessage::operator=(val);
return *this;
}
- ConstStream stream() const noexcept
+ CommonDiscardedEventsMessage<const bt_message> asConst() const noexcept
{
- return ConstStream {internal::CommonDiscardedEventsMessageSpec<const bt_message>::stream(
- this->libObjPtr())};
+ return CommonDiscardedEventsMessage<const bt_message> {*this};
}
- _Stream stream() noexcept
+ _Stream stream() const noexcept
{
return _Stream {
internal::CommonDiscardedEventsMessageSpec<LibObjT>::stream(this->libObjPtr())};
}
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
+ {
+ return bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
+ this->libObjPtr());
+ }
+
ConstClockSnapshot beginningDefaultClockSnapshot() const noexcept
{
const auto libObjPtr =
return ConstClockSnapshot {libObjPtr};
}
- void count(const std::uint64_t count) noexcept
+ CommonDiscardedEventsMessage count(const std::uint64_t count) const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstDiscardedEventsMessage`.");
bt_message_discarded_events_set_count(this->libObjPtr(), count);
+ return *this;
}
- nonstd::optional<std::uint64_t> count() const noexcept
+ bt2s::optional<std::uint64_t> count() const noexcept
{
std::uint64_t count;
- const auto avail = bt_message_discarded_events_get_count(this->libObjPtr(), &count);
- if (avail) {
+ if (bt_message_discarded_events_get_count(this->libObjPtr(), &count)) {
return count;
}
- return nonstd::nullopt;
+ return bt2s::nullopt;
}
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
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;
class CommonDiscardedPacketsMessage final : public CommonMessage<LibObjT>
{
private:
- using typename CommonMessage<LibObjT>::_LibObjPtr;
using typename CommonMessage<LibObjT>::_ThisCommonMessage;
-
- using _Stream =
- typename std::conditional<std::is_const<LibObjT>::value, CommonStream<const bt_stream>,
- CommonStream<bt_stream>>::type;
+ using _Stream = internal::DepStream<LibObjT>;
public:
- using Shared = internal::SharedMessage<CommonDiscardedPacketsMessage<LibObjT>, LibObjT>;
+ using typename CommonMessage<LibObjT>::LibObjPtr;
+ using Shared = SharedMessage<CommonDiscardedPacketsMessage<LibObjT>, LibObjT>;
- explicit CommonDiscardedPacketsMessage(const _LibObjPtr libObjPtr) noexcept :
+ explicit CommonDiscardedPacketsMessage(const LibObjPtr libObjPtr) noexcept :
_ThisCommonMessage {libObjPtr}
{
BT_ASSERT_DBG(this->isDiscardedPackets());
}
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
+ CommonDiscardedPacketsMessage<LibObjT>
+ operator=(const CommonDiscardedPacketsMessage<OtherLibObjT> val) noexcept
{
_ThisCommonMessage::operator=(val);
return *this;
}
- ConstStream stream() const noexcept
+ CommonDiscardedPacketsMessage<const bt_message> asConst() const noexcept
{
- return ConstStream {internal::CommonDiscardedPacketsMessageSpec<const bt_message>::stream(
- this->libObjPtr())};
+ return CommonDiscardedPacketsMessage<const bt_message> {*this};
}
- _Stream stream() noexcept
+ _Stream stream() const noexcept
{
return _Stream {
internal::CommonDiscardedPacketsMessageSpec<LibObjT>::stream(this->libObjPtr())};
}
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
+ {
+ return bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(
+ this->libObjPtr());
+ }
+
ConstClockSnapshot beginningDefaultClockSnapshot() const noexcept
{
const auto libObjPtr =
return ConstClockSnapshot {libObjPtr};
}
- void count(const std::uint64_t count) noexcept
+ CommonDiscardedPacketsMessage count(const std::uint64_t count) const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstDiscardedPacketsMessage`.");
bt_message_discarded_packets_set_count(this->libObjPtr(), count);
+ return *this;
}
- nonstd::optional<std::uint64_t> count() const noexcept
+ bt2s::optional<std::uint64_t> count() const noexcept
{
std::uint64_t count;
- const auto avail = bt_message_discarded_packets_get_count(this->libObjPtr(), &count);
- if (avail) {
+ if (bt_message_discarded_packets_get_count(this->libObjPtr(), &count)) {
return count;
}
- return nonstd::nullopt;
+ return bt2s::nullopt;
}
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>
{
private:
- using typename CommonMessage<LibObjT>::_LibObjPtr;
using typename CommonMessage<LibObjT>::_ThisCommonMessage;
public:
- using Shared =
- internal::SharedMessage<CommonMessageIteratorInactivityMessage<LibObjT>, LibObjT>;
+ using typename CommonMessage<LibObjT>::LibObjPtr;
+ using Shared = SharedMessage<CommonMessageIteratorInactivityMessage<LibObjT>, LibObjT>;
- explicit CommonMessageIteratorInactivityMessage(const _LibObjPtr libObjPtr) noexcept :
+ explicit CommonMessageIteratorInactivityMessage(const LibObjPtr libObjPtr) noexcept :
_ThisCommonMessage {libObjPtr}
{
BT_ASSERT_DBG(this->isMessageIteratorInactivity());
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
+ CommonMessageIteratorInactivityMessage<LibObjT>
+ operator=(const CommonMessageIteratorInactivityMessage<OtherLibObjT> val) noexcept
{
_ThisCommonMessage::operator=(val);
return *this;
}
+ CommonMessageIteratorInactivityMessage<const bt_message> asConst() const noexcept
+ {
+ return CommonMessageIteratorInactivityMessage<const bt_message> {*this};
+ }
+
ConstClockSnapshot clockSnapshot() const noexcept
{
const auto libObjPtr =
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
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()};
}
template <typename LibObjT>
CommonStreamEndMessage<LibObjT> CommonMessage<LibObjT>::asStreamEnd() const noexcept
{
- BT_ASSERT_DBG(this->isStreamEnd());
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()};
}
template <typename LibObjT>
CommonPacketEndMessage<LibObjT> CommonMessage<LibObjT>::asPacketEnd() const noexcept
{
- BT_ASSERT_DBG(this->isPacketEnd());
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()};
}
template <typename LibObjT>
CommonDiscardedEventsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedEvents() const noexcept
{
- BT_ASSERT_DBG(this->isDiscardedEvents());
return CommonDiscardedEventsMessage<LibObjT> {this->libObjPtr()};
}
+template <typename LibObjT>
+CommonDiscardedPacketsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedPackets() const noexcept
+{
+ return CommonDiscardedPacketsMessage<LibObjT> {this->libObjPtr()};
+}
+
template <typename LibObjT>
CommonMessageIteratorInactivityMessage<LibObjT>
CommonMessage<LibObjT>::asMessageIteratorInactivity() const noexcept
{
- BT_ASSERT_DBG(this->isMessageIteratorInactivity());
return CommonMessageIteratorInactivityMessage<LibObjT> {this->libObjPtr()};
}