🍎 Pass the user message iterator class type as template parameters to
`UserSourceComponent` and `UserFilterComponent`.
🍎 Make them set a public type `MessageIterator` with that.
🍎 Update the `BT_CPP_PLUGIN_*` macros to not take the message iterator
class type, but use `_userComponentClass::MessageIterator`
instead.
Change-Id: I7af3a1a088a61e5b83e4a4047f808435221352cc
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11800
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
* `bt2::SelfSourceComponent` parameter, which it needs to forward to
* bt2::UserSourceComponent::UserSourceComponent(), and a
* `bt2::ConstValue` parameter (initialization parameters).
* `bt2::SelfSourceComponent` parameter, which it needs to forward to
* bt2::UserSourceComponent::UserSourceComponent(), and a
* `bt2::ConstValue` parameter (initialization parameters).
+ *
+ * `UserMessageIteratorT`, the message iterator class to use, must inherit
+ * `UserMessageIterator`.
-template <typename UserComponentT>
+template <typename UserComponentT, typename UserMessageIteratorT>
class UserSourceComponent : public UserComponent<SelfSourceComponent>
{
class UserSourceComponent : public UserComponent<SelfSourceComponent>
{
+ static_assert(std::is_base_of<UserMessageIterator<UserMessageIteratorT, UserComponentT>,
+ UserMessageIteratorT>::value,
+ "`UserMessageIteratorT` inherits `UserMessageIterator`");
+
+public:
+ using MessageIterator = UserMessageIteratorT;
+
protected:
using _OutputPorts = SelfSourceComponent::OutputPorts;
protected:
using _OutputPorts = SelfSourceComponent::OutputPorts;
* `bt2::SelfFilterComponent` parameter, which it needs to forward to
* bt2::UserFilterComponent::UserFilterComponent(), and a
* `bt2::ConstValue` parameter (initialization parameters).
* `bt2::SelfFilterComponent` parameter, which it needs to forward to
* bt2::UserFilterComponent::UserFilterComponent(), and a
* `bt2::ConstValue` parameter (initialization parameters).
+ *
+ * `UserMessageIteratorT`, the message iterator class to use, must inherit
+ * `UserMessageIterator`.
-template <typename UserComponentT>
+template <typename UserComponentT, typename UserMessageIteratorT>
class UserFilterComponent : public UserComponent<SelfFilterComponent>
{
class UserFilterComponent : public UserComponent<SelfFilterComponent>
{
+ static_assert(std::is_base_of<UserMessageIterator<UserMessageIteratorT, UserComponentT>,
+ UserMessageIteratorT>::value,
+ "`UserMessageIteratorT` inherits `UserMessageIterator`");
+
+public:
+ using MessageIterator = UserMessageIteratorT;
+
protected:
using _InputPorts = SelfFilterComponent::InputPorts;
using _OutputPorts = SelfFilterComponent::OutputPorts;
protected:
using _InputPorts = SelfFilterComponent::InputPorts;
using _OutputPorts = SelfFilterComponent::OutputPorts;
-#define BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID( \
- _pluginId, _componentClassId, _name, _userComponentClass, _userMessageIteratorClass) \
+#define BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_pluginId, _componentClassId, _name, \
+ _userComponentClass) \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID( \
_pluginId, _componentClassId, _name, \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID( \
_pluginId, _componentClassId, _name, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::next); \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::next); \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INITIALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, bt2::internal::SrcCompClsBridge<_userComponentClass>::init); \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID( \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INITIALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, bt2::internal::SrcCompClsBridge<_userComponentClass>::init); \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID( \
bt2::internal::SrcCompClsBridge<_userComponentClass>::query); \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, \
bt2::internal::SrcCompClsBridge<_userComponentClass>::query); \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::init); \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::init); \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::finalize); \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::finalize); \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHODS_WITH_ID( \
_pluginId, _componentClassId, \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHODS_WITH_ID( \
_pluginId, _componentClassId, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::seekBeginning, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::canSeekBeginning); \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::seekBeginning, \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::canSeekBeginning); \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID( \
_pluginId, _componentClassId, \
BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID( \
_pluginId, _componentClassId, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::seekNsFromOrigin, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::canSeekNsFromOrigin);
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::seekNsFromOrigin, \
+ bt2::internal::MsgIterClsBridge< \
+ _userComponentClass::MessageIterator>::canSeekNsFromOrigin);
-#define BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID( \
- _pluginId, _componentClassId, _name, _userComponentClass, _userMessageIteratorClass) \
+#define BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_pluginId, _componentClassId, _name, \
+ _userComponentClass) \
BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID( \
_pluginId, _componentClassId, _name, \
BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID( \
_pluginId, _componentClassId, _name, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::next); \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::next); \
BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, bt2::internal::FltCompClsBridge<_userComponentClass>::init); \
BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID( \
BT_PLUGIN_FILTER_COMPONENT_CLASS_INITIALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, bt2::internal::FltCompClsBridge<_userComponentClass>::init); \
BT_PLUGIN_FILTER_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID( \
bt2::internal::FltCompClsBridge<_userComponentClass>::query); \
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, \
bt2::internal::FltCompClsBridge<_userComponentClass>::query); \
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::init); \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::init); \
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, \
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD_WITH_ID( \
_pluginId, _componentClassId, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::finalize); \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::finalize); \
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHODS_WITH_ID( \
_pluginId, _componentClassId, \
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHODS_WITH_ID( \
_pluginId, _componentClassId, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::seekBeginning, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::canSeekBeginning); \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::seekBeginning, \
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::canSeekBeginning); \
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID( \
_pluginId, _componentClassId, \
BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID( \
_pluginId, _componentClassId, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::seekNsFromOrigin, \
- bt2::internal::MsgIterClsBridge<_userMessageIteratorClass>::canSeekNsFromOrigin);
+ bt2::internal::MsgIterClsBridge<_userComponentClass::MessageIterator>::seekNsFromOrigin, \
+ bt2::internal::MsgIterClsBridge< \
+ _userComponentClass::MessageIterator>::canSeekNsFromOrigin);
#define BT_CPP_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(_pluginId, _componentClassId, _name, \
_userComponentClass) \
#define BT_CPP_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(_pluginId, _componentClassId, _name, \
_userComponentClass) \
_pluginId, _componentClassId, \
bt2::internal::SinkCompClsBridge<_userComponentClass>::query);
_pluginId, _componentClassId, \
bt2::internal::SinkCompClsBridge<_userComponentClass>::query);
-#define BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _userComponentClass, \
- _userMessageIteratorClass) \
- BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass, \
- _userMessageIteratorClass)
+#define BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS(_name, _userComponentClass) \
+ BT_CPP_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass)
-#define BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS(_name, _userComponentClass, \
- _userMessageIteratorClass) \
- BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass, \
- _userMessageIteratorClass)
+#define BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS(_name, _userComponentClass) \
+ BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass)
#define BT_CPP_PLUGIN_SINK_COMPONENT_CLASS(_name, _userComponentClass) \
BT_CPP_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass)
#define BT_CPP_PLUGIN_SINK_COMPONENT_CLASS(_name, _userComponentClass) \
BT_CPP_PLUGIN_SINK_COMPONENT_CLASS_WITH_ID(auto, _name, #_name, _userComponentClass)
namespace bt2mux {
Comp::Comp(const bt2::SelfFilterComponent selfComp, const bt2::ConstMapValue params) :
namespace bt2mux {
Comp::Comp(const bt2::SelfFilterComponent selfComp, const bt2::ConstMapValue params) :
- bt2::UserFilterComponent<Comp> {selfComp, "PLUGIN/FLT.UTILS.MUXER"}
+ bt2::UserFilterComponent<Comp, MsgIter> {selfComp, "PLUGIN/FLT.UTILS.MUXER"}
{
BT_CPPLOGI_STR("Initializing component.");
{
BT_CPPLOGI_STR("Initializing component.");
#include "cpp-common/bt2/plugin-dev.hpp"
#include "cpp-common/bt2/plugin-dev.hpp"
+#include "msg-iter.hpp"
+
-class Comp final : public bt2::UserFilterComponent<Comp>
+class MsgIter;
+
+class Comp final : public bt2::UserFilterComponent<Comp, MsgIter>
- friend bt2::UserFilterComponent<Comp>;
+ friend bt2::UserFilterComponent<Comp, MsgIter>;
public:
explicit Comp(bt2::SelfFilterComponent selfComp, bt2::ConstMapValue params);
public:
explicit Comp(bt2::SelfFilterComponent selfComp, bt2::ConstMapValue params);
trimmer_msg_iter_finalize);
/* flt.utils.muxer */
trimmer_msg_iter_finalize);
/* flt.utils.muxer */
-BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS(muxer, bt2mux::Comp, bt2mux::MsgIter);
+BT_CPP_PLUGIN_FILTER_COMPONENT_CLASS(muxer, bt2mux::Comp);
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(
muxer, "Sort messages from multiple input ports to a single output port by time.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_HELP(muxer,
BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(
muxer, "Sort messages from multiple input ports to a single output port by time.");
BT_PLUGIN_FILTER_COMPONENT_CLASS_HELP(muxer,