#ifndef BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP
#define BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP
-#include <type_traits>
#include <cstdint>
+#include <type_traits>
+
#include <babeltrace2/babeltrace.h>
-#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 {
}
template <typename OtherLibObjT>
- CommonEvent(const CommonEvent<OtherLibObjT>& event) noexcept : _ThisBorrowedObj {event}
+ CommonEvent(const CommonEvent<OtherLibObjT> event) noexcept : _ThisBorrowedObj {event}
{
}
template <typename OtherLibObjT>
- CommonEvent<LibObjT>& operator=(const CommonEvent<OtherLibObjT>& event) noexcept
+ CommonEvent<LibObjT>& operator=(const CommonEvent<OtherLibObjT> event) noexcept
{
_ThisBorrowedObj::operator=(event);
return *this;
namespace internal {
+struct EventTypeDescr
+{
+ using Const = ConstEvent;
+ using NonConst = Event;
+};
+
+template <>
+struct TypeDescr<Event> : public EventTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstEvent> : public EventTypeDescr
+{
+};
+
struct PacketRefFuncs final
{
static void get(const bt_packet * const libObjPtr)
}
template <typename OtherLibObjT>
- CommonPacket(const CommonPacket<OtherLibObjT>& packet) noexcept : _ThisBorrowedObj {packet}
+ CommonPacket(const CommonPacket<OtherLibObjT> packet) noexcept : _ThisBorrowedObj {packet}
{
}
template <typename OtherLibObjT>
- _ThisCommonPacket& operator=(const CommonPacket<OtherLibObjT>& packet) noexcept
+ _ThisCommonPacket& operator=(const CommonPacket<OtherLibObjT> packet) noexcept
{
_ThisBorrowedObj::operator=(packet);
return *this;
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
using Packet = CommonPacket<bt_packet>;
using ConstPacket = CommonPacket<const bt_packet>;
+namespace internal {
+
+struct PacketTypeDescr
+{
+ using Const = ConstPacket;
+ using NonConst = Packet;
+};
+
+template <>
+struct TypeDescr<Packet> : public PacketTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstPacket> : public PacketTypeDescr
+{
+};
+
+} /* namespace internal */
+
template <typename LibObjT>
nonstd::optional<ConstPacket> CommonEvent<LibObjT>::packet() const noexcept
{
}
template <typename OtherLibObjT>
- CommonStream(const CommonStream<OtherLibObjT>& stream) noexcept : _ThisBorrowedObj {stream}
+ CommonStream(const CommonStream<OtherLibObjT> stream) noexcept : _ThisBorrowedObj {stream}
{
}
template <typename OtherLibObjT>
- _ThisCommonStream& operator=(const CommonStream<OtherLibObjT>& stream) noexcept
+ _ThisCommonStream& operator=(const CommonStream<OtherLibObjT> stream) noexcept
{
_ThisBorrowedObj::operator=(stream);
return *this;
const auto libObjPtr = bt_packet_create(this->libObjPtr());
internal::validateCreatedObjPtr(libObjPtr);
- return Packet::Shared {Packet {libObjPtr}};
+ return Packet::Shared::createWithoutRef(libObjPtr);
}
CommonStreamClass<const bt_stream_class> cls() const noexcept;
const auto status = bt_stream_set_name(this->libObjPtr(), name);
if (status == BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
}
template <typename LibValT>
- void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+ void userAttributes(const CommonMapValue<LibValT> userAttrs)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
using Stream = CommonStream<bt_stream>;
using ConstStream = CommonStream<const bt_stream>;
+namespace internal {
+
+struct StreamTypeDescr
+{
+ using Const = ConstStream;
+ using NonConst = Stream;
+};
+
+template <>
+struct TypeDescr<Stream> : public StreamTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstStream> : public StreamTypeDescr
+{
+};
+
+} /* namespace internal */
+
template <typename LibObjT>
ConstStream CommonEvent<LibObjT>::stream() const noexcept
{
}
template <typename OtherLibObjT>
- CommonTrace(const CommonTrace<OtherLibObjT>& trace) noexcept : _ThisBorrowedObj {trace}
+ CommonTrace(const CommonTrace<OtherLibObjT> trace) noexcept : _ThisBorrowedObj {trace}
{
}
template <typename OtherLibObjT>
- _ThisCommonTrace& operator=(const CommonTrace<OtherLibObjT>& trace) noexcept
+ _ThisCommonTrace& operator=(const CommonTrace<OtherLibObjT> trace) noexcept
{
_ThisBorrowedObj::operator=(trace);
return *this;
const auto status = bt_trace_set_name(this->libObjPtr(), name);
if (status == BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
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<bt2_common::UuidView> uuid() const noexcept
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 {};
}
}
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 {};
}
}
}
template <typename LibValT>
- void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+ void userAttributes(const CommonMapValue<LibValT> userAttrs)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
using Trace = CommonTrace<bt_trace>;
using ConstTrace = CommonTrace<const bt_trace>;
+namespace internal {
+
+struct TraceTypeDescr
+{
+ using Const = ConstTrace;
+ using NonConst = Trace;
+};
+
+template <>
+struct TypeDescr<Trace> : public TraceTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstTrace> : public TraceTypeDescr
+{
+};
+
+} /* namespace internal */
+
template <typename LibObjT>
ConstTrace CommonStream<LibObjT>::trace() const noexcept
{
}
template <typename OtherLibObjT>
- CommonEventClass(const CommonEventClass<OtherLibObjT>& eventClass) noexcept :
+ CommonEventClass(const CommonEventClass<OtherLibObjT> eventClass) noexcept :
_ThisBorrowedObj {eventClass}
{
}
template <typename OtherLibObjT>
- _ThisCommonEventClass& operator=(const CommonEventClass<OtherLibObjT>& eventClass) noexcept
+ _ThisCommonEventClass& operator=(const CommonEventClass<OtherLibObjT> eventClass) noexcept
{
_ThisBorrowedObj::operator=(eventClass);
return *this;
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 {};
}
}
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 {};
}
}
return nonstd::nullopt;
}
- void payloadFieldClass(const StructureFieldClass& fc)
+ void payloadFieldClass(const StructureFieldClass fc)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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 {};
}
}
return nonstd::nullopt;
}
- void specificContextFieldClass(const StructureFieldClass& fc)
+ void specificContextFieldClass(const StructureFieldClass fc)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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 {};
}
}
}
template <typename LibValT>
- void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+ void userAttributes(const CommonMapValue<LibValT> userAttrs)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
using EventClass = CommonEventClass<bt_event_class>;
using ConstEventClass = CommonEventClass<const bt_event_class>;
+namespace internal {
+
+struct EventClassTypeDescr
+{
+ using Const = ConstEventClass;
+ using NonConst = EventClass;
+};
+
+template <>
+struct TypeDescr<EventClass> : public EventClassTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstEventClass> : public EventClassTypeDescr
+{
+};
+
+} /* namespace internal */
+
template <typename LibObjT>
ConstEventClass CommonEvent<LibObjT>::cls() const noexcept
{
}
template <typename OtherLibObjT>
- CommonStreamClass(const CommonStreamClass<OtherLibObjT>& streamClass) noexcept :
+ CommonStreamClass(const CommonStreamClass<OtherLibObjT> streamClass) noexcept :
_ThisBorrowedObj {streamClass}
{
}
template <typename OtherLibObjT>
- _ThisCommonStreamClass& operator=(const CommonStreamClass<OtherLibObjT>& streamClass) noexcept
+ _ThisCommonStreamClass& operator=(const CommonStreamClass<OtherLibObjT> streamClass) noexcept
{
_ThisBorrowedObj::operator=(streamClass);
return *this;
}
- Stream::Shared instantiate(const Trace& trace)
+ Stream::Shared instantiate(const Trace trace)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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()
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)
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<const bt_trace_class> traceClass() const noexcept;
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 {};
}
}
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
bt_stream_class_set_supports_discarded_events(
- this->libObjPtr(), static_cast<bt_bool>(supportsPackets),
+ this->libObjPtr(), static_cast<bt_bool>(supportsDiscardedEvents),
static_cast<bt_bool>(withDefaultClkSnapshots));
}
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
bt_stream_class_set_supports_discarded_packets(
- this->libObjPtr(), static_cast<bt_bool>(supportsPackets),
+ this->libObjPtr(), static_cast<bt_bool>(supportsDiscardedPackets),
static_cast<bt_bool>(withDefaultClkSnapshots));
}
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
return nonstd::nullopt;
}
- void packetContextFieldClass(const StructureFieldClass& fc)
+ void packetContextFieldClass(const StructureFieldClass fc)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
const auto status =
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 {};
}
}
return nonstd::nullopt;
}
- void eventCommonContextFieldClass(const StructureFieldClass& fc)
+ void eventCommonContextFieldClass(const StructureFieldClass fc)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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 {};
}
}
}
template <typename LibValT>
- void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+ void userAttributes(const CommonMapValue<LibValT> userAttrs)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
};
using StreamClass = CommonStreamClass<bt_stream_class>;
using ConstStreamClass = CommonStreamClass<const bt_stream_class>;
+namespace internal {
+
+struct StreamClassTypeDescr
+{
+ using Const = ConstStreamClass;
+ using NonConst = StreamClass;
+};
+
+template <>
+struct TypeDescr<StreamClass> : public StreamClassTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstStreamClass> : public StreamClassTypeDescr
+{
+};
+
+} /* namespace internal */
+
template <typename LibObjT>
ConstStreamClass CommonEventClass<LibObjT>::streamClass() const noexcept
{
}
template <typename OtherLibObjT>
- CommonTraceClass(const CommonTraceClass<OtherLibObjT>& traceClass) noexcept :
+ CommonTraceClass(const CommonTraceClass<OtherLibObjT> traceClass) noexcept :
_ThisBorrowedObj {traceClass}
{
}
template <typename OtherLibObjT>
- _ThisCommonTraceClass& operator=(const CommonTraceClass<OtherLibObjT>& traceClass) noexcept
+ _ThisCommonTraceClass& operator=(const CommonTraceClass<OtherLibObjT> traceClass) noexcept
{
_ThisBorrowedObj::operator=(traceClass);
return *this;
}
- Trace::Shared instantiate(const Trace& trace)
+ Trace::Shared instantiate()
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
const auto libObjPtr = bt_trace_create(this->libObjPtr());
internal::validateCreatedObjPtr(libObjPtr);
- return Trace::Shared {Trace {libObjPtr}};
+ return Trace::Shared::createWithoutRef(libObjPtr);
}
StreamClass::Shared createStreamClass()
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)
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()
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)
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()
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()
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()
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()
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()
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()
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()
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
this->libObjPtr(), elementFieldClass.libObjPtr(), lengthFieldClass.libObjPtr());
internal::validateCreatedObjPtr(libObjPtr);
- return DynamicArrayWithLengthFieldClass::Shared {
- DynamicArrayWithLengthFieldClass {libObjPtr}};
+ return DynamicArrayWithLengthFieldClass::Shared::createWithoutRef(libObjPtr);
}
StructureFieldClass::Shared createStructureFieldClass()
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
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<LibObjT>::value, "`LibObjT` must NOT be `const`.");
ranges.libObjPtr());
internal::validateCreatedObjPtr(libObjPtr);
- return OptionWithSignedIntegerSelectorFieldClass::Shared {
- OptionWithSignedIntegerSelectorFieldClass {libObjPtr}};
+ return OptionWithSignedIntegerSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
}
VariantWithoutSelectorFieldClass::Shared createVariantFieldClass()
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
}
template <typename LibValT>
- void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+ void userAttributes(const CommonMapValue<LibValT> userAttrs)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
Shared shared() const noexcept
{
- return Shared {*this};
+ return Shared::createWithRef(*this);
}
private:
- bt_field_class *
- _createVariantWithIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass)
+ template <typename ObjT>
+ typename ObjT::Shared
+ _createVariantWithIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass)
{
static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
bt_field_class_variant_create(this->libObjPtr(), selectorFieldClass.libObjPtr());
internal::validateCreatedObjPtr(libObjPtr);
- return libObjPtr;
+ return ObjT::Shared::createWithoutRef(libObjPtr);
}
};
using TraceClass = CommonTraceClass<bt_trace_class>;
using ConstTraceClass = CommonTraceClass<const bt_trace_class>;
+namespace internal {
+
+struct TraceClassTypeDescr
+{
+ using Const = ConstTraceClass;
+ using NonConst = TraceClass;
+};
+
+template <>
+struct TypeDescr<TraceClass> : public TraceClassTypeDescr
+{
+};
+
+template <>
+struct TypeDescr<ConstTraceClass> : public TraceClassTypeDescr
+{
+};
+
+} /* namespace internal */
+
template <typename LibObjT>
ConstTraceClass CommonStreamClass<LibObjT>::traceClass() const noexcept
{