X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcpp-common%2Fbt2%2Fself-component-port.hpp;h=e41dd09c8cde3d3259236861244c9f627f99f3c3;hb=7c9d996f00a4172ab5ce40ae7f1d8506a469c03a;hp=fff4aea76a37c7eaeacd871b4d1aef055e4c7379;hpb=e7f0f07bea73c3fdf14bbc919bfd44bff3eb85e1;p=babeltrace.git diff --git a/src/cpp-common/bt2/self-component-port.hpp b/src/cpp-common/bt2/self-component-port.hpp index fff4aea7..e41dd09c 100644 --- a/src/cpp-common/bt2/self-component-port.hpp +++ b/src/cpp-common/bt2/self-component-port.hpp @@ -8,7 +8,6 @@ #define BABELTRACE_CPP_COMMON_BT2_SELF_COMPONENT_PORT_HPP #include -#include #include @@ -297,8 +296,7 @@ public: } Port operator[](std::uint64_t index) const noexcept; - Port operator[](const char *name) const noexcept; - Port operator[](const std::string& name) const noexcept; + Port operator[](bt2c::CStringView name) const noexcept; Iterator begin() const noexcept; Iterator end() const noexcept; Port front() const noexcept; @@ -323,14 +321,10 @@ public: } template - OutputPorts::Port addOutputPort(const char *name, DataT& data) const; + OutputPorts::Port addOutputPort(bt2c::CStringView name, DataT& data) const; - OutputPorts::Port addOutputPort(const char *name) const; + OutputPorts::Port addOutputPort(bt2c::CStringView name) const; - template - OutputPorts::Port addOutputPort(const std::string& name, DataT& data) const; - - OutputPorts::Port addOutputPort(const std::string& name) const; OutputPorts outputPorts() const noexcept; private: @@ -358,25 +352,17 @@ public: } template - InputPorts::Port addInputPort(const char *name, DataT& data) const; - - InputPorts::Port addInputPort(const char *name) const; + InputPorts::Port addInputPort(bt2c::CStringView name, DataT& data) const; - template - InputPorts::Port addInputPort(const std::string& name, DataT& data) const; + InputPorts::Port addInputPort(bt2c::CStringView name) const; - InputPorts::Port addInputPort(const std::string& name) const; InputPorts inputPorts() const noexcept; template - OutputPorts::Port addOutputPort(const char *name, DataT& data) const; - - OutputPorts::Port addOutputPort(const char *name) const; + OutputPorts::Port addOutputPort(bt2c::CStringView name, DataT& data) const; - template - OutputPorts::Port addOutputPort(const std::string& name, DataT& data) const; + OutputPorts::Port addOutputPort(bt2c::CStringView name) const; - OutputPorts::Port addOutputPort(const std::string& name) const; OutputPorts outputPorts() const noexcept; private: @@ -411,14 +397,10 @@ public: } template - InputPorts::Port addInputPort(const char *name, DataT& data) const; + InputPorts::Port addInputPort(bt2c::CStringView name, DataT& data) const; - InputPorts::Port addInputPort(const char *name) const; + InputPorts::Port addInputPort(bt2c::CStringView name) const; - template - InputPorts::Port addInputPort(const std::string& name, DataT& data) const; - - InputPorts::Port addInputPort(const std::string& name) const; InputPorts inputPorts() const noexcept; private: @@ -556,19 +538,11 @@ SelfComponentPorts::operator[]( template typename SelfComponentPorts::Port SelfComponentPorts::operator[]( - const char * const name) const noexcept + const bt2c::CStringView name) const noexcept { return Port {_Spec::portByName(this->libObjPtr(), name)}; } -template -typename SelfComponentPorts::Port -SelfComponentPorts::operator[]( - const std::string& name) const noexcept -{ - return (*this)[name.data()]; -} - template typename SelfComponentPorts::Iterator SelfComponentPorts::begin() const noexcept @@ -611,31 +585,18 @@ SelfSourceComponent::OutputPorts::Port SelfSourceComponent::_addOutputPort(const } template -SelfSourceComponent::OutputPorts::Port SelfSourceComponent::addOutputPort(const char * const name, - DataT& data) const +SelfSourceComponent::OutputPorts::Port +SelfSourceComponent::addOutputPort(const bt2c::CStringView name, DataT& data) const { return this->_addOutputPort(name, &data); } inline SelfSourceComponent::OutputPorts::Port -SelfSourceComponent::addOutputPort(const char * const name) const +SelfSourceComponent::addOutputPort(const bt2c::CStringView name) const { return this->_addOutputPort(name, nullptr); } -template -SelfSourceComponent::OutputPorts::Port SelfSourceComponent::addOutputPort(const std::string& name, - DataT& data) const -{ - return this->_addOutputPort(name.data(), &data); -} - -inline SelfSourceComponent::OutputPorts::Port -SelfSourceComponent::addOutputPort(const std::string& name) const -{ - return this->_addOutputPort(name.data(), nullptr); -} - inline SelfSourceComponent::OutputPorts SelfSourceComponent::outputPorts() const noexcept { return OutputPorts {this->libObjPtr()}; @@ -650,31 +611,18 @@ SelfFilterComponent::OutputPorts::Port SelfFilterComponent::_addOutputPort(const } template -SelfFilterComponent::OutputPorts::Port SelfFilterComponent::addOutputPort(const char * const name, - DataT& data) const +SelfFilterComponent::OutputPorts::Port +SelfFilterComponent::addOutputPort(const bt2c::CStringView name, DataT& data) const { return this->_addOutputPort(name, &data); } inline SelfFilterComponent::OutputPorts::Port -SelfFilterComponent::addOutputPort(const char * const name) const +SelfFilterComponent::addOutputPort(const bt2c::CStringView name) const { return this->_addOutputPort(name, nullptr); } -template -SelfFilterComponent::OutputPorts::Port SelfFilterComponent::addOutputPort(const std::string& name, - DataT& data) const -{ - return this->_addOutputPort(name.data(), &data); -} - -inline SelfFilterComponent::OutputPorts::Port -SelfFilterComponent::addOutputPort(const std::string& name) const -{ - return this->_addOutputPort(name.data(), nullptr); -} - inline SelfFilterComponent::OutputPorts SelfFilterComponent::outputPorts() const noexcept { return OutputPorts {this->libObjPtr()}; @@ -689,31 +637,18 @@ SelfFilterComponent::InputPorts::Port SelfFilterComponent::_addInputPort(const c } template -SelfFilterComponent::InputPorts::Port SelfFilterComponent::addInputPort(const char * const name, - DataT& data) const +SelfFilterComponent::InputPorts::Port +SelfFilterComponent::addInputPort(const bt2c::CStringView name, DataT& data) const { return this->_addInputPort(name, &data); } inline SelfFilterComponent::InputPorts::Port -SelfFilterComponent::addInputPort(const char * const name) const +SelfFilterComponent::addInputPort(const bt2c::CStringView name) const { return this->_addInputPort(name, nullptr); } -template -SelfFilterComponent::InputPorts::Port SelfFilterComponent::addInputPort(const std::string& name, - DataT& data) const -{ - return this->_addInputPort(name.data(), &data); -} - -inline SelfFilterComponent::InputPorts::Port -SelfFilterComponent::addInputPort(const std::string& name) const -{ - return this->_addInputPort(name.data(), nullptr); -} - inline SelfFilterComponent::InputPorts SelfFilterComponent::inputPorts() const noexcept { return InputPorts {this->libObjPtr()}; @@ -749,31 +684,18 @@ SelfSinkComponent::InputPorts::Port SelfSinkComponent::_addInputPort(const char } template -SelfSinkComponent::InputPorts::Port SelfSinkComponent::addInputPort(const char * const name, +SelfSinkComponent::InputPorts::Port SelfSinkComponent::addInputPort(const bt2c::CStringView name, DataT& data) const { return this->_addInputPort(name, &data); } inline SelfSinkComponent::InputPorts::Port -SelfSinkComponent::addInputPort(const char * const name) const +SelfSinkComponent::addInputPort(const bt2c::CStringView name) const { return this->_addInputPort(name, nullptr); } -template -SelfSinkComponent::InputPorts::Port SelfSinkComponent::addInputPort(const std::string& name, - DataT& data) const -{ - return this->_addInputPort(name.data(), &data); -} - -inline SelfSinkComponent::InputPorts::Port -SelfSinkComponent::addInputPort(const std::string& name) const -{ - return this->_addInputPort(name.data(), nullptr); -} - inline SelfSinkComponent::InputPorts SelfSinkComponent::inputPorts() const noexcept { return InputPorts {this->libObjPtr()};