iceoryx_posh 2.0.3
port_pool.hpp
1// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16// SPDX-License-Identifier: Apache-2.0
17#ifndef IOX_POSH_ROUDI_PORT_POOL_HPP
18#define IOX_POSH_ROUDI_PORT_POOL_HPP
19
20#include "iceoryx_hoofs/cxx/type_traits.hpp"
21#include "iceoryx_posh/iceoryx_posh_types.hpp"
22#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
23#include "iceoryx_posh/internal/popo/ports/client_port_data.hpp"
24#include "iceoryx_posh/internal/popo/ports/client_port_roudi.hpp"
25#include "iceoryx_posh/internal/popo/ports/interface_port.hpp"
26#include "iceoryx_posh/internal/popo/ports/publisher_port_data.hpp"
27#include "iceoryx_posh/internal/popo/ports/publisher_port_roudi.hpp"
28#include "iceoryx_posh/internal/popo/ports/server_port_data.hpp"
29#include "iceoryx_posh/internal/popo/ports/server_port_roudi.hpp"
30#include "iceoryx_posh/internal/popo/ports/subscriber_port_data.hpp"
31#include "iceoryx_posh/internal/popo/ports/subscriber_port_multi_producer.hpp"
32#include "iceoryx_posh/internal/popo/ports/subscriber_port_single_producer.hpp"
33#include "iceoryx_posh/internal/roudi/port_pool_data.hpp"
34#include "iceoryx_posh/internal/runtime/node_data.hpp"
35#include "iceoryx_posh/popo/client_options.hpp"
36#include "iceoryx_posh/popo/publisher_options.hpp"
37#include "iceoryx_posh/popo/server_options.hpp"
38#include "iceoryx_posh/popo/subscriber_options.hpp"
39
40namespace iox
41{
42namespace roudi
43{
44struct PortPoolDataBase;
45
46enum class PortPoolError : uint8_t
47{
48 UNIQUE_PUBLISHER_PORT_ALREADY_EXISTS,
49 INTERNAL_SERVICE_DESCRIPTION_IS_FORBIDDEN,
50 PUBLISHER_PORT_LIST_FULL,
51 SUBSCRIBER_PORT_LIST_FULL,
52 INTERFACE_PORT_LIST_FULL,
53 CLIENT_PORT_LIST_FULL,
54 UNIQUE_SERVER_PORT_ALREADY_EXISTS,
55 SERVER_PORT_LIST_FULL,
56 NODE_DATA_LIST_FULL,
57 CONDITION_VARIABLE_LIST_FULL,
58 EVENT_VARIABLE_LIST_FULL,
59};
60
62{
63 public:
64 PortPool(PortPoolData& portPoolData) noexcept;
65
66 virtual ~PortPool() noexcept = default;
67
71 cxx::vector<PublisherPortRouDiType::MemberType_t*, MAX_PUBLISHERS> getPublisherPortDataList() noexcept;
72 cxx::vector<SubscriberPortType::MemberType_t*, MAX_SUBSCRIBERS> getSubscriberPortDataList() noexcept;
73 cxx::vector<popo::ClientPortData*, MAX_CLIENTS> getClientPortDataList() noexcept;
74 cxx::vector<popo::ServerPortData*, MAX_SERVERS> getServerPortDataList() noexcept;
75 cxx::vector<popo::InterfacePortData*, MAX_INTERFACE_NUMBER> getInterfacePortDataList() noexcept;
76 cxx::vector<runtime::NodeData*, MAX_NODE_NUMBER> getNodeDataList() noexcept;
77 cxx::vector<popo::ConditionVariableData*, MAX_NUMBER_OF_CONDITION_VARIABLES>
78 getConditionVariableDataList() noexcept;
79
80 cxx::expected<PublisherPortRouDiType::MemberType_t*, PortPoolError>
81 addPublisherPort(const capro::ServiceDescription& serviceDescription,
82 mepoo::MemoryManager* const memoryManager,
83 const RuntimeName_t& runtimeName,
84 const popo::PublisherOptions& publisherOptions,
85 const mepoo::MemoryInfo& memoryInfo = mepoo::MemoryInfo()) noexcept;
86
87 cxx::expected<SubscriberPortType::MemberType_t*, PortPoolError>
88 addSubscriberPort(const capro::ServiceDescription& serviceDescription,
89 const RuntimeName_t& runtimeName,
90 const popo::SubscriberOptions& subscriberOptions,
91 const mepoo::MemoryInfo& memoryInfo = mepoo::MemoryInfo()) noexcept;
92
93 template <typename T, std::enable_if_t<std::is_same<T, iox::build::ManyToManyPolicy>::value>* = nullptr>
94 iox::popo::SubscriberPortData* constructSubscriber(const capro::ServiceDescription& serviceDescription,
95 const RuntimeName_t& runtimeName,
96 const popo::SubscriberOptions& subscriberOptions,
97 const mepoo::MemoryInfo& memoryInfo) noexcept;
98
99 template <typename T, std::enable_if_t<std::is_same<T, iox::build::OneToManyPolicy>::value>* = nullptr>
100 iox::popo::SubscriberPortData* constructSubscriber(const capro::ServiceDescription& serviceDescription,
101 const RuntimeName_t& runtimeName,
102 const popo::SubscriberOptions& subscriberOptions,
103 const mepoo::MemoryInfo& memoryInfo) noexcept;
104
112 cxx::expected<popo::ClientPortData*, PortPoolError>
113 addClientPort(const capro::ServiceDescription& serviceDescription,
114 mepoo::MemoryManager* const memoryManager,
115 const RuntimeName_t& runtimeName,
116 const popo::ClientOptions& clientOptions,
117 const mepoo::MemoryInfo& memoryInfo = mepoo::MemoryInfo()) noexcept;
118
126 cxx::expected<popo::ServerPortData*, PortPoolError>
127 addServerPort(const capro::ServiceDescription& serviceDescription,
128 mepoo::MemoryManager* const memoryManager,
129 const RuntimeName_t& runtimeName,
130 const popo::ServerOptions& serverOptions,
131 const mepoo::MemoryInfo& memoryInfo = mepoo::MemoryInfo()) noexcept;
132
133 cxx::expected<popo::InterfacePortData*, PortPoolError> addInterfacePort(const RuntimeName_t& runtimeName,
134 const capro::Interfaces interface) noexcept;
135
136 cxx::expected<runtime::NodeData*, PortPoolError> addNodeData(const RuntimeName_t& runtimeName,
137 const NodeName_t& nodeName,
138 const uint64_t nodeDeviceIdentifier) noexcept;
139
140 cxx::expected<popo::ConditionVariableData*, PortPoolError>
141 addConditionVariableData(const RuntimeName_t& runtimeName) noexcept;
142
146 void removePublisherPort(const PublisherPortRouDiType::MemberType_t* const portData) noexcept;
147
151 void removeSubscriberPort(const SubscriberPortType::MemberType_t* const portData) noexcept;
152
156 void removeClientPort(const popo::ClientPortData* const portData) noexcept;
157
161 void removeServerPort(const popo::ServerPortData* const portData) noexcept;
162
166 void removeInterfacePort(const popo::InterfacePortData* const portData) noexcept;
167
171 void removeNodeData(const runtime::NodeData* const nodeData) noexcept;
172
176 void removeConditionVariableData(const popo::ConditionVariableData* const conditionVariableData) noexcept;
177
178 private:
179 PortPoolData* m_portPoolData;
180};
181
182} // namespace roudi
183} // namespace iox
184
185#include "iceoryx_posh/roudi/port_pool.inl"
186
187#endif // IOX_POSH_ROUDI_PORT_POOL_HPP
Definition: port_pool.hpp:62
void removeClientPort(const popo::ClientPortData *const portData) noexcept
Removes a ClientPortData from the internal pool.
cxx::expected< popo::ServerPortData *, PortPoolError > addServerPort(const capro::ServiceDescription &serviceDescription, mepoo::MemoryManager *const memoryManager, const RuntimeName_t &runtimeName, const popo::ServerOptions &serverOptions, const mepoo::MemoryInfo &memoryInfo=mepoo::MemoryInfo()) noexcept
Adds a ServerPortData to the internal pool and returns a pointer for further usage.
void removePublisherPort(const PublisherPortRouDiType::MemberType_t *const portData) noexcept
Removes a PublisherPortData from the internal pool.
cxx::expected< popo::ClientPortData *, PortPoolError > addClientPort(const capro::ServiceDescription &serviceDescription, mepoo::MemoryManager *const memoryManager, const RuntimeName_t &runtimeName, const popo::ClientOptions &clientOptions, const mepoo::MemoryInfo &memoryInfo=mepoo::MemoryInfo()) noexcept
Adds a ClientPortData to the internal pool and returns a pointer for further usage.
void removeServerPort(const popo::ServerPortData *const portData) noexcept
Removes a ServerPortData from the internal pool.
void removeConditionVariableData(const popo::ConditionVariableData *const conditionVariableData) noexcept
Removes a ConditionVariableData from the internal pool.
cxx::vector< PublisherPortRouDiType::MemberType_t *, MAX_PUBLISHERS > getPublisherPortDataList() noexcept
void removeInterfacePort(const popo::InterfacePortData *const portData) noexcept
Removes a InterfacePortData from the internal pool.
void removeNodeData(const runtime::NodeData *const nodeData) noexcept
Removes a NodeData from the internal pool.
void removeSubscriberPort(const SubscriberPortType::MemberType_t *const portData) noexcept
Removes a SubscriberPortData from the internal pool.
container for common port data which is related to the subscriber port as well as the publisher port
Definition: introspection_types.hpp:68