// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.// Copyright (c) 2020 - 2022 by Apex.AI Inc. 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_HPP#define IOX_POSH_ROUDI_PORT_POOL_HPP#include"iceoryx_hoofs/cxx/type_traits.hpp"#include"iceoryx_posh/iceoryx_posh_types.hpp"#include"iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"#include"iceoryx_posh/internal/popo/ports/client_port_data.hpp"#include"iceoryx_posh/internal/popo/ports/client_port_roudi.hpp"#include"iceoryx_posh/internal/popo/ports/interface_port.hpp"#include"iceoryx_posh/internal/popo/ports/publisher_port_data.hpp"#include"iceoryx_posh/internal/popo/ports/publisher_port_roudi.hpp"#include"iceoryx_posh/internal/popo/ports/server_port_data.hpp"#include"iceoryx_posh/internal/popo/ports/server_port_roudi.hpp"#include"iceoryx_posh/internal/popo/ports/subscriber_port_data.hpp"#include"iceoryx_posh/internal/popo/ports/subscriber_port_multi_producer.hpp"#include"iceoryx_posh/internal/popo/ports/subscriber_port_single_producer.hpp"#include"iceoryx_posh/internal/roudi/port_pool_data.hpp"#include"iceoryx_posh/internal/runtime/node_data.hpp"#include"iceoryx_posh/popo/client_options.hpp"#include"iceoryx_posh/popo/publisher_options.hpp"#include"iceoryx_posh/popo/server_options.hpp"#include"iceoryx_posh/popo/subscriber_options.hpp"namespaceiox{namespaceroudi{structPortPoolDataBase;enumclassPortPoolError:uint8_t{UNIQUE_PUBLISHER_PORT_ALREADY_EXISTS,INTERNAL_SERVICE_DESCRIPTION_IS_FORBIDDEN,PUBLISHER_PORT_LIST_FULL,SUBSCRIBER_PORT_LIST_FULL,INTERFACE_PORT_LIST_FULL,CLIENT_PORT_LIST_FULL,UNIQUE_SERVER_PORT_ALREADY_EXISTS,SERVER_PORT_LIST_FULL,NODE_DATA_LIST_FULL,CONDITION_VARIABLE_LIST_FULL,EVENT_VARIABLE_LIST_FULL,};classPortPool{public:PortPool(PortPoolData&portPoolData)noexcept;virtual~PortPool()noexcept=default;cxx::vector<PublisherPortRouDiType::MemberType_t*,MAX_PUBLISHERS>getPublisherPortDataList()noexcept;cxx::vector<SubscriberPortType::MemberType_t*,MAX_SUBSCRIBERS>getSubscriberPortDataList()noexcept;cxx::vector<popo::ClientPortData*,MAX_CLIENTS>getClientPortDataList()noexcept;cxx::vector<popo::ServerPortData*,MAX_SERVERS>getServerPortDataList()noexcept;cxx::vector<popo::InterfacePortData*,MAX_INTERFACE_NUMBER>getInterfacePortDataList()noexcept;cxx::vector<runtime::NodeData*,MAX_NODE_NUMBER>getNodeDataList()noexcept;cxx::vector<popo::ConditionVariableData*,MAX_NUMBER_OF_CONDITION_VARIABLES>getConditionVariableDataList()noexcept;cxx::expected<PublisherPortRouDiType::MemberType_t*,PortPoolError>addPublisherPort(constcapro::ServiceDescription&serviceDescription,mepoo::MemoryManager*constmemoryManager,constRuntimeName_t&runtimeName,constpopo::PublisherOptions&publisherOptions,constmepoo::MemoryInfo&memoryInfo=mepoo::MemoryInfo())noexcept;cxx::expected<SubscriberPortType::MemberType_t*,PortPoolError>addSubscriberPort(constcapro::ServiceDescription&serviceDescription,constRuntimeName_t&runtimeName,constpopo::SubscriberOptions&subscriberOptions,constmepoo::MemoryInfo&memoryInfo=mepoo::MemoryInfo())noexcept;template<typenameT,std::enable_if_t<std::is_same<T,iox::build::ManyToManyPolicy>::value>*=nullptr>iox::popo::SubscriberPortData*constructSubscriber(constcapro::ServiceDescription&serviceDescription,constRuntimeName_t&runtimeName,constpopo::SubscriberOptions&subscriberOptions,constmepoo::MemoryInfo&memoryInfo)noexcept;template<typenameT,std::enable_if_t<std::is_same<T,iox::build::OneToManyPolicy>::value>*=nullptr>iox::popo::SubscriberPortData*constructSubscriber(constcapro::ServiceDescription&serviceDescription,constRuntimeName_t&runtimeName,constpopo::SubscriberOptions&subscriberOptions,constmepoo::MemoryInfo&memoryInfo)noexcept;cxx::expected<popo::ClientPortData*,PortPoolError>addClientPort(constcapro::ServiceDescription&serviceDescription,mepoo::MemoryManager*constmemoryManager,constRuntimeName_t&runtimeName,constpopo::ClientOptions&clientOptions,constmepoo::MemoryInfo&memoryInfo=mepoo::MemoryInfo())noexcept;cxx::expected<popo::ServerPortData*,PortPoolError>addServerPort(constcapro::ServiceDescription&serviceDescription,mepoo::MemoryManager*constmemoryManager,constRuntimeName_t&runtimeName,constpopo::ServerOptions&serverOptions,constmepoo::MemoryInfo&memoryInfo=mepoo::MemoryInfo())noexcept;cxx::expected<popo::InterfacePortData*,PortPoolError>addInterfacePort(constRuntimeName_t&runtimeName,constcapro::Interfacesinterface)noexcept;cxx::expected<runtime::NodeData*,PortPoolError>addNodeData(constRuntimeName_t&runtimeName,constNodeName_t&nodeName,constuint64_tnodeDeviceIdentifier)noexcept;cxx::expected<popo::ConditionVariableData*,PortPoolError>addConditionVariableData(constRuntimeName_t&runtimeName)noexcept;voidremovePublisherPort(constPublisherPortRouDiType::MemberType_t*constportData)noexcept;voidremoveSubscriberPort(constSubscriberPortType::MemberType_t*constportData)noexcept;voidremoveClientPort(constpopo::ClientPortData*constportData)noexcept;voidremoveServerPort(constpopo::ServerPortData*constportData)noexcept;voidremoveInterfacePort(constpopo::InterfacePortData*constportData)noexcept;voidremoveNodeData(construntime::NodeData*constnodeData)noexcept;voidremoveConditionVariableData(constpopo::ConditionVariableData*constconditionVariableData)noexcept;private:PortPoolData*m_portPoolData;};}// namespace roudi}// namespace iox#include"iceoryx_posh/roudi/port_pool.inl"#endif // IOX_POSH_ROUDI_PORT_POOL_HPP