iceoryx_posh 2.0.3
channel.hpp
1// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2// Copyright (c) 2020 - 2021 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
18#ifndef IOX_POSH_GW_CHANNEL_HPP
19#define IOX_POSH_GW_CHANNEL_HPP
20
21#include "iceoryx_hoofs/cxx/expected.hpp"
22#include "iceoryx_hoofs/cxx/optional.hpp"
23#include "iceoryx_hoofs/internal/objectpool/objectpool.hpp"
24#include "iceoryx_posh/capro/service_description.hpp"
25#include "iceoryx_posh/iceoryx_posh_types.hpp"
26
27#include <memory>
28
29namespace iox
30{
31namespace gw
32{
33enum class ChannelError : uint8_t
34{
35 OBJECT_POOL_FULL
36};
37
55template <typename IceoryxTerminal, typename ExternalTerminal>
57{
58 using IceoryxTerminalPtr = std::shared_ptr<IceoryxTerminal>;
59 using IceoryxTerminalPool = cxx::ObjectPool<IceoryxTerminal, MAX_CHANNEL_NUMBER>;
60 using ExternalTerminalPtr = std::shared_ptr<ExternalTerminal>;
61 using ExternalTerminalPool = cxx::ObjectPool<ExternalTerminal, MAX_CHANNEL_NUMBER>;
62
63 public:
64 constexpr Channel(const capro::ServiceDescription& service,
65 const IceoryxTerminalPtr iceoryxTerminal,
66 const ExternalTerminalPtr externalTerminal) noexcept;
67
68 constexpr bool operator==(const Channel<IceoryxTerminal, ExternalTerminal>& rhs) const noexcept;
69
76 template <typename IceoryxPubSubOptions>
77 static cxx::expected<Channel, ChannelError> create(const capro::ServiceDescription& service,
78 const IceoryxPubSubOptions& options) noexcept;
79
80 capro::ServiceDescription getServiceDescription() const noexcept;
81 IceoryxTerminalPtr getIceoryxTerminal() const noexcept;
82 ExternalTerminalPtr getExternalTerminal() const noexcept;
83
84 private:
85 static IceoryxTerminalPool s_iceoryxTerminals;
86 static ExternalTerminalPool s_externalTerminals;
87
88 capro::ServiceDescription m_service;
89 IceoryxTerminalPtr m_iceoryxTerminal;
90 ExternalTerminalPtr m_externalTerminal;
91};
92
93} // namespace gw
94} // namespace iox
95
96#include "iceoryx_posh/internal/gateway/channel.inl"
97
98#endif // IOX_POSH_GW_CHANNEL_HPP
class for the identification of a communication event including information on the service,...
Definition: service_description.hpp:81
A data structure representing a channel between Iceoryx and an external system.
Definition: channel.hpp:57
static cxx::expected< Channel, ChannelError > create(const capro::ServiceDescription &service, const IceoryxPubSubOptions &options) noexcept
create Creates a channel for the given service whose terminals reside in a static object pool.