iceoryx_doc  1.0.1
ipc_runtime_interface.hpp
1 // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
2 // Copyright (c) 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_RUNTIME_IPC_RUNTIME_INTERFACE_HPP
19 #define IOX_POSH_RUNTIME_IPC_RUNTIME_INTERFACE_HPP
20 
21 #include "iceoryx_posh/internal/runtime/ipc_interface_creator.hpp"
22 #include "iceoryx_posh/internal/runtime/ipc_interface_user.hpp"
23 
24 namespace iox
25 {
26 namespace runtime
27 {
29 {
30  public:
35  IpcRuntimeInterface(const RuntimeName_t& roudiName,
36  const RuntimeName_t& runtimeName,
37  const units::Duration roudiWaitingTimeout) noexcept;
38  ~IpcRuntimeInterface() noexcept = default;
39 
42  IpcRuntimeInterface& operator=(const IpcRuntimeInterface&) = delete;
44  IpcRuntimeInterface& operator=(IpcRuntimeInterface&&) = delete;
45 
48  bool sendKeepalive() noexcept;
49 
54  bool sendRequestToRouDi(const IpcMessage& msg, IpcMessage& answer) noexcept;
55 
58  rp::BaseRelativePointer::offset_t getSegmentManagerAddressOffset() const noexcept;
59 
62  size_t getShmTopicSize() noexcept;
63 
66  uint64_t getSegmentId() const noexcept;
67 
68  private:
69  enum class RegAckResult
70  {
71  SUCCESS,
72  TIMEOUT
73  };
74 
75  void waitForRoudi(cxx::DeadlineTimer& timer) noexcept;
76 
77  RegAckResult waitForRegAck(const int64_t transmissionTimestamp) noexcept;
78 
79  private:
80  RuntimeName_t m_runtimeName;
81  cxx::optional<rp::BaseRelativePointer::offset_t> m_segmentManagerAddressOffset;
82  IpcInterfaceCreator m_AppIpcInterface;
83  IpcInterfaceUser m_RoudiIpcInterface;
84  uint64_t m_shmTopicSize{0U};
85  uint64_t m_segmentId{0U};
86 };
87 
88 } // namespace runtime
89 } // namespace iox
90 
91 #endif // IOX_POSH_RUNTIME_IPC_RUNTIME_INTERFACE_HPP
Class for creating and handling a IPC channel.
Definition: ipc_interface_creator.hpp:31
Class for using a IPC channel.
Definition: ipc_interface_user.hpp:29
Definition: ipc_message.hpp:43
Definition: ipc_runtime_interface.hpp:29
bool sendRequestToRouDi(const IpcMessage &msg, IpcMessage &answer) noexcept
send a request to the RouDi daemon
IpcRuntimeInterface(const RuntimeName_t &roudiName, const RuntimeName_t &runtimeName, const units::Duration roudiWaitingTimeout) noexcept
Runtime Interface for the own IPC channel and the one to the RouDi daemon.
size_t getShmTopicSize() noexcept
get the size of the management shared memory object
bool sendKeepalive() noexcept
sends the keep alive trigger to the RouDi daemon
uint64_t getSegmentId() const noexcept
get the segment id of the shared memory object
rp::BaseRelativePointer::offset_t getSegmentManagerAddressOffset() const noexcept
get the adress offset of the segment manager
Definition: service_description.hpp:29