X-Git-Url: http://drtracing.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcpp-common%2Fbt2%2Ftrace-ir.hpp;h=a7576a56ce62607a6c39c01fa4249b30a999feeb;hb=69d96f808107fa18e4d2ee49b058dfa324dae506;hp=44d84b6d3eb8413d4cc26cbffe80a77889b588b7;hpb=e1acf2c711f8fd1643f8c0411394c9bcd215f373;p=babeltrace.git diff --git a/src/cpp-common/bt2/trace-ir.hpp b/src/cpp-common/bt2/trace-ir.hpp index 44d84b6d..a7576a56 100644 --- a/src/cpp-common/bt2/trace-ir.hpp +++ b/src/cpp-common/bt2/trace-ir.hpp @@ -151,12 +151,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 +171,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 +182,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 +193,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 +204,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 +215,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 +226,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 +241,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) @@ -314,12 +330,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 +346,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 +357,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 +368,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 +410,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}; @@ -472,12 +508,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 +523,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 +536,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 +557,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 +567,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 { @@ -656,7 +712,7 @@ struct CommonTraceSpec final 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 +747,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 +765,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 +779,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; @@ -734,12 +790,12 @@ public: void uuid(const std::uint8_t * const uuid) noexcept { - bt_trace_set_uuid(this->_libObjPtr(), uuid); + bt_trace_set_uuid(this->libObjPtr(), uuid); } 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 +806,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 +832,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 +845,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 +861,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 +885,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 +893,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 +901,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 +916,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 { @@ -1018,13 +1094,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 +1111,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 +1132,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 +1145,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 +1165,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 +1179,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 +1188,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 +1213,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 +1222,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 +1247,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 +1257,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 { @@ -1362,56 +1458,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 +1515,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 +1536,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 +1549,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 +1577,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 +1585,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 +1606,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 +1627,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 +1665,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 +1676,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 +1702,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 +1711,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 +1736,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 +1745,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 +1770,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 +1780,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 { @@ -1824,301 +1940,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() { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); - const auto libObjPtr = bt_field_class_structure_create(this->_libObjPtr()); + 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 +2238,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,67 +2248,88 @@ 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 */