Skip to content

iceoryx_posh/gateway/channel.hpp🔗

Namespaces🔗

Name
iox
iox::gw

Classes🔗

Name
class iox:🇬🇼:Channel
A data structure representing a channel between Iceoryx and an external system.

Source code🔗

// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2021 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_GW_CHANNEL_HPP
#define IOX_POSH_GW_CHANNEL_HPP

#include "iceoryx_hoofs/cxx/expected.hpp"
#include "iceoryx_hoofs/cxx/optional.hpp"
#include "iceoryx_hoofs/internal/objectpool/objectpool.hpp"
#include "iceoryx_posh/capro/service_description.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"

#include <memory>

namespace iox
{
namespace gw
{
enum class ChannelError : uint8_t
{
    OBJECT_POOL_FULL
};

template <typename IceoryxTerminal, typename ExternalTerminal>
class Channel
{
    using IceoryxTerminalPtr = std::shared_ptr<IceoryxTerminal>;
    using IceoryxTerminalPool = cxx::ObjectPool<IceoryxTerminal, MAX_CHANNEL_NUMBER>;
    using ExternalTerminalPtr = std::shared_ptr<ExternalTerminal>;
    using ExternalTerminalPool = cxx::ObjectPool<ExternalTerminal, MAX_CHANNEL_NUMBER>;

  public:
    constexpr Channel(const capro::ServiceDescription& service,
                      const IceoryxTerminalPtr iceoryxTerminal,
                      const ExternalTerminalPtr externalTerminal) noexcept;

    constexpr bool operator==(const Channel<IceoryxTerminal, ExternalTerminal>& rhs) const noexcept;

    template <typename IceoryxPubSubOptions>
    static cxx::expected<Channel, ChannelError> create(const capro::ServiceDescription& service,
                                                       const IceoryxPubSubOptions& options) noexcept;

    capro::ServiceDescription getServiceDescription() const noexcept;
    IceoryxTerminalPtr getIceoryxTerminal() const noexcept;
    ExternalTerminalPtr getExternalTerminal() const noexcept;

  private:
    static IceoryxTerminalPool s_iceoryxTerminals;
    static ExternalTerminalPool s_externalTerminals;

    capro::ServiceDescription m_service;
    IceoryxTerminalPtr m_iceoryxTerminal;
    ExternalTerminalPtr m_externalTerminal;
};

} // namespace gw
} // namespace iox

#include "iceoryx_posh/internal/gateway/channel.inl"

#endif // IOX_POSH_GW_CHANNEL_HPP

Updated on 18 December 2023 at 13:11:43 CET