#include "logging.hpp"
-#include "common/assert.h"
#include "cpp-common/bt2c/c-string-view.hpp"
#include "borrowed-object-iterator.hpp"
}
template <typename T>
- void data(T& obj) const noexcept
+ SelfComponent data(T& obj) const noexcept
{
- bt_self_component_set_data(this->libObjPtr(), static_cast<void *>(&obj));
+ bt_self_component_set_data(this->libObjPtr(),
+ const_cast<void *>(static_cast<const void *>(&obj)));
+ return *this;
}
bt2::TraceClass::Shared createTraceClass() const
}
};
+namespace internal {
+
template <typename LibObjT>
class SelfSpecificComponent : public BorrowedObject<LibObjT>
{
{
LibPortT *libPortPtr;
- const auto status = func(this->libObjPtr(), name, static_cast<void *>(data), &libPortPtr);
+ const auto status = func(this->libObjPtr(), name,
+ const_cast<void *>(static_cast<const void *>(data)), &libPortPtr);
switch (status) {
case BT_SELF_COMPONENT_ADD_PORT_STATUS_OK:
return this->_selfComponent().template data<T>();
}
- template <typename T>
- void data(T& obj) const noexcept
- {
- this->_selfComponent().data(obj);
- }
-
-private:
+protected:
SelfComponent _selfComponent() const noexcept
{
return SelfComponent {this->libObjPtr()};
}
};
-namespace internal {
-
template <typename LibSelfCompT, typename LibSelfCompPortPtrT>
struct SelfComponentPortsSpec;
Port back() const noexcept;
};
-class SelfSourceComponent final : public SelfSpecificComponent<bt_self_component_source>
+class SelfSourceComponent final : public internal::SelfSpecificComponent<bt_self_component_source>
{
+ using _ThisSelfSpecificComponent = internal::SelfSpecificComponent<bt_self_component_source>;
+
public:
using OutputPorts = SelfComponentPorts<bt_self_component_source, bt_self_component_port_output,
const bt_port_output>;
bt_self_component_source_as_component_source(this->libObjPtr())};
}
+ using _ThisSelfSpecificComponent::data;
+
+ template <typename T>
+ SelfSourceComponent data(T& obj) const noexcept
+ {
+ this->_selfComponent().data(obj);
+ return *this;
+ }
+
template <typename DataT>
OutputPorts::Port addOutputPort(bt2c::CStringView name, DataT& data) const;
OutputPorts::Port _addOutputPort(const char *name, DataT *data) const;
};
-class SelfFilterComponent final : public SelfSpecificComponent<bt_self_component_filter>
+class SelfFilterComponent final : public internal::SelfSpecificComponent<bt_self_component_filter>
{
+ using _ThisSelfSpecificComponent = internal::SelfSpecificComponent<bt_self_component_filter>;
+
public:
using InputPorts = SelfComponentPorts<bt_self_component_filter, bt_self_component_port_input,
const bt_port_input>;
bt_self_component_filter_as_component_filter(this->libObjPtr())};
}
+ using _ThisSelfSpecificComponent::data;
+
+ template <typename T>
+ SelfFilterComponent data(T& obj) const noexcept
+ {
+ this->_selfComponent().data(obj);
+ return *this;
+ }
+
template <typename DataT>
InputPorts::Port addInputPort(bt2c::CStringView name, DataT& data) const;
OutputPorts::Port _addOutputPort(const char *name, DataT *data) const;
};
-class SelfSinkComponent final : public SelfSpecificComponent<bt_self_component_sink>
+class SelfSinkComponent final : public internal::SelfSpecificComponent<bt_self_component_sink>
{
+ using _ThisSelfSpecificComponent = internal::SelfSpecificComponent<bt_self_component_sink>;
+
public:
using InputPorts = SelfComponentPorts<bt_self_component_sink, bt_self_component_port_input,
const bt_port_input>;
return ConstSinkComponent {bt_self_component_sink_as_component_sink(this->libObjPtr())};
}
+ using _ThisSelfSpecificComponent::data;
+
+ template <typename T>
+ SelfSinkComponent data(T& obj) const noexcept
+ {
+ this->_selfComponent().data(obj);
+ return *this;
+ }
+
MessageIterator::Shared createMessageIterator(InputPorts::Port port) const;
bool isInterrupted() const noexcept
switch (status) {
case BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_OK:
- BT_ASSERT(libMsgIterPtr);
return MessageIterator::Shared::createWithoutRef(libMsgIterPtr);
case BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_MEMORY_ERROR:
throw MemoryError {};