diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_manager.inl b/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_manager.inl index 05a538ddf92..fec1f13c754 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_manager.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_manager.inl @@ -28,17 +28,25 @@ inline optional PortManager::doesViolateCommunicationPolicy(const capro::ServiceDescription& service) noexcept { // check if the publisher is already in the list - for (auto publisherPortData : m_portPool->getPublisherPortDataList()) + auto& publisherPorts = m_portPool->getPublisherPortDataList(); + auto port = publisherPorts.begin(); + while (port != publisherPorts.end()) { - popo::PublisherPortRouDi publisherPort(publisherPortData); + popo::PublisherPortRouDi publisherPort(port.to_ptr()); + if (service == publisherPort.getCaProServiceDescription()) { - if (publisherPortData->m_toBeDestroyed) + if (publisherPort.toBeDestroyed()) { - destroyPublisherPort(publisherPortData); + destroyPublisherPort(port.to_ptr()); + port = publisherPorts.begin(); continue; } - return make_optional(publisherPortData->m_runtimeName); + return make_optional(port->m_runtimeName); + } + else + { + ++port; } } return nullopt; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_pool_data.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_pool_data.hpp index 00a3d1de735..c372ae478e2 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_pool_data.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_pool_data.hpp @@ -25,6 +25,7 @@ #include "iceoryx_posh/internal/popo/ports/server_port_data.hpp" #include "iceoryx_posh/internal/popo/ports/subscriber_port_data.hpp" #include "iceoryx_posh/internal/runtime/node_data.hpp" +#include "iox/fixed_position_container.hpp" #include "iox/optional.hpp" #include "iox/vector.hpp" @@ -32,42 +33,31 @@ namespace iox { namespace roudi { -/// @brief workaround container until we have a fixed list with the needed functionality -template -class FixedPositionContainer +struct PortPoolData { - public: - static constexpr uint64_t FIRST_ELEMENT = std::numeric_limits::max(); + using InterfaceContainer = FixedPositionContainer; + InterfaceContainer m_interfacePortMembers; - bool hasFreeSpace() noexcept; + using NodeContainer = FixedPositionContainer; + NodeContainer m_nodeMembers; - template - T* insert(Targs&&... args) noexcept; + using CondVarContainer = FixedPositionContainer; + CondVarContainer m_conditionVariableMembers; - void erase(const T* const element) noexcept; + using PublisherContainer = FixedPositionContainer; + PublisherContainer m_publisherPortMembers; - vector content() noexcept; + using SubscriberContainer = FixedPositionContainer; + SubscriberContainer m_subscriberPortMembers; - private: - vector, Capacity> m_data; -}; + using ServerContainer = FixedPositionContainer; + ServerContainer m_serverPortMembers; -struct PortPoolData -{ - FixedPositionContainer m_interfacePortMembers; - FixedPositionContainer m_nodeMembers; - FixedPositionContainer m_conditionVariableMembers; - - FixedPositionContainer m_publisherPortMembers; - FixedPositionContainer m_subscriberPortMembers; - - FixedPositionContainer m_serverPortMembers; - FixedPositionContainer m_clientPortMembers; + using ClientContainer = FixedPositionContainer; + ClientContainer m_clientPortMembers; }; } // namespace roudi } // namespace iox -#include "iceoryx_posh/internal/roudi/port_pool_data.inl" - #endif // IOX_POSH_ROUDI_PORT_POOL_DATA_BASE_HPP diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_pool_data.inl b/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_pool_data.inl deleted file mode 100644 index e08814b596b..00000000000 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/port_pool_data.inl +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_POSH_ROUDI_PORT_POOL_DATA_INL -#define IOX_POSH_ROUDI_PORT_POOL_DATA_INL - -#include "iceoryx_posh/internal/roudi/port_pool_data.hpp" - -namespace iox -{ -namespace roudi -{ -template -bool FixedPositionContainer::hasFreeSpace() noexcept -{ - if (m_data.capacity() > m_data.size()) - { - return true; - } - - for (auto& e : m_data) - { - if (!e.has_value()) - { - return true; - } - } - - return false; -} - -template -template -T* FixedPositionContainer::insert(Targs&&... args) noexcept -{ - for (auto& e : m_data) - { - if (!e.has_value()) - { - e.emplace(std::forward(args)...); - return &e.value(); - } - } - - m_data.emplace_back(); - m_data.back().emplace(std::forward(args)...); - return &m_data.back().value(); -} - -template -void FixedPositionContainer::erase(const T* const element) noexcept -{ - for (auto& e : m_data) - { - if (e.has_value() && &e.value() == element) - { - e.reset(); - return; - } - } -} - -template -vector FixedPositionContainer::content() noexcept -{ - vector returnValue; - for (auto& e : m_data) - { - if (e.has_value()) - { - returnValue.emplace_back(&e.value()); - } - } - return returnValue; -} - -} // namespace roudi -} // namespace iox - -#endif // IOX_POSH_ROUDI_PORT_POOL_DATA_BASE_INL diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/port_pool.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/port_pool.hpp index e9e58a00e9c..284d11cd0f2 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/port_pool.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/port_pool.hpp @@ -63,13 +63,13 @@ class PortPool virtual ~PortPool() noexcept = default; - vector getPublisherPortDataList() noexcept; - vector getSubscriberPortDataList() noexcept; - vector getClientPortDataList() noexcept; - vector getServerPortDataList() noexcept; - vector getInterfacePortDataList() noexcept; - vector getNodeDataList() noexcept; - vector getConditionVariableDataList() noexcept; + PortPoolData::PublisherContainer& getPublisherPortDataList() noexcept; + PortPoolData::SubscriberContainer& getSubscriberPortDataList() noexcept; + PortPoolData::ClientContainer& getClientPortDataList() noexcept; + PortPoolData::ServerContainer& getServerPortDataList() noexcept; + PortPoolData::InterfaceContainer& getInterfacePortDataList() noexcept; + PortPoolData::NodeContainer& getNodeDataList() noexcept; + PortPoolData::CondVarContainer& getConditionVariableDataList() noexcept; expected addPublisherPort(const capro::ServiceDescription& serviceDescription, diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/port_pool.inl b/iceoryx_posh/include/iceoryx_posh/roudi/port_pool.inl index 05d9ec11766..1257487a4cc 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/port_pool.inl +++ b/iceoryx_posh/include/iceoryx_posh/roudi/port_pool.inl @@ -27,7 +27,7 @@ inline iox::popo::SubscriberPortData* PortPool::constructSubscriber(const capro: const popo::SubscriberOptions& subscriberOptions, const mepoo::MemoryInfo& memoryInfo) noexcept { - return m_portPoolData->m_subscriberPortMembers.insert( + auto port = getSubscriberPortDataList().emplace( serviceDescription, runtimeName, (subscriberOptions.queueFullPolicy == popo::QueueFullPolicy::DISCARD_OLDEST_DATA) @@ -35,6 +35,12 @@ inline iox::popo::SubscriberPortData* PortPool::constructSubscriber(const capro: : cxx::VariantQueueTypes::FiFo_MultiProducerSingleConsumer, subscriberOptions, memoryInfo); + if (port == getSubscriberPortDataList().end()) + { + return nullptr; + } + + return port.to_ptr(); } template ::value>*> @@ -43,7 +49,7 @@ inline iox::popo::SubscriberPortData* PortPool::constructSubscriber(const capro: const popo::SubscriberOptions& subscriberOptions, const mepoo::MemoryInfo& memoryInfo) noexcept { - return m_portPoolData->m_subscriberPortMembers.insert( + auto port = getSubscriberPortDataList().emplace( serviceDescription, runtimeName, (subscriberOptions.queueFullPolicy == popo::QueueFullPolicy::DISCARD_OLDEST_DATA) @@ -51,6 +57,12 @@ inline iox::popo::SubscriberPortData* PortPool::constructSubscriber(const capro: : cxx::VariantQueueTypes::FiFo_SingleProducerSingleConsumer, subscriberOptions, memoryInfo); + if (port == getSubscriberPortDataList().end()) + { + return nullptr; + } + + return port.to_ptr(); } } // namespace roudi } // namespace iox diff --git a/iceoryx_posh/source/roudi/port_manager.cpp b/iceoryx_posh/source/roudi/port_manager.cpp index 7692771023a..d323f2ad81a 100644 --- a/iceoryx_posh/source/roudi/port_manager.cpp +++ b/iceoryx_posh/source/roudi/port_manager.cpp @@ -130,16 +130,19 @@ void PortManager::doDiscovery() noexcept void PortManager::handlePublisherPorts() noexcept { // get the changes of publisher port offer state - for (auto publisherPortData : m_portPool->getPublisherPortDataList()) + auto& publisherPorts = m_portPool->getPublisherPortDataList(); + auto port = publisherPorts.begin(); + while (port != publisherPorts.end()) { - PublisherPortRouDiType publisherPort(publisherPortData); + auto currentPort = port++; + PublisherPortRouDiType publisherPort(currentPort.to_ptr()); doDiscoveryForPublisherPort(publisherPort); // check if we have to destroy this publisher port if (publisherPort.toBeDestroyed()) { - destroyPublisherPort(publisherPortData); + destroyPublisherPort(currentPort.to_ptr()); } } } @@ -177,16 +180,19 @@ void PortManager::doDiscoveryForPublisherPort(PublisherPortRouDiType& publisherP void PortManager::handleSubscriberPorts() noexcept { // get requests for change of subscription state of subscribers - for (auto subscriberPortData : m_portPool->getSubscriberPortDataList()) + auto& subscriberPorts = m_portPool->getSubscriberPortDataList(); + auto port = subscriberPorts.begin(); + while (port != subscriberPorts.end()) { - SubscriberPortType subscriberPort(subscriberPortData); + auto currentPort = port++; + SubscriberPortType subscriberPort(currentPort.to_ptr()); doDiscoveryForSubscriberPort(subscriberPort); // check if we have to destroy this subscriber port if (subscriberPort.toBeDestroyed()) { - destroySubscriberPort(subscriberPortData); + destroySubscriberPort(currentPort.to_ptr()); } } } @@ -258,16 +264,19 @@ void PortManager::destroyClientPort(popo::ClientPortData* const clientPortData) void PortManager::handleClientPorts() noexcept { // get requests for change of connection state of clients - for (auto clientPortData : m_portPool->getClientPortDataList()) + auto& clientPorts = m_portPool->getClientPortDataList(); + auto port = clientPorts.begin(); + while (port != clientPorts.end()) { - popo::ClientPortRouDi clientPort(*clientPortData); + auto currentPort = port++; + popo::ClientPortRouDi clientPort(*currentPort); doDiscoveryForClientPort(clientPort); // check if we have to destroy this clinet port if (clientPort.toBeDestroyed()) { - destroyClientPort(clientPortData); + destroyClientPort(currentPort.to_ptr()); } } } @@ -306,11 +315,11 @@ void PortManager::doDiscoveryForClientPort(popo::ClientPortRouDi& clientPort) no void PortManager::makeAllServerPortsToStopOffer() noexcept { - for (auto port : m_portPool->getServerPortDataList()) + for (auto& port : m_portPool->getServerPortDataList()) { - port->m_offeringRequested.store(false, std::memory_order_relaxed); + port.m_offeringRequested.store(false, std::memory_order_relaxed); - popo::ServerPortRouDi serverPort(*port); + popo::ServerPortRouDi serverPort(port); doDiscoveryForServerPort(serverPort); } } @@ -351,16 +360,19 @@ void PortManager::destroyServerPort(popo::ServerPortData* const serverPortData) void PortManager::handleServerPorts() noexcept { // get the changes of server port offer state - for (auto serverPortData : m_portPool->getServerPortDataList()) + auto& serverPorts = m_portPool->getServerPortDataList(); + auto port = serverPorts.begin(); + while (port != serverPorts.end()) { - popo::ServerPortRouDi serverPort(*serverPortData); + auto currentPort = port++; + popo::ServerPortRouDi serverPort(*currentPort); doDiscoveryForServerPort(serverPort); // check if we have to destroy this server port if (serverPort.toBeDestroyed()) { - destroyServerPort(serverPortData); + destroyServerPort(currentPort.to_ptr()); } } } @@ -400,22 +412,25 @@ void PortManager::handleInterfaces() noexcept vector interfacePortsForInitialForwarding; - for (auto interfacePortData : m_portPool->getInterfacePortDataList()) + auto& interfacePorts = m_portPool->getInterfacePortDataList(); + auto port = interfacePorts.begin(); + while (port != interfacePorts.end()) { - if (interfacePortData->m_doInitialOfferForward) + auto currentPort = port++; + if (currentPort->m_doInitialOfferForward) { - interfacePortsForInitialForwarding.push_back(interfacePortData); - interfacePortData->m_doInitialOfferForward = false; + interfacePortsForInitialForwarding.push_back(currentPort.to_ptr()); + currentPort->m_doInitialOfferForward = false; } // check if we have to destroy this interface port - if (interfacePortData->m_toBeDestroyed.load(std::memory_order_relaxed)) + if (currentPort->m_toBeDestroyed.load(std::memory_order_relaxed)) { IOX_LOG(DEBUG, - "Destroy interface port from runtime '" << interfacePortData->m_runtimeName + "Destroy interface port from runtime '" << currentPort->m_runtimeName << "' and with service description '" - << interfacePortData->m_serviceDescription << "'"); - m_portPool->removeInterfacePort(interfacePortData); + << currentPort->m_serviceDescription << "'"); + m_portPool->removeInterfacePort(currentPort.to_ptr()); } } @@ -425,9 +440,9 @@ void PortManager::handleInterfaces() noexcept capro::CaproMessage caproMessage; caproMessage.m_type = capro::CaproMessageType::OFFER; caproMessage.m_serviceType = capro::CaproServiceType::PUBLISHER; - for (auto publisherPortData : m_portPool->getPublisherPortDataList()) + for (auto& publisherPortData : m_portPool->getPublisherPortDataList()) { - PublisherPortUserType publisherPort(publisherPortData); + PublisherPortUserType publisherPort(&publisherPortData); if (publisherPort.isOffered()) { caproMessage.m_serviceDescription = publisherPort.getCaProServiceDescription(); @@ -445,9 +460,9 @@ void PortManager::handleInterfaces() noexcept } // provide offer information from all active server ports to all new interfaces caproMessage.m_serviceType = capro::CaproServiceType::SERVER; - for (auto serverPortData : m_portPool->getServerPortDataList()) + for (auto& serverPortData : m_portPool->getServerPortDataList()) { - popo::ServerPortUser serverPort(*serverPortData); + popo::ServerPortUser serverPort(serverPortData); if (serverPort.isOffered()) { caproMessage.m_serviceDescription = serverPort.getCaProServiceDescription(); @@ -473,27 +488,32 @@ void PortManager::handleNodes() noexcept // m_processIntrospection->removeNode(RuntimeName_t(process.c_str()), // NodeName_t(node.c_str())); - for (auto nodeData : m_portPool->getNodeDataList()) + auto& nodes = m_portPool->getNodeDataList(); + auto node = nodes.begin(); + while (node != nodes.end()) { - if (nodeData->m_toBeDestroyed.load(std::memory_order_relaxed)) + auto currentNode = node++; + if (currentNode->m_toBeDestroyed.load(std::memory_order_relaxed)) { IOX_LOG(DEBUG, - "Destroy NodeData from runtime '" << nodeData->m_runtimeName << "' and node name '" - << nodeData->m_nodeName << "'"); - m_portPool->removeNodeData(nodeData); + "Destroy NodeData from runtime '" << currentNode->m_runtimeName << "' and node name '" + << currentNode->m_nodeName << "'"); + m_portPool->removeNodeData(currentNode.to_ptr()); } } } void PortManager::handleConditionVariables() noexcept { - for (auto conditionVariableData : m_portPool->getConditionVariableDataList()) + auto& condVars = m_portPool->getConditionVariableDataList(); + auto condVar = condVars.begin(); + while (condVar != condVars.end()) { - if (conditionVariableData->m_toBeDestroyed.load(std::memory_order_relaxed)) + auto currentCondVar = condVar++; + if (currentCondVar->m_toBeDestroyed.load(std::memory_order_relaxed)) { - IOX_LOG(DEBUG, - "Destroy ConditionVariableData from runtime '" << conditionVariableData->m_runtimeName << "'"); - m_portPool->removeConditionVariableData(conditionVariableData); + IOX_LOG(DEBUG, "Destroy ConditionVariableData from runtime '" << currentCondVar->m_runtimeName << "'"); + m_portPool->removeConditionVariableData(currentCondVar.to_ptr()); } } } @@ -522,9 +542,9 @@ bool PortManager::sendToAllMatchingPublisherPorts(const capro::CaproMessage& mes SubscriberPortType& subscriberSource) noexcept { bool publisherFound = false; - for (auto publisherPortData : m_portPool->getPublisherPortDataList()) + for (auto& publisherPortData : m_portPool->getPublisherPortDataList()) { - PublisherPortRouDiType publisherPort(publisherPortData); + PublisherPortRouDiType publisherPort(&publisherPortData); auto messageInterface = message.m_serviceDescription.getSourceInterface(); auto publisherInterface = publisherPort.getCaProServiceDescription().getSourceInterface(); @@ -561,9 +581,9 @@ bool PortManager::sendToAllMatchingPublisherPorts(const capro::CaproMessage& mes void PortManager::sendToAllMatchingSubscriberPorts(const capro::CaproMessage& message, PublisherPortRouDiType& publisherSource) noexcept { - for (auto subscriberPortData : m_portPool->getSubscriberPortDataList()) + for (auto& subscriberPortData : m_portPool->getSubscriberPortDataList()) { - SubscriberPortType subscriberPort(subscriberPortData); + SubscriberPortType subscriberPort(&subscriberPortData); auto messageInterface = message.m_serviceDescription.getSourceInterface(); auto subscriberInterface = subscriberPort.getCaProServiceDescription().getSourceInterface(); @@ -628,9 +648,9 @@ bool PortManager::isCompatibleClientServer(const popo::ServerPortRouDi& server, void PortManager::sendToAllMatchingClientPorts(const capro::CaproMessage& message, popo::ServerPortRouDi& serverSource) noexcept { - for (auto clientPortData : m_portPool->getClientPortDataList()) + for (auto& clientPortData : m_portPool->getClientPortDataList()) { - popo::ClientPortRouDi clientPort(*clientPortData); + popo::ClientPortRouDi clientPort(clientPortData); if (isCompatibleClientServer(serverSource, clientPort)) { // send OFFER/STOP_OFFER to client @@ -665,9 +685,9 @@ bool PortManager::sendToAllMatchingServerPorts(const capro::CaproMessage& messag popo::ClientPortRouDi& clientSource) noexcept { bool serverFound = false; - for (auto serverPortData : m_portPool->getServerPortDataList()) + for (auto& serverPortData : m_portPool->getServerPortDataList()) { - popo::ServerPortRouDi serverPort(*serverPortData); + popo::ServerPortRouDi serverPort(serverPortData); if (isCompatibleClientServer(serverPort, clientSource)) { // send CONNECT/DISCONNECT to server @@ -692,9 +712,9 @@ bool PortManager::sendToAllMatchingServerPorts(const capro::CaproMessage& messag void PortManager::sendToAllMatchingInterfacePorts(const capro::CaproMessage& message) noexcept { - for (auto interfacePortData : m_portPool->getInterfacePortDataList()) + for (auto& interfacePortData : m_portPool->getInterfacePortDataList()) { - iox::popo::InterfacePort interfacePort(interfacePortData); + iox::popo::InterfacePort interfacePort(&interfacePortData); // not to the interface the port is located if (message.m_serviceDescription.getSourceInterface() != interfacePort.getCaProServiceDescription().getSourceInterface()) @@ -706,22 +726,22 @@ void PortManager::sendToAllMatchingInterfacePorts(const capro::CaproMessage& mes void PortManager::unblockProcessShutdown(const RuntimeName_t& runtimeName) noexcept { - for (auto port : m_portPool->getPublisherPortDataList()) + for (auto& port : m_portPool->getPublisherPortDataList()) { - PublisherPortRouDiType publisherPort(port); + PublisherPortRouDiType publisherPort(&port); if (runtimeName == publisherPort.getRuntimeName()) { - port->m_offeringRequested.store(false, std::memory_order_relaxed); + port.m_offeringRequested.store(false, std::memory_order_relaxed); doDiscoveryForPublisherPort(publisherPort); } } - for (auto port : m_portPool->getServerPortDataList()) + for (auto& port : m_portPool->getServerPortDataList()) { - popo::ServerPortRouDi serverPort(*port); + popo::ServerPortRouDi serverPort(port); if (runtimeName == serverPort.getRuntimeName()) { - port->m_offeringRequested.store(false, std::memory_order_relaxed); + port.m_offeringRequested.store(false, std::memory_order_relaxed); doDiscoveryForServerPort(serverPort); } } @@ -735,11 +755,11 @@ void PortManager::unblockRouDiShutdown() noexcept void PortManager::makeAllPublisherPortsToStopOffer() noexcept { - for (auto port : m_portPool->getPublisherPortDataList()) + for (auto& port : m_portPool->getPublisherPortDataList()) { - port->m_offeringRequested.store(false, std::memory_order_relaxed); + port.m_offeringRequested.store(false, std::memory_order_relaxed); - PublisherPortRouDiType publisherPort(port); + PublisherPortRouDiType publisherPort(&port); doDiscoveryForPublisherPort(publisherPort); } } @@ -751,67 +771,88 @@ void PortManager::deletePortsOfProcess(const RuntimeName_t& runtimeName) noexcep { m_serviceRegistryPublisherPortData.reset(); } - for (auto port : m_portPool->getPublisherPortDataList()) + auto& publisherPorts = m_portPool->getPublisherPortDataList(); + auto publisherPort = publisherPorts.begin(); + while (publisherPort != publisherPorts.end()) { - PublisherPortRouDiType sender(port); + auto currentPort = publisherPort++; + PublisherPortRouDiType sender(currentPort.to_ptr()); if (runtimeName == sender.getRuntimeName()) { - destroyPublisherPort(port); + destroyPublisherPort(currentPort.to_ptr()); } } - for (auto port : m_portPool->getSubscriberPortDataList()) + auto& subscriberPorts = m_portPool->getSubscriberPortDataList(); + auto subscriberPort = subscriberPorts.begin(); + while (subscriberPort != subscriberPorts.end()) { - SubscriberPortUserType subscriber(port); + auto currentPort = subscriberPort++; + SubscriberPortUserType subscriber(currentPort.to_ptr()); if (runtimeName == subscriber.getRuntimeName()) { - destroySubscriberPort(port); + destroySubscriberPort(currentPort.to_ptr()); } } - for (auto port : m_portPool->getServerPortDataList()) + auto& serverPorts = m_portPool->getServerPortDataList(); + auto serverPort = serverPorts.begin(); + while (serverPort != serverPorts.end()) { - popo::ServerPortRouDi server(*port); + auto currentPort = serverPort++; + popo::ServerPortRouDi server(*currentPort); if (runtimeName == server.getRuntimeName()) { - destroyServerPort(port); + destroyServerPort(currentPort.to_ptr()); } } - for (auto port : m_portPool->getClientPortDataList()) + auto& clientPorts = m_portPool->getClientPortDataList(); + auto clientPort = clientPorts.begin(); + while (clientPort != clientPorts.end()) { - popo::ClientPortRouDi client(*port); + auto currentPort = clientPort++; + popo::ClientPortRouDi client(*currentPort); if (runtimeName == client.getRuntimeName()) { - destroyClientPort(port); + destroyClientPort(currentPort.to_ptr()); } } - for (auto port : m_portPool->getInterfacePortDataList()) + auto& interfacePorts = m_portPool->getInterfacePortDataList(); + auto interfacePort = interfacePorts.begin(); + while (interfacePort != interfacePorts.end()) { - popo::InterfacePort interface(port); + auto currentPort = interfacePort++; + popo::InterfacePort interface(currentPort.to_ptr()); if (runtimeName == interface.getRuntimeName()) { - m_portPool->removeInterfacePort(port); IOX_LOG(DEBUG, "Deleted Interface of application " << runtimeName); + m_portPool->removeInterfacePort(currentPort.to_ptr()); } } - for (auto nodeData : m_portPool->getNodeDataList()) + auto& nodes = m_portPool->getNodeDataList(); + auto node = nodes.begin(); + while (node != nodes.end()) { - if (runtimeName == nodeData->m_runtimeName) + auto currentNode = node++; + if (runtimeName == currentNode->m_runtimeName) { - m_portPool->removeNodeData(nodeData); IOX_LOG(DEBUG, "Deleted node of application " << runtimeName); + m_portPool->removeNodeData(currentNode.to_ptr()); } } - for (auto conditionVariableData : m_portPool->getConditionVariableDataList()) + auto& condVars = m_portPool->getConditionVariableDataList(); + auto condVar = condVars.begin(); + while (condVar != condVars.end()) { - if (runtimeName == conditionVariableData->m_runtimeName) + auto currentCondVar = condVar++; + if (runtimeName == currentCondVar->m_runtimeName) { - m_portPool->removeConditionVariableData(conditionVariableData); IOX_LOG(DEBUG, "Deleted condition variable of application" << runtimeName); + m_portPool->removeConditionVariableData(currentCondVar.to_ptr()); } } } @@ -1021,20 +1062,24 @@ PortManager::acquireServerPortData(const capro::ServiceDescription& service, { // it is not allowed to have two servers with the same ServiceDescription; // check if the server is already in the list - for (const auto serverPortData : m_portPool->getServerPortDataList()) + auto& serverPorts = m_portPool->getServerPortDataList(); + auto port = serverPorts.begin(); + while (port != serverPorts.end()) { - if (service == serverPortData->m_serviceDescription) + auto currentPort = port++; + + if (service == currentPort->m_serviceDescription) { - if (serverPortData->m_toBeDestroyed) + if (currentPort->m_toBeDestroyed) { - destroyServerPort(serverPortData); + destroyServerPort(currentPort.to_ptr()); continue; } IOX_LOG(WARN, "Process '" << runtimeName << "' violates the communication policy by requesting a ServerPort which is already used by '" - << serverPortData->m_runtimeName << "' with service '" + << currentPort->m_runtimeName << "' with service '" << service.operator cxx::Serialization().toString() << "'."); errorHandler(PoshError::POSH__PORT_MANAGER_SERVERPORT_NOT_UNIQUE, ErrorLevel::MODERATE); return err(PortPoolError::UNIQUE_SERVER_PORT_ALREADY_EXISTS); diff --git a/iceoryx_posh/source/roudi/port_pool.cpp b/iceoryx_posh/source/roudi/port_pool.cpp index e1b092b2f4c..8aad8ac5078 100644 --- a/iceoryx_posh/source/roudi/port_pool.cpp +++ b/iceoryx_posh/source/roudi/port_pool.cpp @@ -27,70 +27,60 @@ PortPool::PortPool(PortPoolData& portPoolData) noexcept { } -vector PortPool::getInterfacePortDataList() noexcept +PortPoolData::InterfaceContainer& PortPool::getInterfacePortDataList() noexcept { - return m_portPoolData->m_interfacePortMembers.content(); + return m_portPoolData->m_interfacePortMembers; } -vector PortPool::getNodeDataList() noexcept +PortPoolData::NodeContainer& PortPool::getNodeDataList() noexcept { - return m_portPoolData->m_nodeMembers.content(); + return m_portPoolData->m_nodeMembers; } -vector -PortPool::getConditionVariableDataList() noexcept +PortPoolData::CondVarContainer& PortPool::getConditionVariableDataList() noexcept { - return m_portPoolData->m_conditionVariableMembers.content(); + return m_portPoolData->m_conditionVariableMembers; } expected PortPool::addInterfacePort(const RuntimeName_t& runtimeName, const capro::Interfaces interface) noexcept { - if (m_portPoolData->m_interfacePortMembers.hasFreeSpace()) - { - auto interfacePortData = m_portPoolData->m_interfacePortMembers.insert(runtimeName, interface); - return ok(interfacePortData); - } - else + auto interfacePortData = getInterfacePortDataList().emplace(runtimeName, interface); + if (interfacePortData == getInterfacePortDataList().end()) { IOX_LOG(WARN, "Out of interface ports! Requested by runtime '" << runtimeName << "'"); errorHandler(PoshError::PORT_POOL__INTERFACELIST_OVERFLOW, ErrorLevel::MODERATE); return err(PortPoolError::INTERFACE_PORT_LIST_FULL); } + return ok(interfacePortData.to_ptr()); } expected PortPool::addNodeData(const RuntimeName_t& runtimeName, const NodeName_t& nodeName, const uint64_t nodeDeviceIdentifier) noexcept { - if (m_portPoolData->m_nodeMembers.hasFreeSpace()) - { - auto nodeData = m_portPoolData->m_nodeMembers.insert(runtimeName, nodeName, nodeDeviceIdentifier); - return ok(nodeData); - } - else + auto nodeData = getNodeDataList().emplace(runtimeName, nodeName, nodeDeviceIdentifier); + if (nodeData == getNodeDataList().end()) { IOX_LOG(WARN, "Out of node data! Requested by runtime '" << runtimeName << "' and node name '" << nodeName << "'"); errorHandler(PoshError::PORT_POOL__NODELIST_OVERFLOW, ErrorLevel::MODERATE); return err(PortPoolError::NODE_DATA_LIST_FULL); } + return ok(nodeData.to_ptr()); } expected PortPool::addConditionVariableData(const RuntimeName_t& runtimeName) noexcept { - if (m_portPoolData->m_conditionVariableMembers.hasFreeSpace()) - { - auto conditionVariableData = m_portPoolData->m_conditionVariableMembers.insert(runtimeName); - return ok(conditionVariableData); - } - else + auto conditionVariableData = getConditionVariableDataList().emplace(runtimeName); + if (conditionVariableData == getConditionVariableDataList().end()) { IOX_LOG(WARN, "Out of condition variables! Requested by runtime '" << runtimeName << "'"); errorHandler(PoshError::PORT_POOL__CONDITION_VARIABLE_LIST_OVERFLOW, ErrorLevel::MODERATE); return err(PortPoolError::CONDITION_VARIABLE_LIST_FULL); } + return ok(conditionVariableData.to_ptr()); } void PortPool::removeInterfacePort(const popo::InterfacePortData* const portData) noexcept @@ -108,14 +98,14 @@ void PortPool::removeConditionVariableData(const popo::ConditionVariableData* co m_portPoolData->m_conditionVariableMembers.erase(conditionVariableData); } -vector PortPool::getPublisherPortDataList() noexcept +PortPoolData::PublisherContainer& PortPool::getPublisherPortDataList() noexcept { - return m_portPoolData->m_publisherPortMembers.content(); + return m_portPoolData->m_publisherPortMembers; } -vector PortPool::getSubscriberPortDataList() noexcept +PortPoolData::SubscriberContainer& PortPool::getSubscriberPortDataList() noexcept { - return m_portPoolData->m_subscriberPortMembers.content(); + return m_portPoolData->m_subscriberPortMembers; } expected @@ -125,13 +115,9 @@ PortPool::addPublisherPort(const capro::ServiceDescription& serviceDescription, const popo::PublisherOptions& publisherOptions, const mepoo::MemoryInfo& memoryInfo) noexcept { - if (m_portPoolData->m_publisherPortMembers.hasFreeSpace()) - { - auto publisherPortData = m_portPoolData->m_publisherPortMembers.insert( - serviceDescription, runtimeName, memoryManager, publisherOptions, memoryInfo); - return ok(publisherPortData); - } - else + auto publisherPortData = getPublisherPortDataList().emplace( + serviceDescription, runtimeName, memoryManager, publisherOptions, memoryInfo); + if (publisherPortData == getPublisherPortDataList().end()) { IOX_LOG(WARN, "Out of publisher ports! Requested by runtime '" << runtimeName << "' and with service description '" @@ -139,6 +125,7 @@ PortPool::addPublisherPort(const capro::ServiceDescription& serviceDescription, errorHandler(PoshError::PORT_POOL__PUBLISHERLIST_OVERFLOW, ErrorLevel::MODERATE); return err(PortPoolError::PUBLISHER_PORT_LIST_FULL); } + return ok(publisherPortData.to_ptr()); } expected @@ -147,14 +134,9 @@ PortPool::addSubscriberPort(const capro::ServiceDescription& serviceDescription, const popo::SubscriberOptions& subscriberOptions, const mepoo::MemoryInfo& memoryInfo) noexcept { - if (m_portPoolData->m_subscriberPortMembers.hasFreeSpace()) - { - auto subscriberPortData = constructSubscriber( - serviceDescription, runtimeName, subscriberOptions, memoryInfo); - - return ok(subscriberPortData); - } - else + auto* subscriberPortData = constructSubscriber( + serviceDescription, runtimeName, subscriberOptions, memoryInfo); + if (subscriberPortData == nullptr) { IOX_LOG(WARN, "Out of subscriber ports! Requested by runtime '" << runtimeName << "' and with service description '" @@ -162,16 +144,17 @@ PortPool::addSubscriberPort(const capro::ServiceDescription& serviceDescription, errorHandler(PoshError::PORT_POOL__SUBSCRIBERLIST_OVERFLOW, ErrorLevel::MODERATE); return err(PortPoolError::SUBSCRIBER_PORT_LIST_FULL); } + return ok(subscriberPortData); } -vector PortPool::getClientPortDataList() noexcept +PortPoolData::ClientContainer& PortPool::getClientPortDataList() noexcept { - return m_portPoolData->m_clientPortMembers.content(); + return m_portPoolData->m_clientPortMembers; } -vector PortPool::getServerPortDataList() noexcept +PortPoolData::ServerContainer& PortPool::getServerPortDataList() noexcept { - return m_portPoolData->m_serverPortMembers.content(); + return m_portPoolData->m_serverPortMembers; } expected @@ -181,7 +164,9 @@ PortPool::addClientPort(const capro::ServiceDescription& serviceDescription, const popo::ClientOptions& clientOptions, const mepoo::MemoryInfo& memoryInfo) noexcept { - if (!m_portPoolData->m_clientPortMembers.hasFreeSpace()) + auto clientPortData = + getClientPortDataList().emplace(serviceDescription, runtimeName, clientOptions, memoryManager, memoryInfo); + if (clientPortData == getClientPortDataList().end()) { IOX_LOG(WARN, "Out of client ports! Requested by runtime '" << runtimeName << "' and with service description '" @@ -189,10 +174,7 @@ PortPool::addClientPort(const capro::ServiceDescription& serviceDescription, errorHandler(PoshError::PORT_POOL__CLIENTLIST_OVERFLOW, ErrorLevel::MODERATE); return err(PortPoolError::CLIENT_PORT_LIST_FULL); } - - auto clientPortData = m_portPoolData->m_clientPortMembers.insert( - serviceDescription, runtimeName, clientOptions, memoryManager, memoryInfo); - return ok(clientPortData); + return ok(clientPortData.to_ptr()); } expected @@ -202,7 +184,9 @@ PortPool::addServerPort(const capro::ServiceDescription& serviceDescription, const popo::ServerOptions& serverOptions, const mepoo::MemoryInfo& memoryInfo) noexcept { - if (!m_portPoolData->m_serverPortMembers.hasFreeSpace()) + auto serverPortData = + getServerPortDataList().emplace(serviceDescription, runtimeName, serverOptions, memoryManager, memoryInfo); + if (serverPortData == getServerPortDataList().end()) { IOX_LOG(WARN, "Out of server ports! Requested by runtime '" << runtimeName << "' and with service description '" @@ -210,10 +194,7 @@ PortPool::addServerPort(const capro::ServiceDescription& serviceDescription, errorHandler(PoshError::PORT_POOL__SERVERLIST_OVERFLOW, ErrorLevel::MODERATE); return err(PortPoolError::SERVER_PORT_LIST_FULL); } - - auto serverPortData = m_portPoolData->m_serverPortMembers.insert( - serviceDescription, runtimeName, serverOptions, memoryManager, memoryInfo); - return ok(serverPortData); + return ok(serverPortData.to_ptr()); } void PortPool::removePublisherPort(const PublisherPortRouDiType::MemberType_t* const portData) noexcept diff --git a/iceoryx_posh/test/moduletests/test_roudi_portpool.cpp b/iceoryx_posh/test/moduletests/test_roudi_portpool.cpp index 79aa4ef0338..10139df59bd 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_portpool.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_portpool.cpp @@ -155,20 +155,20 @@ TEST_F(PortPool_test, GetNodeDataListIsSuccessful) ::testing::Test::RecordProperty("TEST_ID", "5a86e0ed-e61a-4f45-9aab-2b38a22730a9"); ASSERT_FALSE(sut.addNodeData(m_runtimeName, m_nodeName, m_nodeDeviceId).has_error()); - auto nodeDataList = sut.getNodeDataList(); + EXPECT_EQ(sut.getNodeDataList().size(), 1U); - EXPECT_EQ(nodeDataList.size(), 1U); - EXPECT_EQ(nodeDataList[0]->m_runtimeName, m_runtimeName); - EXPECT_EQ(nodeDataList[0]->m_nodeName, m_nodeName); - EXPECT_EQ(nodeDataList[0]->m_nodeDeviceIdentifier, m_nodeDeviceId); + auto node = sut.getNodeDataList().begin(); + + EXPECT_EQ(node->m_runtimeName, m_runtimeName); + EXPECT_EQ(node->m_nodeName, m_nodeName); + EXPECT_EQ(node->m_nodeDeviceIdentifier, m_nodeDeviceId); } TEST_F(PortPool_test, GetNodeDataListWhenEmptyIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "c5f629bd-b9ea-4d41-b991-5654e20dae3b"); - auto nodeDataList = sut.getNodeDataList(); - EXPECT_EQ(nodeDataList.size(), 0U); + EXPECT_EQ(sut.getNodeDataList().size(), 0U); } TEST_F(PortPool_test, GetNodeDataListWithMaxCapacityIsSuccessful) @@ -181,9 +181,7 @@ TEST_F(PortPool_test, GetNodeDataListWithMaxCapacityIsSuccessful) ASSERT_THAT(nodeData.has_error(), Eq(false)); } - auto nodeDataList = sut.getNodeDataList(); - - EXPECT_EQ(nodeDataList.size(), MAX_NODE_NUMBER); + EXPECT_EQ(sut.getNodeDataList().size(), MAX_NODE_NUMBER); } TEST_F(PortPool_test, RemoveNodeDataIsSuccessful) @@ -192,9 +190,8 @@ TEST_F(PortPool_test, RemoveNodeDataIsSuccessful) auto nodeData = sut.addNodeData(m_runtimeName, m_nodeName, m_nodeDeviceId); sut.removeNodeData(nodeData.value()); - auto nodeDataList = sut.getNodeDataList(); - EXPECT_EQ(nodeDataList.size(), 0U); + EXPECT_EQ(sut.getNodeDataList().size(), 0U); } // END Node tests @@ -274,23 +271,20 @@ TEST_F(PortPool_test, AddPublisherPortWhenPublisherListOverflowsReturnsError) TEST_F(PortPool_test, GetPublisherPortDataListIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "1650a6e0-8079-4ac4-ad03-723a7fc70217"); - auto publisherPortDataList = sut.getPublisherPortDataList(); - EXPECT_EQ(publisherPortDataList.size(), 0U); + EXPECT_EQ(sut.getPublisherPortDataList().size(), 0U); ASSERT_FALSE(sut.addPublisherPort(m_serviceDescription, &m_memoryManager, m_applicationName, m_publisherOptions) .has_error()); - publisherPortDataList = sut.getPublisherPortDataList(); - EXPECT_EQ(publisherPortDataList.size(), 1U); + EXPECT_EQ(sut.getPublisherPortDataList().size(), 1U); } TEST_F(PortPool_test, GetPublisherPortDataListWhenEmptyIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "01fc41aa-4961-4bb6-98b7-a35ca3f93c1d"); - auto nodeDataList = sut.getPublisherPortDataList(); - EXPECT_EQ(nodeDataList.size(), 0U); + EXPECT_EQ(sut.getPublisherPortDataList().size(), 0U); } TEST_F(PortPool_test, GetPublisherPortDataListCompletelyFilledSuccessfully) @@ -309,9 +303,7 @@ TEST_F(PortPool_test, GetPublisherPortDataListCompletelyFilledSuccessfully) .has_error()); } - auto publisherPortDataList = sut.getPublisherPortDataList(); - - EXPECT_EQ(publisherPortDataList.size(), MAX_PUBLISHERS); + EXPECT_EQ(sut.getPublisherPortDataList().size(), MAX_PUBLISHERS); } TEST_F(PortPool_test, RemovePublisherPortIsSuccessful) @@ -320,9 +312,8 @@ TEST_F(PortPool_test, RemovePublisherPortIsSuccessful) auto publisherPort = sut.addPublisherPort(m_serviceDescription, &m_memoryManager, m_applicationName, m_publisherOptions); sut.removePublisherPort(publisherPort.value()); - auto publisherPortDataList = sut.getPublisherPortDataList(); - EXPECT_EQ(publisherPortDataList.size(), 0U); + EXPECT_EQ(sut.getPublisherPortDataList().size(), 0U); } // END PublisherPort tests @@ -407,17 +398,15 @@ TEST_F(PortPool_test, GetSubscriberPortDataListIsSuccessful) ::testing::Test::RecordProperty("TEST_ID", "391bba2f-e6f7-4dec-9ffb-67a69cd9a059"); auto subscriberPort = sut.addSubscriberPort(m_serviceDescription, m_applicationName, m_subscriberOptions); EXPECT_FALSE(subscriberPort.has_error()); - auto subscriberPortDataList = sut.getSubscriberPortDataList(); - ASSERT_EQ(subscriberPortDataList.size(), 1U); + ASSERT_EQ(sut.getSubscriberPortDataList().size(), 1U); } TEST_F(PortPool_test, GetSubscriberPortDataListWhenEmptyIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "a525a8b7-98f3-4c01-a85f-c8c7cc741e09"); - auto nodeDataList = sut.getSubscriberPortDataList(); - ASSERT_EQ(nodeDataList.size(), 0U); + ASSERT_EQ(sut.getSubscriberPortDataList().size(), 0U); } TEST_F(PortPool_test, GetSubscriberPortDataListCompletelyFilledIsSuccessful) @@ -435,9 +424,8 @@ TEST_F(PortPool_test, GetSubscriberPortDataListCompletelyFilledIsSuccessful) m_subscriberOptions); EXPECT_FALSE(publisherPort.has_error()); } - auto subscriberPortDataList = sut.getSubscriberPortDataList(); - ASSERT_EQ(subscriberPortDataList.size(), MAX_SUBSCRIBERS); + ASSERT_EQ(sut.getSubscriberPortDataList().size(), MAX_SUBSCRIBERS); } TEST_F(PortPool_test, RemoveSubscriberPortIsSuccessful) @@ -446,9 +434,8 @@ TEST_F(PortPool_test, RemoveSubscriberPortIsSuccessful) auto subscriberPort = sut.addSubscriberPort(m_serviceDescription, m_applicationName, m_subscriberOptions); sut.removeSubscriberPort(subscriberPort.value()); - auto subscriberPortDataList = sut.getSubscriberPortDataList(); - EXPECT_EQ(subscriberPortDataList.size(), 0U); + EXPECT_EQ(sut.getSubscriberPortDataList().size(), 0U); } // END SubscriberPort tests @@ -520,17 +507,14 @@ TEST_F(PortPool_test, GetClientPortDataListIsSuccessful) auto addSuccessful = addClientPorts(NUMBER_OF_CLIENTS_TO_ADD, [&](const auto&, const auto&, const auto&) {}); EXPECT_TRUE(addSuccessful); - auto clientPortDataList = sut.getClientPortDataList(); - - ASSERT_EQ(clientPortDataList.size(), NUMBER_OF_CLIENTS_TO_ADD); + ASSERT_EQ(sut.getClientPortDataList().size(), NUMBER_OF_CLIENTS_TO_ADD); } TEST_F(PortPool_test, GetClientPortDataListWhenEmptyIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "6c08ae7d-1eed-46d6-b363-b2dc294d0e0e"); - auto clientPortDataList = sut.getClientPortDataList(); - ASSERT_EQ(clientPortDataList.size(), 0U); + ASSERT_EQ(sut.getClientPortDataList().size(), 0U); } TEST_F(PortPool_test, GetClientPortDataListCompletelyFilledIsSuccessful) @@ -540,9 +524,7 @@ TEST_F(PortPool_test, GetClientPortDataListCompletelyFilledIsSuccessful) auto addSuccessful = addClientPorts(NUMBER_OF_CLIENTS_TO_ADD, [&](const auto&, const auto&, const auto&) {}); EXPECT_TRUE(addSuccessful); - auto clientPortDataList = sut.getClientPortDataList(); - - ASSERT_EQ(clientPortDataList.size(), MAX_CLIENTS); + ASSERT_EQ(sut.getClientPortDataList().size(), MAX_CLIENTS); } TEST_F(PortPool_test, RemoveClientPortIsSuccessful) @@ -554,9 +536,7 @@ TEST_F(PortPool_test, RemoveClientPortIsSuccessful) [&](const auto&, const auto&, const auto& clientPort) { sut.removeClientPort(&clientPort); }); EXPECT_TRUE(addSuccessful); - auto clientPortDataList = sut.getClientPortDataList(); - - EXPECT_EQ(clientPortDataList.size(), 0U); + EXPECT_EQ(sut.getClientPortDataList().size(), 0U); } // END ClientPort tests @@ -628,17 +608,14 @@ TEST_F(PortPool_test, GetServerPortDataListIsSuccessful) auto addSuccessful = addServerPorts(NUMBER_OF_SERVERS_TO_ADD, [&](const auto&, const auto&, const auto&) {}); EXPECT_TRUE(addSuccessful); - auto serverPortDataList = sut.getServerPortDataList(); - - ASSERT_EQ(serverPortDataList.size(), NUMBER_OF_SERVERS_TO_ADD); + ASSERT_EQ(sut.getServerPortDataList().size(), NUMBER_OF_SERVERS_TO_ADD); } TEST_F(PortPool_test, GetServerPortDataListWhenEmptyIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "d1b32417-caeb-4a5c-ae40-49d651b418cd"); - auto serverPortDataList = sut.getServerPortDataList(); - ASSERT_EQ(serverPortDataList.size(), 0U); + ASSERT_EQ(sut.getServerPortDataList().size(), 0U); } TEST_F(PortPool_test, GetServerPortDataListCompletelyFilledIsSuccessful) @@ -648,9 +625,7 @@ TEST_F(PortPool_test, GetServerPortDataListCompletelyFilledIsSuccessful) auto addSuccessful = addServerPorts(NUMBER_OF_SERVERS_TO_ADD, [&](const auto&, const auto&, const auto&) {}); EXPECT_TRUE(addSuccessful); - auto serverPortDataList = sut.getServerPortDataList(); - - ASSERT_EQ(serverPortDataList.size(), MAX_SERVERS); + ASSERT_EQ(sut.getServerPortDataList().size(), MAX_SERVERS); } TEST_F(PortPool_test, RemoveServerPortIsSuccessful) @@ -662,9 +637,7 @@ TEST_F(PortPool_test, RemoveServerPortIsSuccessful) [&](const auto&, const auto&, const auto& serverPort) { sut.removeServerPort(&serverPort); }); EXPECT_TRUE(addSuccessful); - auto serverPortDataList = sut.getServerPortDataList(); - - EXPECT_EQ(serverPortDataList.size(), 0U); + EXPECT_EQ(sut.getServerPortDataList().size(), 0U); } // END ServerPort tests @@ -719,17 +692,15 @@ TEST_F(PortPool_test, GetInterfacePortDataListIsSuccessful) ::testing::Test::RecordProperty("TEST_ID", "0ed6bf52-2ffb-40f4-acab-a9f79532cde1"); auto interfacePort = sut.addInterfacePort(m_applicationName, Interfaces::INTERNAL); EXPECT_FALSE(interfacePort.has_error()); - auto interfacePortDataList = sut.getInterfacePortDataList(); - ASSERT_EQ(interfacePortDataList.size(), 1U); + ASSERT_EQ(sut.getInterfacePortDataList().size(), 1U); } TEST_F(PortPool_test, GetInterfacePortDataListWhenEmptyIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "80aab75f-5251-4c2e-9ab6-82b00c728a9c"); - auto interfacePortDataList = sut.getInterfacePortDataList(); - ASSERT_EQ(interfacePortDataList.size(), 0U); + ASSERT_EQ(sut.getInterfacePortDataList().size(), 0U); } TEST_F(PortPool_test, GetInterfacePortDataListCompletelyFilledIsSuccessful) @@ -740,9 +711,8 @@ TEST_F(PortPool_test, GetInterfacePortDataListCompletelyFilledIsSuccessful) RuntimeName_t applicationName = into>("AppName" + cxx::convert::toString(i)); ASSERT_FALSE(sut.addInterfacePort(applicationName, Interfaces::INTERNAL).has_error()); } - auto interfacePortDataList = sut.getInterfacePortDataList(); - ASSERT_EQ(interfacePortDataList.size(), MAX_INTERFACE_NUMBER); + ASSERT_EQ(sut.getInterfacePortDataList().size(), MAX_INTERFACE_NUMBER); } TEST_F(PortPool_test, RemoveInterfacePortIsSuccessful) @@ -751,9 +721,8 @@ TEST_F(PortPool_test, RemoveInterfacePortIsSuccessful) auto interfacePort = sut.addInterfacePort(m_applicationName, Interfaces::INTERNAL); sut.removeInterfacePort(interfacePort.value()); - auto interfacePortDataList = sut.getInterfacePortDataList(); - ASSERT_EQ(interfacePortDataList.size(), 0U); + ASSERT_EQ(sut.getInterfacePortDataList().size(), 0U); } // END InterfacePort tests @@ -806,17 +775,15 @@ TEST_F(PortPool_test, GetConditionVariableDataListIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "b128487c-f808-4eef-9c74-7ddeab5415d9"); ASSERT_FALSE(sut.addConditionVariableData(m_applicationName).has_error()); - auto condtionalVariableData = sut.getConditionVariableDataList(); - ASSERT_EQ(condtionalVariableData.size(), 1U); + ASSERT_EQ(sut.getConditionVariableDataList().size(), 1U); } TEST_F(PortPool_test, GetConditionVariableDataListWhenEmptyIsSuccessful) { ::testing::Test::RecordProperty("TEST_ID", "f70cc08d-9a50-4166-acfc-b2514bd7f571"); - auto condtionalVariableData = sut.getConditionVariableDataList(); - ASSERT_EQ(condtionalVariableData.size(), 0U); + ASSERT_EQ(sut.getConditionVariableDataList().size(), 0U); } TEST_F(PortPool_test, GetConditionVariableDataListCompletelyFilledIsSuccessful) @@ -827,9 +794,8 @@ TEST_F(PortPool_test, GetConditionVariableDataListCompletelyFilledIsSuccessful) RuntimeName_t applicationName = into>("AppName" + cxx::convert::toString(i)); ASSERT_FALSE(sut.addConditionVariableData(applicationName).has_error()); } - auto condtionalVariableData = sut.getConditionVariableDataList(); - ASSERT_EQ(condtionalVariableData.size(), MAX_NUMBER_OF_CONDITION_VARIABLES); + ASSERT_EQ(sut.getConditionVariableDataList().size(), MAX_NUMBER_OF_CONDITION_VARIABLES); } TEST_F(PortPool_test, RemoveConditionVariableDataIsSuccessful) @@ -838,9 +804,8 @@ TEST_F(PortPool_test, RemoveConditionVariableDataIsSuccessful) auto conditionVariableData = sut.addConditionVariableData(m_applicationName); sut.removeConditionVariableData(conditionVariableData.value()); - auto condtionalVariableData = sut.getConditionVariableDataList(); - ASSERT_EQ(condtionalVariableData.size(), 0U); + ASSERT_EQ(sut.getConditionVariableDataList().size(), 0U); } // END ConditionVariable tests