cpp-common/bt2: remove unnecessary mentions of `bt2::`
[babeltrace.git] / src / cpp-common / bt2 / self-component-port.hpp
index 2cd056afb1f4343dbe367d4f99c102b4de39f8a3..10a73bb4bd3a021c58a5cd4722d4fa133a7ec3f5 100644 (file)
@@ -99,13 +99,14 @@ public:
     }
 
     template <typename T>
-    void data(T& obj) const noexcept
+    SelfComponent data(T& obj) const noexcept
     {
         bt_self_component_set_data(this->libObjPtr(),
                                    const_cast<void *>(static_cast<const void *>(&obj)));
+        return *this;
     }
 
-    bt2::TraceClass::Shared createTraceClass() const
+    TraceClass::Shared createTraceClass() const
     {
         const auto libObjPtr = bt_trace_class_create(this->libObjPtr());
 
@@ -113,10 +114,10 @@ public:
             throw MemoryError {};
         }
 
-        return bt2::TraceClass::Shared::createWithoutRef(libObjPtr);
+        return TraceClass::Shared::createWithoutRef(libObjPtr);
     }
 
-    bt2::ClockClass::Shared createClockClass() const
+    ClockClass::Shared createClockClass() const
     {
         const auto libObjPtr = bt_clock_class_create(this->libObjPtr());
 
@@ -124,10 +125,12 @@ public:
             throw MemoryError {};
         }
 
-        return bt2::ClockClass::Shared::createWithoutRef(libObjPtr);
+        return ClockClass::Shared::createWithoutRef(libObjPtr);
     }
 };
 
+namespace internal {
+
 template <typename LibObjT>
 class SelfSpecificComponent : public BorrowedObject<LibObjT>
 {
@@ -185,21 +188,13 @@ public:
         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;
 
@@ -326,8 +321,10 @@ public:
     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>;
@@ -343,6 +340,15 @@ public:
             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;
 
@@ -355,8 +361,10 @@ private:
     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>;
@@ -374,6 +382,15 @@ public:
             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;
 
@@ -396,8 +413,10 @@ private:
     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>;
@@ -412,6 +431,15 @@ public:
         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
This page took 0.031919 seconds and 4 git commands to generate.