cpp-common/bt2: fix trivial-ish mistakes in plugin-dev.hpp
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 12 Feb 2024 20:39:59 +0000 (15:39 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 19 Feb 2024 18:10:15 +0000 (13:10 -0500)
Fix a few problems that were found by exercising the `plugin-dev.hpp`
code a bit more.

    ⚾ Use public inheritance in `SinkCompClsBridge`.
    ⚾ Add return statement in happy path of
       `SinkCompClsBridge::graphIsConfigured`.
    ⚾ Use `DataT&` as the parameter type to `_addOutputPort` and
       `_addInputPort` methods, matching what
       `Self*Component::add*Port` expects.
    ⚾ Call `_outputPortConnected` instead of `outputPortConnected` in
       `UserSourceComponent::outputPortConnected`, which otherwise results
       in infinite recursion.

Change-Id: Ieab12436c4b85b5a33195be0ea388b3f545f07cd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11789
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/cpp-common/bt2/plugin-dev.hpp

index 33ab5b4254e3d62e539f8bef8f2eb9ba58cf4604..916ff1aeaa6bdfa269ba96c1ed0732c08e58a4c2 100644 (file)
@@ -235,8 +235,8 @@ struct SinkCompClsLibTypes final
 
 template <typename UserCompClsT>
 class SinkCompClsBridge final :
-    CompClsBridge<UserCompClsT, SinkCompClsLibTypes>,
-    CompClsBridgeWithInputPorts<SinkCompClsBridge<UserCompClsT>, SinkCompClsLibTypes>
+    public CompClsBridge<UserCompClsT, SinkCompClsLibTypes>,
+    public CompClsBridgeWithInputPorts<SinkCompClsBridge<UserCompClsT>, SinkCompClsLibTypes>
 {
 private:
     using CompClsBridge<UserCompClsT, SinkCompClsLibTypes>::userCompFromLibSelfCompPtr;
@@ -270,6 +270,7 @@ public:
     {
         try {
             userCompFromLibSelfCompPtr(libSelfCompPtr).graphIsConfigured();
+            return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
         } catch (const std::bad_alloc&) {
             return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR;
         } catch (const Error&) {
@@ -561,7 +562,7 @@ public:
     void outputPortConnected(const SelfComponentOutputPort outputPort,
                              const ConstInputPort inputPort)
     {
-        static_cast<UserComponentT&>(*this).outputPortConnected(outputPort, inputPort);
+        static_cast<UserComponentT&>(*this)._outputPortConnected(outputPort, inputPort);
     }
 
 protected:
@@ -585,7 +586,7 @@ protected:
     }
 
     template <typename DataT>
-    _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT * const data)
+    _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data)
     {
         return this->_selfComp().addOutputPort(name, data);
     }
@@ -693,7 +694,7 @@ protected:
     }
 
     template <typename DataT>
-    _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT * const data)
+    _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data)
     {
         return this->_selfComp().addInputPort(name, data);
     }
@@ -709,7 +710,7 @@ protected:
     }
 
     template <typename DataT>
-    _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT * const data)
+    _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data)
     {
         return this->_selfComp().addOutputPort(name, data);
     }
@@ -822,7 +823,7 @@ protected:
     }
 
     template <typename DataT>
-    _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT * const data)
+    _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data)
     {
         return this->_selfComp().addInputPort(name, data);
     }
This page took 0.026885 seconds and 4 git commands to generate.