X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcpp-common%2Fbt2%2Ftrace-ir.hpp;h=f27a87aee01e7b11ddc1bafd1d4c4b6090c38e2b;hb=c7e1be4b771715840b4bc3d635f72eeaf1d2e984;hp=3c8637cf5df0acfe1e4d956fa4cfd84cf6b13794;hpb=e1f49fd06b3b55ba81d5df0adddd18781b0940e6;p=babeltrace.git diff --git a/src/cpp-common/bt2/trace-ir.hpp b/src/cpp-common/bt2/trace-ir.hpp index 3c8637cf..f27a87ae 100644 --- a/src/cpp-common/bt2/trace-ir.hpp +++ b/src/cpp-common/bt2/trace-ir.hpp @@ -7,19 +7,20 @@ #ifndef BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP #define BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP -#include #include +#include + #include -#include "internal/borrowed-obj.hpp" #include "cpp-common/optional.hpp" #include "cpp-common/string_view.hpp" + #include "clock-class.hpp" -#include "clock-snapshot.hpp" #include "field-class.hpp" #include "field.hpp" -#include "value.hpp" +#include "internal/borrowed-obj.hpp" #include "internal/utils.hpp" +#include "value.hpp" namespace bt2 { @@ -49,7 +50,7 @@ namespace internal { template struct CommonEventSpec; -// Functions specific to mutable events +/* Functions specific to mutable events */ template <> struct CommonEventSpec final { @@ -84,7 +85,7 @@ struct CommonEventSpec final } }; -// Functions specific to constant events +/* Functions specific to constant events */ template <> struct CommonEventSpec final { @@ -119,7 +120,7 @@ struct CommonEventSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonEvent final : public internal::BorrowedObj @@ -151,12 +152,12 @@ public: } template - CommonEvent(const CommonEvent& event) noexcept : _ThisBorrowedObj {event} + CommonEvent(const CommonEvent event) noexcept : _ThisBorrowedObj {event} { } template - CommonEvent& operator=(const CommonEvent& event) noexcept + CommonEvent& operator=(const CommonEvent event) noexcept { _ThisBorrowedObj::operator=(event); return *this; @@ -171,7 +172,7 @@ public: nonstd::optional payloadField() const noexcept { - const auto libObjPtr = _ConstSpec::payloadField(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::payloadField(this->libObjPtr()); if (libObjPtr) { return ConstStructureField {libObjPtr}; @@ -182,7 +183,7 @@ public: nonstd::optional<_StructureField> payloadField() noexcept { - const auto libObjPtr = _Spec::payloadField(this->_libObjPtr()); + const auto libObjPtr = _Spec::payloadField(this->libObjPtr()); if (libObjPtr) { return _StructureField {libObjPtr}; @@ -193,7 +194,7 @@ public: nonstd::optional specificContextField() const noexcept { - const auto libObjPtr = _ConstSpec::specificContextField(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::specificContextField(this->libObjPtr()); if (libObjPtr) { return ConstStructureField {libObjPtr}; @@ -204,7 +205,7 @@ public: nonstd::optional<_StructureField> specificContextField() noexcept { - const auto libObjPtr = _Spec::specificContextField(this->_libObjPtr()); + const auto libObjPtr = _Spec::specificContextField(this->libObjPtr()); if (libObjPtr) { return _StructureField {libObjPtr}; @@ -215,7 +216,7 @@ public: nonstd::optional commonContextField() const noexcept { - const auto libObjPtr = _ConstSpec::commonContextField(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::commonContextField(this->libObjPtr()); if (libObjPtr) { return ConstStructureField {libObjPtr}; @@ -226,7 +227,7 @@ public: nonstd::optional<_StructureField> commonContextField() noexcept { - const auto libObjPtr = _Spec::commonContextField(this->_libObjPtr()); + const auto libObjPtr = _Spec::commonContextField(this->libObjPtr()); if (libObjPtr) { return _StructureField {libObjPtr}; @@ -241,6 +242,22 @@ using ConstEvent = CommonEvent; namespace internal { +struct EventTypeDescr +{ + using Const = ConstEvent; + using NonConst = Event; +}; + +template <> +struct TypeDescr : public EventTypeDescr +{ +}; + +template <> +struct TypeDescr : public EventTypeDescr +{ +}; + struct PacketRefFuncs final { static void get(const bt_packet * const libObjPtr) @@ -257,7 +274,7 @@ struct PacketRefFuncs final template struct CommonPacketSpec; -// Functions specific to mutable packets +/* Functions specific to mutable packets */ template <> struct CommonPacketSpec final { @@ -272,7 +289,7 @@ struct CommonPacketSpec final } }; -// Functions specific to constant packets +/* Functions specific to constant packets */ template <> struct CommonPacketSpec final { @@ -287,7 +304,7 @@ struct CommonPacketSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonPacket final : public internal::BorrowedObj @@ -314,12 +331,12 @@ public: } template - CommonPacket(const CommonPacket& packet) noexcept : _ThisBorrowedObj {packet} + CommonPacket(const CommonPacket packet) noexcept : _ThisBorrowedObj {packet} { } template - _ThisCommonPacket& operator=(const CommonPacket& packet) noexcept + _ThisCommonPacket& operator=(const CommonPacket packet) noexcept { _ThisBorrowedObj::operator=(packet); return *this; @@ -330,7 +347,7 @@ public: nonstd::optional contextField() const noexcept { - const auto libObjPtr = _ConstSpec::contextField(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::contextField(this->libObjPtr()); if (libObjPtr) { return ConstStructureField {libObjPtr}; @@ -341,7 +358,7 @@ public: nonstd::optional<_StructureField> contextField() noexcept { - const auto libObjPtr = _Spec::contextField(this->_libObjPtr()); + const auto libObjPtr = _Spec::contextField(this->libObjPtr()); if (libObjPtr) { return _StructureField {libObjPtr}; @@ -352,17 +369,37 @@ public: Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using Packet = CommonPacket; using ConstPacket = CommonPacket; +namespace internal { + +struct PacketTypeDescr +{ + using Const = ConstPacket; + using NonConst = Packet; +}; + +template <> +struct TypeDescr : public PacketTypeDescr +{ +}; + +template <> +struct TypeDescr : public PacketTypeDescr +{ +}; + +} /* namespace internal */ + template nonstd::optional CommonEvent::packet() const noexcept { - const auto libObjPtr = _ConstSpec::packet(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::packet(this->libObjPtr()); if (libObjPtr) { return ConstPacket {libObjPtr}; @@ -374,7 +411,7 @@ nonstd::optional CommonEvent::packet() const noexcept template nonstd::optional::_Packet> CommonEvent::packet() noexcept { - const auto libObjPtr = _Spec::packet(this->_libObjPtr()); + const auto libObjPtr = _Spec::packet(this->libObjPtr()); if (libObjPtr) { return _Packet {libObjPtr}; @@ -401,7 +438,7 @@ struct StreamRefFuncs final template struct CommonStreamSpec; -// Functions specific to mutable streams +/* Functions specific to mutable streams */ template <> struct CommonStreamSpec final { @@ -421,7 +458,7 @@ struct CommonStreamSpec final } }; -// Functions specific to constant streams +/* Functions specific to constant streams */ template <> struct CommonStreamSpec final { @@ -441,7 +478,7 @@ struct CommonStreamSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonStream final : public internal::BorrowedObj @@ -472,12 +509,12 @@ public: } template - CommonStream(const CommonStream& stream) noexcept : _ThisBorrowedObj {stream} + CommonStream(const CommonStream stream) noexcept : _ThisBorrowedObj {stream} { } template - _ThisCommonStream& operator=(const CommonStream& stream) noexcept + _ThisCommonStream& operator=(const CommonStream stream) noexcept { _ThisBorrowedObj::operator=(stream); return *this; @@ -487,10 +524,10 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_packet_create(this->_libObjPtr()); + const auto libObjPtr = bt_packet_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return Packet::Shared {Packet {libObjPtr}}; + return Packet::Shared::createWithoutRef(libObjPtr); } CommonStreamClass cls() const noexcept; @@ -500,17 +537,17 @@ public: std::uint64_t id() const noexcept { - return bt_stream_get_id(this->_libObjPtr()); + return bt_stream_get_id(this->libObjPtr()); } void name(const char * const name) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_stream_set_name(this->_libObjPtr(), name); + const auto status = bt_stream_set_name(this->libObjPtr(), name); if (status == BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } @@ -521,7 +558,7 @@ public: nonstd::optional name() const noexcept { - const auto name = bt_stream_get_name(this->_libObjPtr()); + const auto name = bt_stream_get_name(this->libObjPtr()); if (name) { return name; @@ -531,54 +568,74 @@ public: } template - void userAttributes(const CommonMapValue& userAttrs) + void userAttributes(const CommonMapValue userAttrs) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_stream_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); + bt_stream_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); } ConstMapValue userAttributes() const noexcept { - return ConstMapValue {_ConstSpec::userAttributes(this->_libObjPtr())}; + return ConstMapValue {_ConstSpec::userAttributes(this->libObjPtr())}; } UserAttributes userAttributes() noexcept { - return UserAttributes {_Spec::userAttributes(this->_libObjPtr())}; + return UserAttributes {_Spec::userAttributes(this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using Stream = CommonStream; using ConstStream = CommonStream; +namespace internal { + +struct StreamTypeDescr +{ + using Const = ConstStream; + using NonConst = Stream; +}; + +template <> +struct TypeDescr : public StreamTypeDescr +{ +}; + +template <> +struct TypeDescr : public StreamTypeDescr +{ +}; + +} /* namespace internal */ + template ConstStream CommonEvent::stream() const noexcept { - return ConstStream {_ConstSpec::stream(this->_libObjPtr())}; + return ConstStream {_ConstSpec::stream(this->libObjPtr())}; } template typename CommonEvent::_Stream CommonEvent::stream() noexcept { - return _Stream {_Spec::stream(this->_libObjPtr())}; + return _Stream {_Spec::stream(this->libObjPtr())}; } template ConstStream CommonPacket::stream() const noexcept { - return ConstStream {_ConstSpec::stream(this->_libObjPtr())}; + return ConstStream {_ConstSpec::stream(this->libObjPtr())}; } template typename CommonPacket::_Stream CommonPacket::stream() noexcept { - return _Stream {_Spec::stream(this->_libObjPtr())}; + return _Stream {_Spec::stream(this->libObjPtr())}; } namespace internal { @@ -599,7 +656,7 @@ struct TraceRefFuncs final template struct CommonTraceSpec; -// Functions specific to mutable traces +/* Functions specific to mutable traces */ template <> struct CommonTraceSpec final { @@ -624,7 +681,7 @@ struct CommonTraceSpec final } }; -// Functions specific to constant traces +/* Functions specific to constant traces */ template <> struct CommonTraceSpec final { @@ -651,12 +708,12 @@ struct CommonTraceSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonTrace final : public internal::BorrowedObj { - // Allow instantiate() to call `trace._libObjPtr()` + /* Allow instantiate() to call `trace.libObjPtr()` */ friend class CommonStreamClass; private: @@ -691,12 +748,12 @@ public: } template - CommonTrace(const CommonTrace& trace) noexcept : _ThisBorrowedObj {trace} + CommonTrace(const CommonTrace trace) noexcept : _ThisBorrowedObj {trace} { } template - _ThisCommonTrace& operator=(const CommonTrace& trace) noexcept + _ThisCommonTrace& operator=(const CommonTrace trace) noexcept { _ThisBorrowedObj::operator=(trace); return *this; @@ -709,10 +766,10 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_trace_set_name(this->_libObjPtr(), name); + const auto status = bt_trace_set_name(this->libObjPtr(), name); if (status == BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } @@ -723,7 +780,7 @@ public: nonstd::optional name() const noexcept { - const auto name = bt_trace_get_name(this->_libObjPtr()); + const auto name = bt_trace_get_name(this->libObjPtr()); if (name) { return name; @@ -732,14 +789,14 @@ public: return nonstd::nullopt; } - void uuid(const std::uint8_t * const uuid) noexcept + void uuid(const bt2_common::UuidView& uuid) noexcept { - bt_trace_set_uuid(this->_libObjPtr(), uuid); + bt_trace_set_uuid(this->libObjPtr(), uuid.begin()); } nonstd::optional uuid() const noexcept { - const auto uuid = bt_trace_get_uuid(this->_libObjPtr()); + const auto uuid = bt_trace_get_uuid(this->libObjPtr()); if (uuid) { return bt2_common::UuidView {uuid}; @@ -750,22 +807,22 @@ public: std::uint64_t size() const noexcept { - return bt_trace_get_stream_count(this->_libObjPtr()); + return bt_trace_get_stream_count(this->libObjPtr()); } ConstStream operator[](const std::uint64_t index) const noexcept { - return ConstStream {_ConstSpec::streamByIndex(this->_libObjPtr(), index)}; + return ConstStream {_ConstSpec::streamByIndex(this->libObjPtr(), index)}; } _Stream operator[](const std::uint64_t index) noexcept { - return _Stream {_Spec::streamByIndex(this->_libObjPtr(), index)}; + return _Stream {_Spec::streamByIndex(this->libObjPtr(), index)}; } nonstd::optional streamById(const std::uint64_t id) const noexcept { - const auto libObjPtr = _ConstSpec::streamById(this->_libObjPtr(), id); + const auto libObjPtr = _ConstSpec::streamById(this->libObjPtr(), id); if (libObjPtr) { return ConstStream {libObjPtr}; @@ -776,7 +833,7 @@ public: nonstd::optional<_Stream> streamById(const std::uint64_t id) noexcept { - const auto libObjPtr = _Spec::streamById(this->_libObjPtr(), id); + const auto libObjPtr = _Spec::streamById(this->libObjPtr(), id); if (libObjPtr) { return _Stream {libObjPtr}; @@ -789,10 +846,10 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_trace_set_environment_entry_integer(this->_libObjPtr(), name, val); + const auto status = bt_trace_set_environment_entry_integer(this->libObjPtr(), name, val); if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } @@ -805,10 +862,10 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_trace_set_environment_entry_string(this->_libObjPtr(), name, val); + const auto status = bt_trace_set_environment_entry_string(this->libObjPtr(), name, val); if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } @@ -829,7 +886,7 @@ public: std::uint64_t environmentSize() const noexcept { - return bt_trace_get_environment_entry_count(this->_libObjPtr()); + return bt_trace_get_environment_entry_count(this->libObjPtr()); } ConstEnvironmentEntry environmentEntry(const std::uint64_t index) const noexcept @@ -837,7 +894,7 @@ public: const char *name; const bt_value *libObjPtr; - bt_trace_borrow_environment_entry_by_index_const(this->_libObjPtr(), index, &name, + bt_trace_borrow_environment_entry_by_index_const(this->libObjPtr(), index, &name, &libObjPtr); return ConstEnvironmentEntry {name, ConstValue {libObjPtr}}; } @@ -845,7 +902,7 @@ public: nonstd::optional environmentEntry(const char * const name) const noexcept { const auto libObjPtr = - bt_trace_borrow_environment_entry_value_by_name_const(this->_libObjPtr(), name); + bt_trace_borrow_environment_entry_value_by_name_const(this->libObjPtr(), name); if (libObjPtr) { return ConstValue {libObjPtr}; @@ -860,42 +917,62 @@ public: } template - void userAttributes(const CommonMapValue& userAttrs) + void userAttributes(const CommonMapValue userAttrs) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_trace_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); + bt_trace_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); } ConstMapValue userAttributes() const noexcept { - return ConstMapValue {_ConstSpec::userAttributes(this->_libObjPtr())}; + return ConstMapValue {_ConstSpec::userAttributes(this->libObjPtr())}; } UserAttributes userAttributes() noexcept { - return UserAttributes {_Spec::userAttributes(this->_libObjPtr())}; + return UserAttributes {_Spec::userAttributes(this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using Trace = CommonTrace; using ConstTrace = CommonTrace; +namespace internal { + +struct TraceTypeDescr +{ + using Const = ConstTrace; + using NonConst = Trace; +}; + +template <> +struct TypeDescr : public TraceTypeDescr +{ +}; + +template <> +struct TypeDescr : public TraceTypeDescr +{ +}; + +} /* namespace internal */ + template ConstTrace CommonStream::trace() const noexcept { - return ConstTrace {_ConstSpec::trace(this->_libObjPtr())}; + return ConstTrace {_ConstSpec::trace(this->libObjPtr())}; } template typename CommonStream::_Trace CommonStream::trace() noexcept { - return _Trace {_Spec::trace(this->_libObjPtr())}; + return _Trace {_Spec::trace(this->libObjPtr())}; } namespace internal { @@ -916,7 +993,7 @@ struct EventClassRefFuncs final template struct CommonEventClassSpec; -// Functions specific to mutable event classes +/* Functions specific to mutable event classes */ template <> struct CommonEventClassSpec final { @@ -941,7 +1018,7 @@ struct CommonEventClassSpec final } }; -// Functions specific to constant event classes +/* Functions specific to constant event classes */ template <> struct CommonEventClassSpec final { @@ -967,7 +1044,7 @@ struct CommonEventClassSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonEventClass final : public internal::BorrowedObj @@ -999,13 +1076,13 @@ public: EMERGENCY = BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY, ALERT = BT_EVENT_CLASS_LOG_LEVEL_ALERT, CRITICAL = BT_EVENT_CLASS_LOG_LEVEL_CRITICAL, - ERROR = BT_EVENT_CLASS_LOG_LEVEL_ERROR, + ERR = BT_EVENT_CLASS_LOG_LEVEL_ERROR, WARNING = BT_EVENT_CLASS_LOG_LEVEL_WARNING, NOTICE = BT_EVENT_CLASS_LOG_LEVEL_NOTICE, INFO = BT_EVENT_CLASS_LOG_LEVEL_INFO, DEBUG_SYSTEM = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM, DEBUG_PROGRAM = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM, - DEBUG_PROCESS = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS, + DEBUG_PROC = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS, DEBUG_MODULE = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE, DEBUG_UNIT = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT, DEBUG_FUNCTION = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION, @@ -1018,13 +1095,13 @@ public: } template - CommonEventClass(const CommonEventClass& eventClass) noexcept : + CommonEventClass(const CommonEventClass eventClass) noexcept : _ThisBorrowedObj {eventClass} { } template - _ThisCommonEventClass& operator=(const CommonEventClass& eventClass) noexcept + _ThisCommonEventClass& operator=(const CommonEventClass eventClass) noexcept { _ThisBorrowedObj::operator=(eventClass); return *this; @@ -1035,17 +1112,17 @@ public: std::uint64_t id() const noexcept { - return bt_event_class_get_id(this->_libObjPtr()); + return bt_event_class_get_id(this->libObjPtr()); } void name(const char * const name) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_event_class_set_name(this->_libObjPtr(), name); + const auto status = bt_event_class_set_name(this->libObjPtr(), name); if (status == BT_EVENT_CLASS_SET_NAME_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } @@ -1056,7 +1133,7 @@ public: nonstd::optional name() const noexcept { - const auto name = bt_event_class_get_name(this->_libObjPtr()); + const auto name = bt_event_class_get_name(this->libObjPtr()); if (name) { return name; @@ -1069,14 +1146,14 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_event_class_set_log_level(this->_libObjPtr(), + bt_event_class_set_log_level(this->libObjPtr(), static_cast(logLevel)); } nonstd::optional logLevel() const noexcept { bt_event_class_log_level libLogLevel; - const auto avail = bt_event_class_get_log_level(this->_libObjPtr(), &libLogLevel); + const auto avail = bt_event_class_get_log_level(this->libObjPtr(), &libLogLevel); if (avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) { return static_cast(libLogLevel); @@ -1089,10 +1166,10 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_event_class_set_emf_uri(this->_libObjPtr(), emfUri); + const auto status = bt_event_class_set_emf_uri(this->libObjPtr(), emfUri); if (status == BT_EVENT_CLASS_SET_EMF_URI_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } @@ -1103,7 +1180,7 @@ public: nonstd::optional emfUri() const noexcept { - const auto emfUri = bt_event_class_get_emf_uri(this->_libObjPtr()); + const auto emfUri = bt_event_class_get_emf_uri(this->libObjPtr()); if (emfUri) { return emfUri; @@ -1112,21 +1189,21 @@ public: return nonstd::nullopt; } - void payloadFieldClass(const StructureFieldClass& fc) + void payloadFieldClass(const StructureFieldClass fc) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto status = - bt_event_class_set_payload_field_class(this->_libObjPtr(), fc._libObjPtr()); + bt_event_class_set_payload_field_class(this->libObjPtr(), fc.libObjPtr()); if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } nonstd::optional payloadFieldClass() const noexcept { - const auto libObjPtr = _ConstSpec::payloadFieldClass(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::payloadFieldClass(this->libObjPtr()); if (libObjPtr) { return ConstStructureFieldClass {libObjPtr}; @@ -1137,7 +1214,7 @@ public: nonstd::optional<_StructureFieldClass> payloadFieldClass() noexcept { - const auto libObjPtr = _Spec::payloadFieldClass(this->_libObjPtr()); + const auto libObjPtr = _Spec::payloadFieldClass(this->libObjPtr()); if (libObjPtr) { return _StructureFieldClass {libObjPtr}; @@ -1146,21 +1223,21 @@ public: return nonstd::nullopt; } - void specificContextFieldClass(const StructureFieldClass& fc) + void specificContextFieldClass(const StructureFieldClass fc) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto status = - bt_event_class_set_specific_context_field_class(this->_libObjPtr(), fc._libObjPtr()); + bt_event_class_set_specific_context_field_class(this->libObjPtr(), fc.libObjPtr()); if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } nonstd::optional specificContextFieldClass() const noexcept { - const auto libObjPtr = _ConstSpec::specificContextFieldClass(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::specificContextFieldClass(this->libObjPtr()); if (libObjPtr) { return ConstStructureFieldClass {libObjPtr}; @@ -1171,7 +1248,7 @@ public: nonstd::optional<_StructureFieldClass> specificContextFieldClass() noexcept { - const auto libObjPtr = _Spec::specificContextFieldClass(this->_libObjPtr()); + const auto libObjPtr = _Spec::specificContextFieldClass(this->libObjPtr()); if (libObjPtr) { return _StructureFieldClass {libObjPtr}; @@ -1181,42 +1258,62 @@ public: } template - void userAttributes(const CommonMapValue& userAttrs) + void userAttributes(const CommonMapValue userAttrs) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_event_class_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); + bt_event_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); } ConstMapValue userAttributes() const noexcept { - return ConstMapValue {_ConstSpec::userAttributes(this->_libObjPtr())}; + return ConstMapValue {_ConstSpec::userAttributes(this->libObjPtr())}; } UserAttributes userAttributes() noexcept { - return UserAttributes {_Spec::userAttributes(this->_libObjPtr())}; + return UserAttributes {_Spec::userAttributes(this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using EventClass = CommonEventClass; using ConstEventClass = CommonEventClass; +namespace internal { + +struct EventClassTypeDescr +{ + using Const = ConstEventClass; + using NonConst = EventClass; +}; + +template <> +struct TypeDescr : public EventClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public EventClassTypeDescr +{ +}; + +} /* namespace internal */ + template ConstEventClass CommonEvent::cls() const noexcept { - return ConstEventClass {_ConstSpec::cls(this->_libObjPtr())}; + return ConstEventClass {_ConstSpec::cls(this->libObjPtr())}; } template typename CommonEvent::Class CommonEvent::cls() noexcept { - return Class {_Spec::cls(this->_libObjPtr())}; + return Class {_Spec::cls(this->libObjPtr())}; } namespace internal { @@ -1237,7 +1334,7 @@ struct StreamClassRefFuncs final template struct CommonStreamClassSpec; -// Functions specific to mutable stream classes +/* Functions specific to mutable stream classes */ template <> struct CommonStreamClassSpec final { @@ -1279,7 +1376,7 @@ struct CommonStreamClassSpec final } }; -// Functions specific to constant stream classes +/* Functions specific to constant stream classes */ template <> struct CommonStreamClassSpec final { @@ -1323,7 +1420,7 @@ struct CommonStreamClassSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonStreamClass final : public internal::BorrowedObj @@ -1362,56 +1459,56 @@ public: } template - CommonStreamClass(const CommonStreamClass& streamClass) noexcept : + CommonStreamClass(const CommonStreamClass streamClass) noexcept : _ThisBorrowedObj {streamClass} { } template - _ThisCommonStreamClass& operator=(const CommonStreamClass& streamClass) noexcept + _ThisCommonStreamClass& operator=(const CommonStreamClass streamClass) noexcept { _ThisBorrowedObj::operator=(streamClass); return *this; } - Stream::Shared instantiate(const Trace& trace) + Stream::Shared instantiate(const Trace trace) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_stream_create(this->_libObjPtr(), trace._libObjPtr()); + const auto libObjPtr = bt_stream_create(this->libObjPtr(), trace.libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return Stream::Shared {Stream {libObjPtr}}; + return Stream::Shared::createWithoutRef(libObjPtr); } - Stream::Shared instantiate(const Trace& trace, const std::uint64_t id) + Stream::Shared instantiate(const Trace trace, const std::uint64_t id) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_stream_create_with_id(this->_libObjPtr(), trace._libObjPtr(), id); + const auto libObjPtr = bt_stream_create_with_id(this->libObjPtr(), trace.libObjPtr(), id); internal::validateCreatedObjPtr(libObjPtr); - return Stream::Shared {Stream {libObjPtr}}; + return Stream::Shared::createWithoutRef(libObjPtr); } EventClass::Shared createEventClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_event_class_create(this->_libObjPtr()); + const auto libObjPtr = bt_event_class_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return EventClass::Shared {EventClass {libObjPtr}}; + return EventClass::Shared::createWithoutRef(libObjPtr); } EventClass::Shared createEventClass(const std::uint64_t id) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_event_class_create_with_id(this->_libObjPtr(), id); + const auto libObjPtr = bt_event_class_create_with_id(this->libObjPtr(), id); internal::validateCreatedObjPtr(libObjPtr); - return EventClass::Shared {EventClass {libObjPtr}}; + return EventClass::Shared::createWithoutRef(libObjPtr); } CommonTraceClass traceClass() const noexcept; @@ -1419,17 +1516,17 @@ public: std::uint64_t id() const noexcept { - return bt_stream_class_get_id(this->_libObjPtr()); + return bt_stream_class_get_id(this->libObjPtr()); } void name(const char * const name) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_stream_class_set_name(this->_libObjPtr(), name); + const auto status = bt_stream_class_set_name(this->libObjPtr(), name); if (status == BT_STREAM_CLASS_SET_NAME_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } @@ -1440,7 +1537,7 @@ public: nonstd::optional name() const noexcept { - const auto name = bt_stream_class_get_name(this->_libObjPtr()); + const auto name = bt_stream_class_get_name(this->libObjPtr()); if (name) { return name; @@ -1453,27 +1550,27 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_stream_class_set_assigns_automatic_event_class_id(this->_libObjPtr(), + bt_stream_class_set_assigns_automatic_event_class_id(this->libObjPtr(), static_cast(val)); } bool assignsAutomaticEventClassId() const noexcept { return static_cast( - bt_stream_class_assigns_automatic_event_class_id(this->_libObjPtr())); + bt_stream_class_assigns_automatic_event_class_id(this->libObjPtr())); } void assignsAutomaticStreamId(const bool val) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_stream_class_set_assigns_automatic_stream_id(this->_libObjPtr(), + bt_stream_class_set_assigns_automatic_stream_id(this->libObjPtr(), static_cast(val)); } bool assignsAutomaticStreamId() const noexcept { - return static_cast(bt_stream_class_assigns_automatic_stream_id(this->_libObjPtr())); + return static_cast(bt_stream_class_assigns_automatic_stream_id(this->libObjPtr())); } void supportsPackets(const bool supportsPackets, const bool withBeginningDefaultClkSnapshot, @@ -1481,7 +1578,7 @@ public: { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_stream_class_set_supports_packets(this->_libObjPtr(), + bt_stream_class_set_supports_packets(this->libObjPtr(), static_cast(supportsPackets), static_cast(withBeginningDefaultClkSnapshot), static_cast(withEndDefaultClkSnapshot)); @@ -1489,19 +1586,19 @@ public: bool supportsPackets() const noexcept { - return static_cast(bt_stream_class_supports_packets(this->_libObjPtr())); + return static_cast(bt_stream_class_supports_packets(this->libObjPtr())); } bool packetsHaveBeginningClockSnapshot() const noexcept { return static_cast( - bt_stream_class_packets_have_beginning_default_clock_snapshot(this->_libObjPtr())); + bt_stream_class_packets_have_beginning_default_clock_snapshot(this->libObjPtr())); } bool packetsHaveEndClockSnapshot() const noexcept { return static_cast( - bt_stream_class_packets_have_end_default_clock_snapshot(this->_libObjPtr())); + bt_stream_class_packets_have_end_default_clock_snapshot(this->libObjPtr())); } void supportsDiscardedEvents(const bool supportsDiscardedEvents, @@ -1510,19 +1607,19 @@ public: static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); bt_stream_class_set_supports_discarded_events( - this->_libObjPtr(), static_cast(supportsPackets), + this->libObjPtr(), static_cast(supportsDiscardedEvents), static_cast(withDefaultClkSnapshots)); } bool supportsDiscardedEvents() const noexcept { - return static_cast(bt_stream_class_supports_discarded_events(this->_libObjPtr())); + return static_cast(bt_stream_class_supports_discarded_events(this->libObjPtr())); } bool discardedEventsHaveDefaultClockSnapshots() const noexcept { return static_cast( - bt_stream_class_discarded_events_have_default_clock_snapshots(this->_libObjPtr())); + bt_stream_class_discarded_events_have_default_clock_snapshots(this->libObjPtr())); } void supportsDiscardedPackets(const bool supportsDiscardedPackets, @@ -1531,34 +1628,34 @@ public: static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); bt_stream_class_set_supports_discarded_packets( - this->_libObjPtr(), static_cast(supportsPackets), + this->libObjPtr(), static_cast(supportsDiscardedPackets), static_cast(withDefaultClkSnapshots)); } bool supportsDiscardedPackets() const noexcept { - return static_cast(bt_stream_class_supports_discarded_packets(this->_libObjPtr())); + return static_cast(bt_stream_class_supports_discarded_packets(this->libObjPtr())); } bool discardedPacketsHaveDefaultClockSnapshots() const noexcept { return static_cast( - bt_stream_class_discarded_packets_have_default_clock_snapshots(this->_libObjPtr())); + bt_stream_class_discarded_packets_have_default_clock_snapshots(this->libObjPtr())); } - void defaultClockClass(const ClockClass& clkCls) + void defaultClockClass(const ClockClass clkCls) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto status = - bt_stream_class_set_default_clock_class(this->_libObjPtr(), clkCls._libObjPtr()); + bt_stream_class_set_default_clock_class(this->libObjPtr(), clkCls.libObjPtr()); BT_ASSERT(status == BT_STREAM_CLASS_SET_DEFAULT_CLOCK_CLASS_STATUS_OK); } nonstd::optional defaultClockClass() const noexcept { - const auto libObjPtr = _ConstSpec::defaultClockClass(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::defaultClockClass(this->libObjPtr()); if (libObjPtr) { return ConstClockClass {libObjPtr}; @@ -1569,7 +1666,7 @@ public: nonstd::optional<_ClockClass> defaultClockClass() noexcept { - const auto libObjPtr = _Spec::defaultClockClass(this->_libObjPtr()); + const auto libObjPtr = _Spec::defaultClockClass(this->libObjPtr()); if (libObjPtr) { return _ClockClass {libObjPtr}; @@ -1580,22 +1677,22 @@ public: std::uint64_t size() const noexcept { - return bt_stream_class_get_event_class_count(this->_libObjPtr()); + return bt_stream_class_get_event_class_count(this->libObjPtr()); } ConstEventClass operator[](const std::uint64_t index) const noexcept { - return ConstEventClass {_ConstSpec::eventClassByIndex(this->_libObjPtr(), index)}; + return ConstEventClass {_ConstSpec::eventClassByIndex(this->libObjPtr(), index)}; } _EventClass operator[](const std::uint64_t index) noexcept { - return _EventClass {_Spec::eventClassByIndex(this->_libObjPtr(), index)}; + return _EventClass {_Spec::eventClassByIndex(this->libObjPtr(), index)}; } nonstd::optional eventClassById(const std::uint64_t id) const noexcept { - const auto libObjPtr = _ConstSpec::eventClassById(this->_libObjPtr(), id); + const auto libObjPtr = _ConstSpec::eventClassById(this->libObjPtr(), id); if (libObjPtr) { return ConstEventClass {libObjPtr}; @@ -1606,7 +1703,7 @@ public: nonstd::optional<_EventClass> eventClassById(const std::uint64_t id) noexcept { - const auto libObjPtr = _Spec::eventClassById(this->_libObjPtr(), id); + const auto libObjPtr = _Spec::eventClassById(this->libObjPtr(), id); if (libObjPtr) { return _EventClass {libObjPtr}; @@ -1615,21 +1712,21 @@ public: return nonstd::nullopt; } - void packetContextFieldClass(const StructureFieldClass& fc) + void packetContextFieldClass(const StructureFieldClass fc) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto status = - bt_stream_class_set_packet_context_field_class(this->_libObjPtr(), fc._libObjPtr()); + bt_stream_class_set_packet_context_field_class(this->libObjPtr(), fc.libObjPtr()); - if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) { + throw MemoryError {}; } } nonstd::optional packetContextFieldClass() const noexcept { - const auto libObjPtr = _ConstSpec::packetContextFieldClass(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::packetContextFieldClass(this->libObjPtr()); if (libObjPtr) { return ConstStructureFieldClass {libObjPtr}; @@ -1640,7 +1737,7 @@ public: nonstd::optional<_StructureFieldClass> packetContextFieldClass() noexcept { - const auto libObjPtr = _Spec::packetContextFieldClass(this->_libObjPtr()); + const auto libObjPtr = _Spec::packetContextFieldClass(this->libObjPtr()); if (libObjPtr) { return _StructureFieldClass {libObjPtr}; @@ -1649,21 +1746,21 @@ public: return nonstd::nullopt; } - void eventCommonContextFieldClass(const StructureFieldClass& fc) + void eventCommonContextFieldClass(const StructureFieldClass fc) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto status = bt_stream_class_set_event_common_context_field_class(this->_libObjPtr(), - fc._libObjPtr()); + const auto status = + bt_stream_class_set_event_common_context_field_class(this->libObjPtr(), fc.libObjPtr()); - if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) { + throw MemoryError {}; } } nonstd::optional eventCommonContextFieldClass() const noexcept { - const auto libObjPtr = _ConstSpec::eventCommonContextFieldClass(this->_libObjPtr()); + const auto libObjPtr = _ConstSpec::eventCommonContextFieldClass(this->libObjPtr()); if (libObjPtr) { return ConstStructureFieldClass {libObjPtr}; @@ -1674,7 +1771,7 @@ public: nonstd::optional<_StructureFieldClass> eventCommonContextFieldClass() noexcept { - const auto libObjPtr = _Spec::eventCommonContextFieldClass(this->_libObjPtr()); + const auto libObjPtr = _Spec::eventCommonContextFieldClass(this->libObjPtr()); if (libObjPtr) { return _StructureFieldClass {libObjPtr}; @@ -1684,54 +1781,74 @@ public: } template - void userAttributes(const CommonMapValue& userAttrs) + void userAttributes(const CommonMapValue userAttrs) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_stream_class_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); + bt_stream_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); } ConstMapValue userAttributes() const noexcept { - return ConstMapValue {_ConstSpec::userAttributes(this->_libObjPtr())}; + return ConstMapValue {_ConstSpec::userAttributes(this->libObjPtr())}; } UserAttributes userAttributes() noexcept { - return UserAttributes {_Spec::userAttributes(this->_libObjPtr())}; + return UserAttributes {_Spec::userAttributes(this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using StreamClass = CommonStreamClass; using ConstStreamClass = CommonStreamClass; +namespace internal { + +struct StreamClassTypeDescr +{ + using Const = ConstStreamClass; + using NonConst = StreamClass; +}; + +template <> +struct TypeDescr : public StreamClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public StreamClassTypeDescr +{ +}; + +} /* namespace internal */ + template ConstStreamClass CommonEventClass::streamClass() const noexcept { - return ConstStreamClass {_ConstSpec::streamClass(this->_libObjPtr())}; + return ConstStreamClass {_ConstSpec::streamClass(this->libObjPtr())}; } template typename CommonEventClass::_StreamClass CommonEventClass::streamClass() noexcept { - return _StreamClass {_Spec::streamClass(this->_libObjPtr())}; + return _StreamClass {_Spec::streamClass(this->libObjPtr())}; } template ConstStreamClass CommonStream::cls() const noexcept { - return ConstStreamClass {_ConstSpec::cls(this->_libObjPtr())}; + return ConstStreamClass {_ConstSpec::cls(this->libObjPtr())}; } template typename CommonStream::Class CommonStream::cls() noexcept { - return Class {_Spec::cls(this->_libObjPtr())}; + return Class {_Spec::cls(this->libObjPtr())}; } namespace internal { @@ -1752,7 +1869,7 @@ struct TraceClassRefFuncs final template struct CommonTraceClassSpec; -// Functions specific to mutable stream classes +/* Functions specific to mutable stream classes */ template <> struct CommonTraceClassSpec final { @@ -1774,7 +1891,7 @@ struct CommonTraceClassSpec final } }; -// Functions specific to constant stream classes +/* Functions specific to constant stream classes */ template <> struct CommonTraceClassSpec final { @@ -1796,7 +1913,7 @@ struct CommonTraceClassSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonTraceClass final : public internal::BorrowedObj @@ -1824,301 +1941,294 @@ public: } template - CommonTraceClass(const CommonTraceClass& traceClass) noexcept : + CommonTraceClass(const CommonTraceClass traceClass) noexcept : _ThisBorrowedObj {traceClass} { } template - _ThisCommonTraceClass& operator=(const CommonTraceClass& traceClass) noexcept + _ThisCommonTraceClass& operator=(const CommonTraceClass traceClass) noexcept { _ThisBorrowedObj::operator=(traceClass); return *this; } - Trace::Shared instantiate(const Trace& trace) + Trace::Shared instantiate() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_trace_create(this->_libObjPtr()); + const auto libObjPtr = bt_trace_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return Trace::Shared {Trace {libObjPtr}}; + return Trace::Shared::createWithoutRef(libObjPtr); } StreamClass::Shared createStreamClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_stream_class_create(this->_libObjPtr()); + const auto libObjPtr = bt_stream_class_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return StreamClass::Shared {StreamClass {libObjPtr}}; + return StreamClass::Shared::createWithoutRef(libObjPtr); } StreamClass::Shared createStreamClass(const std::uint64_t id) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_stream_class_create_with_id(this->_libObjPtr(), id); + const auto libObjPtr = bt_stream_class_create_with_id(this->libObjPtr(), id); internal::validateCreatedObjPtr(libObjPtr); - return StreamClass::Shared {StreamClass {libObjPtr}}; + return StreamClass::Shared::createWithoutRef(libObjPtr); } FieldClass::Shared createBoolFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_bool_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_bool_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return FieldClass::Shared {FieldClass {libObjPtr}}; + return FieldClass::Shared::createWithoutRef(libObjPtr); } BitArrayFieldClass::Shared createBitArrayFieldClass(const std::uint64_t length) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_bit_array_create(this->_libObjPtr(), length); + const auto libObjPtr = bt_field_class_bit_array_create(this->libObjPtr(), length); internal::validateCreatedObjPtr(libObjPtr); - return BitArrayFieldClass::Shared {BitArrayFieldClass {libObjPtr}}; + return BitArrayFieldClass::Shared::createWithoutRef(libObjPtr); } IntegerFieldClass::Shared createUnsignedIntegerFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_integer_unsigned_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_integer_unsigned_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return IntegerFieldClass::Shared {IntegerFieldClass {libObjPtr}}; + return IntegerFieldClass::Shared::createWithoutRef(libObjPtr); } IntegerFieldClass::Shared createSignedIntegerFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_integer_signed_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_integer_signed_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return IntegerFieldClass::Shared {IntegerFieldClass {libObjPtr}}; + return IntegerFieldClass::Shared::createWithoutRef(libObjPtr); } UnsignedEnumerationFieldClass::Shared createUnsignedEnumerationFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_enumeration_unsigned_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_enumeration_unsigned_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return UnsignedEnumerationFieldClass::Shared {UnsignedEnumerationFieldClass {libObjPtr}}; + return UnsignedEnumerationFieldClass::Shared::createWithoutRef(libObjPtr); } SignedEnumerationFieldClass::Shared createSignedEnumerationFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_enumeration_signed_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_enumeration_signed_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return SignedEnumerationFieldClass::Shared {SignedEnumerationFieldClass {libObjPtr}}; + return SignedEnumerationFieldClass::Shared::createWithoutRef(libObjPtr); } FieldClass::Shared createSinglePrecisionRealFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_real_single_precision_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_real_single_precision_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return FieldClass::Shared {FieldClass {libObjPtr}}; + return FieldClass::Shared::createWithoutRef(libObjPtr); } FieldClass::Shared createDoublePrecisionRealFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_real_double_precision_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_real_double_precision_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return FieldClass::Shared {FieldClass {libObjPtr}}; + return FieldClass::Shared::createWithoutRef(libObjPtr); } FieldClass::Shared createStringFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_string_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_string_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return FieldClass::Shared {FieldClass {libObjPtr}}; + return FieldClass::Shared::createWithoutRef(libObjPtr); } - StaticArrayFieldClass::Shared createStaticArrayFieldClass(const FieldClass& elementFieldClass, + StaticArrayFieldClass::Shared createStaticArrayFieldClass(const FieldClass elementFieldClass, const std::uint64_t length) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto libObjPtr = bt_field_class_array_static_create( - this->_libObjPtr(), elementFieldClass._libObjPtr(), length); + this->libObjPtr(), elementFieldClass.libObjPtr(), length); internal::validateCreatedObjPtr(libObjPtr); - return StaticArrayFieldClass::Shared {StaticArrayFieldClass {libObjPtr}}; + return StaticArrayFieldClass::Shared::createWithoutRef(libObjPtr); } - ArrayFieldClass::Shared createDynamicArrayFieldClass(const FieldClass& elementFieldClass) + ArrayFieldClass::Shared createDynamicArrayFieldClass(const FieldClass elementFieldClass) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto libObjPtr = bt_field_class_array_dynamic_create( - this->_libObjPtr(), elementFieldClass._libObjPtr(), nullptr); + this->libObjPtr(), elementFieldClass.libObjPtr(), nullptr); internal::validateCreatedObjPtr(libObjPtr); - return ArrayFieldClass::Shared {ArrayFieldClass {libObjPtr}}; + return ArrayFieldClass::Shared::createWithoutRef(libObjPtr); } DynamicArrayWithLengthFieldClass::Shared - createDynamicArrayFieldClass(const FieldClass& elementFieldClass, - const IntegerFieldClass& lengthFieldClass) + createDynamicArrayFieldClass(const FieldClass elementFieldClass, + const IntegerFieldClass lengthFieldClass) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto libObjPtr = bt_field_class_array_dynamic_create( - this->_libObjPtr(), elementFieldClass._libObjPtr(), lengthFieldClass._libObjPtr()); + this->libObjPtr(), elementFieldClass.libObjPtr(), lengthFieldClass.libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return DynamicArrayWithLengthFieldClass::Shared { - DynamicArrayWithLengthFieldClass {libObjPtr}}; + return DynamicArrayWithLengthFieldClass::Shared::createWithoutRef(libObjPtr); } - StructureFieldClass::Shared createStructureFieldClass(const std::uint64_t length) + StructureFieldClass::Shared createStructureFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_structure_create(this->_libObjPtr(), length); + const auto libObjPtr = bt_field_class_structure_create(this->libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return StructureFieldClass::Shared {StructureFieldClass {libObjPtr}}; + return StructureFieldClass::Shared::createWithoutRef(libObjPtr); } - OptionFieldClass::Shared createOptionFieldClass(const FieldClass& optionalFieldClass) + OptionFieldClass::Shared createOptionFieldClass(const FieldClass optionalFieldClass) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto libObjPtr = bt_field_class_option_without_selector_create( - this->_libObjPtr(), optionalFieldClass._libObjPtr()); + this->libObjPtr(), optionalFieldClass.libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return OptionFieldClass::Shared {OptionFieldClass {libObjPtr}}; + return OptionFieldClass::Shared::createWithoutRef(libObjPtr); } OptionWithBoolSelectorFieldClass::Shared - createOptionWithBoolSelectorFieldClass(const FieldClass& optionalFieldClass, - const FieldClass& selectorFieldClass) + createOptionWithBoolSelectorFieldClass(const FieldClass optionalFieldClass, + const FieldClass selectorFieldClass) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto libObjPtr = bt_field_class_option_with_selector_field_bool_create( - this->_libObjPtr(), optionalFieldClass._libObjPtr(), selectorFieldClass._libObjPtr()); + this->libObjPtr(), optionalFieldClass.libObjPtr(), selectorFieldClass.libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return OptionWithBoolSelectorFieldClass::Shared { - OptionWithBoolSelectorFieldClass {libObjPtr}}; + return OptionWithBoolSelectorFieldClass::Shared::createWithoutRef(libObjPtr); } OptionWithUnsignedIntegerSelectorFieldClass::Shared - createOptionWithUnsignedIntegerSelectorFieldClass(const FieldClass& optionalFieldClass, - const IntegerFieldClass& selectorFieldClass, - const ConstUnsignedIntegerRangeSet& ranges) + createOptionWithUnsignedIntegerSelectorFieldClass(const FieldClass optionalFieldClass, + const IntegerFieldClass selectorFieldClass, + const ConstUnsignedIntegerRangeSet ranges) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto libObjPtr = bt_field_class_option_with_selector_field_integer_unsigned_create( - this->_libObjPtr(), optionalFieldClass._libObjPtr(), selectorFieldClass._libObjPtr(), - ranges._libObjPtr()); + this->libObjPtr(), optionalFieldClass.libObjPtr(), selectorFieldClass.libObjPtr(), + ranges.libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return OptionWithUnsignedIntegerSelectorFieldClass::Shared { - OptionWithUnsignedIntegerSelectorFieldClass {libObjPtr}}; + return OptionWithUnsignedIntegerSelectorFieldClass::Shared::createWithoutRef(libObjPtr); } OptionWithSignedIntegerSelectorFieldClass::Shared - createOptionWithSignedIntegerSelectorFieldClass(const FieldClass& optionalFieldClass, - const IntegerFieldClass& selectorFieldClass, - const ConstSignedIntegerRangeSet& ranges) + createOptionWithSignedIntegerSelectorFieldClass(const FieldClass optionalFieldClass, + const IntegerFieldClass selectorFieldClass, + const ConstSignedIntegerRangeSet ranges) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto libObjPtr = bt_field_class_option_with_selector_field_integer_signed_create( - this->_libObjPtr(), optionalFieldClass._libObjPtr(), selectorFieldClass._libObjPtr(), - ranges._libObjPtr()); + this->libObjPtr(), optionalFieldClass.libObjPtr(), selectorFieldClass.libObjPtr(), + ranges.libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return OptionWithSignedIntegerSelectorFieldClass::Shared { - OptionWithSignedIntegerSelectorFieldClass {libObjPtr}}; + return OptionWithSignedIntegerSelectorFieldClass::Shared::createWithoutRef(libObjPtr); } VariantWithoutSelectorFieldClass::Shared createVariantFieldClass() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_variant_create(this->_libObjPtr()); + const auto libObjPtr = bt_field_class_variant_create(this->libObjPtr(), nullptr); internal::validateCreatedObjPtr(libObjPtr); - return VariantWithoutSelectorFieldClass::Shared { - VariantWithoutSelectorFieldClass {libObjPtr}}; + return VariantWithoutSelectorFieldClass::Shared::createWithoutRef(libObjPtr); } VariantWithUnsignedIntegerSelectorFieldClass::Shared - createVariantWithUnsignedIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass) + createVariantWithUnsignedIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass) { - return VariantWithUnsignedIntegerSelectorFieldClass::Shared { - VariantWithUnsignedIntegerSelectorFieldClass { - this->_createVariantWithIntegerSelectorFieldClass(selectorFieldClass)}}; + return this->_createVariantWithIntegerSelectorFieldClass< + VariantWithUnsignedIntegerSelectorFieldClass>(selectorFieldClass); } VariantWithSignedIntegerSelectorFieldClass::Shared - createVariantWithSignedIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass) + createVariantWithSignedIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass) { - return VariantWithSignedIntegerSelectorFieldClass::Shared { - VariantWithSignedIntegerSelectorFieldClass { - this->_createVariantWithIntegerSelectorFieldClass(selectorFieldClass)}}; + return this->_createVariantWithIntegerSelectorFieldClass< + VariantWithSignedIntegerSelectorFieldClass>(selectorFieldClass); } void assignsAutomaticStreamClassId(const bool val) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_trace_class_set_assigns_automatic_stream_class_id(this->_libObjPtr(), + bt_trace_class_set_assigns_automatic_stream_class_id(this->libObjPtr(), static_cast(val)); } bool assignsAutomaticStreamClassId() const noexcept { return static_cast( - bt_trace_class_assigns_automatic_stream_class_id(this->_libObjPtr())); + bt_trace_class_assigns_automatic_stream_class_id(this->libObjPtr())); } std::uint64_t size() const noexcept { - return bt_trace_class_get_stream_class_count(this->_libObjPtr()); + return bt_trace_class_get_stream_class_count(this->libObjPtr()); } ConstStreamClass operator[](const std::uint64_t index) const noexcept { - return ConstStreamClass {_ConstSpec::streamClassByIndex(this->_libObjPtr(), index)}; + return ConstStreamClass {_ConstSpec::streamClassByIndex(this->libObjPtr(), index)}; } _StreamClass operator[](const std::uint64_t index) noexcept { - return _StreamClass {_Spec::streamClassByIndex(this->_libObjPtr(), index)}; + return _StreamClass {_Spec::streamClassByIndex(this->libObjPtr(), index)}; } nonstd::optional streamClassById(const std::uint64_t id) const noexcept { - const auto libObjPtr = _ConstSpec::streamClassById(this->_libObjPtr(), id); + const auto libObjPtr = _ConstSpec::streamClassById(this->libObjPtr(), id); if (libObjPtr) { return ConstStreamClass {libObjPtr}; @@ -2129,7 +2239,7 @@ public: nonstd::optional<_StreamClass> streamClassById(const std::uint64_t id) noexcept { - const auto libObjPtr = _Spec::streamClassById(this->_libObjPtr(), id); + const auto libObjPtr = _Spec::streamClassById(this->libObjPtr(), id); if (libObjPtr) { return _StreamClass {libObjPtr}; @@ -2139,69 +2249,90 @@ public: } template - void userAttributes(const CommonMapValue& userAttrs) + void userAttributes(const CommonMapValue userAttrs) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - bt_trace_class_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); + bt_trace_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); } ConstMapValue userAttributes() const noexcept { - return ConstMapValue {_ConstSpec::userAttributes(this->_libObjPtr())}; + return ConstMapValue {_ConstSpec::userAttributes(this->libObjPtr())}; } UserAttributes userAttributes() noexcept { - return UserAttributes {_Spec::userAttributes(this->_libObjPtr())}; + return UserAttributes {_Spec::userAttributes(this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } private: - bt_field_class * - _createVariantWithIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass) + template + typename ObjT::Shared + _createVariantWithIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); const auto libObjPtr = - bt_field_class_variant_create(this->_libObjPtr(), selectorFieldClass._libObjPtr()); + bt_field_class_variant_create(this->libObjPtr(), selectorFieldClass.libObjPtr()); internal::validateCreatedObjPtr(libObjPtr); - return libObjPtr; + return ObjT::Shared::createWithoutRef(libObjPtr); } }; using TraceClass = CommonTraceClass; using ConstTraceClass = CommonTraceClass; +namespace internal { + +struct TraceClassTypeDescr +{ + using Const = ConstTraceClass; + using NonConst = TraceClass; +}; + +template <> +struct TypeDescr : public TraceClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public TraceClassTypeDescr +{ +}; + +} /* namespace internal */ + template ConstTraceClass CommonStreamClass::traceClass() const noexcept { - return ConstTraceClass {_ConstSpec::traceClass(this->_libObjPtr())}; + return ConstTraceClass {_ConstSpec::traceClass(this->libObjPtr())}; } template typename CommonStreamClass::_TraceClass CommonStreamClass::traceClass() noexcept { - return _TraceClass {_Spec::traceClass(this->_libObjPtr())}; + return _TraceClass {_Spec::traceClass(this->libObjPtr())}; } template ConstTraceClass CommonTrace::cls() const noexcept { - return ConstTraceClass {_ConstSpec::cls(this->_libObjPtr())}; + return ConstTraceClass {_ConstSpec::cls(this->libObjPtr())}; } template typename CommonTrace::Class CommonTrace::cls() noexcept { - return Class {_Spec::cls(this->_libObjPtr())}; + return Class {_Spec::cls(this->libObjPtr())}; } -} // namespace bt2 +} /* namespace bt2 */ -#endif // BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP +#endif /* BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP */