#include "borrowed-object.hpp"
#include "internal/utils.hpp"
+#include "optional-borrowed-object.hpp"
#include "shared-object.hpp"
+#include "trace-ir.hpp"
namespace bt2 {
namespace internal {
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>
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
internal::CommonStreamBeginningMessageSpec<LibObjT>::stream(this->libObjPtr())};
}
- void defaultClockSnapshot(const std::uint64_t val) const noexcept
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
+ {
+ 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;
}
- bt2s::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 bt2s::nullopt;
+ return {};
}
Shared shared() const noexcept
return _Stream {internal::CommonStreamEndMessageSpec<LibObjT>::stream(this->libObjPtr())};
}
- void defaultClockSnapshot(const std::uint64_t val) const 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,
"Not available with `bt2::ConstStreamEndMessage`.");
bt_message_stream_end_set_default_clock_snapshot(this->libObjPtr(), val);
+ return *this;
}
- bt2s::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 bt2s::nullopt;
+ return {};
}
Shared shared() const noexcept
internal::CommonPacketBeginningMessageSpec<LibObjT>::packet(this->libObjPtr())};
}
- void defaultClockSnapshot(const std::uint64_t val) const 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,
"Not available with `bt2::ConstPacketBeginningMessage`.");
bt_message_packet_beginning_set_default_clock_snapshot(this->libObjPtr(), val);
+ return *this;
}
ConstClockSnapshot defaultClockSnapshot() const noexcept
return _Packet {internal::CommonPacketEndMessageSpec<LibObjT>::packet(this->libObjPtr())};
}
- void defaultClockSnapshot(const std::uint64_t val) const 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,
"Not available with `bt2::ConstPacketEndMessage`.");
bt_message_packet_end_set_default_clock_snapshot(this->libObjPtr(), val);
+ return *this;
}
ConstClockSnapshot defaultClockSnapshot() const noexcept
return _Event {internal::CommonEventMessageSpec<LibObjT>::event(this->libObjPtr())};
}
- bt2s::optional<ConstClockClass> streamClassDefaultClockClass() const noexcept
+ OptionalBorrowedObject<ConstClockClass> streamClassDefaultClockClass() const noexcept
{
- if (const auto libClkClsPtr =
- bt_message_event_borrow_stream_class_default_clock_class_const(this->libObjPtr())) {
- return ConstClockClass {libClkClsPtr};
- }
-
- return bt2s::nullopt;
+ return bt_message_event_borrow_stream_class_default_clock_class_const(this->libObjPtr());
}
ConstClockSnapshot defaultClockSnapshot() const noexcept
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) const noexcept
+ CommonDiscardedEventsMessage count(const std::uint64_t count) const noexcept
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstDiscardedEventsMessage`.");
bt_message_discarded_events_set_count(this->libObjPtr(), count);
+ return *this;
}
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;
}
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) const noexcept
+ CommonDiscardedPacketsMessage count(const std::uint64_t count) const noexcept
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstDiscardedPacketsMessage`.");
bt_message_discarded_packets_set_count(this->libObjPtr(), count);
+ return *this;
}
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;
}
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
{
- BT_ASSERT_DBG(this->isDiscardedPackets());
return CommonDiscardedPacketsMessage<LibObjT> {this->libObjPtr()};
}
CommonMessageIteratorInactivityMessage<LibObjT>
CommonMessage<LibObjT>::asMessageIteratorInactivity() const noexcept
{
- BT_ASSERT_DBG(this->isMessageIteratorInactivity());
return CommonMessageIteratorInactivityMessage<LibObjT> {this->libObjPtr()};
}