Skip to content

iceoryx_posh/internal/runtime/ipc_runtime_interface.hpp🔗

Namespaces🔗

Name
iox
iox::runtime

Classes🔗

Name
class iox::runtime::IpcRuntimeInterface

Source code🔗

// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 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_RUNTIME_IPC_RUNTIME_INTERFACE_HPP
#define IOX_POSH_RUNTIME_IPC_RUNTIME_INTERFACE_HPP

#include "iceoryx_posh/internal/runtime/ipc_interface_creator.hpp"
#include "iceoryx_posh/internal/runtime/ipc_interface_user.hpp"

namespace iox
{
namespace runtime
{
class IpcRuntimeInterface
{
  public:
    IpcRuntimeInterface(const RuntimeName_t& roudiName,
                        const RuntimeName_t& runtimeName,
                        const units::Duration roudiWaitingTimeout) noexcept;
    ~IpcRuntimeInterface() noexcept = default;

    IpcRuntimeInterface(const IpcRuntimeInterface&) = delete;
    IpcRuntimeInterface& operator=(const IpcRuntimeInterface&) = delete;
    IpcRuntimeInterface(IpcRuntimeInterface&&) = delete;
    IpcRuntimeInterface& operator=(IpcRuntimeInterface&&) = delete;

    bool sendKeepalive() noexcept;

    bool sendRequestToRouDi(const IpcMessage& msg, IpcMessage& answer) noexcept;

    rp::BaseRelativePointer::offset_t getSegmentManagerAddressOffset() const noexcept;

    size_t getShmTopicSize() noexcept;

    uint64_t getSegmentId() const noexcept;

  private:
    enum class RegAckResult
    {
        SUCCESS,
        TIMEOUT
    };

    void waitForRoudi(cxx::DeadlineTimer& timer) noexcept;

    RegAckResult waitForRegAck(const int64_t transmissionTimestamp) noexcept;

  private:
    RuntimeName_t m_runtimeName;
    cxx::optional<rp::BaseRelativePointer::offset_t> m_segmentManagerAddressOffset;
    IpcInterfaceCreator m_AppIpcInterface;
    IpcInterfaceUser m_RoudiIpcInterface;
    uint64_t m_shmTopicSize{0U};
    uint64_t m_segmentId{0U};
};

} // namespace runtime
} // namespace iox

#endif // IOX_POSH_RUNTIME_IPC_RUNTIME_INTERFACE_HPP

Updated on 31 May 2022 at 15:29:16 CEST