iceoryx_posh 2.0.5
Loading...
Searching...
No Matches
rpc_header.hpp
1// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2// Copyright (c) 2021 - 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
18#ifndef IOX_POSH_POPO_RPC_HEADER_HPP
19#define IOX_POSH_POPO_RPC_HEADER_HPP
20
21#include "iceoryx_hoofs/internal/cxx/unique_id.hpp"
22#include "iceoryx_posh/mepoo/chunk_header.hpp"
23
24#include <cstdint>
25
26namespace iox
27{
28namespace popo
29{
31{
32 public:
39 explicit RpcBaseHeader(const cxx::UniqueId& uniqueClientQueueId,
41 const int64_t sequenceId,
42 const uint8_t rpcHeaderVersion) noexcept;
43
44 RpcBaseHeader(const RpcBaseHeader& other) = delete;
45 RpcBaseHeader& operator=(const RpcBaseHeader&) = delete;
46 RpcBaseHeader(RpcBaseHeader&& rhs) noexcept = default;
47 RpcBaseHeader& operator=(RpcBaseHeader&& rhs) noexcept = default;
49
56
57 static constexpr uint32_t UNKNOWN_CLIENT_QUEUE_INDEX{std::numeric_limits<uint32_t>::max()};
58 static constexpr int64_t START_SEQUENCE_ID{0};
59
63
67
70 mepoo::ChunkHeader* getChunkHeader() noexcept;
71
74 const mepoo::ChunkHeader* getChunkHeader() const noexcept;
75
79
83
84 friend class ServerPortUser;
85
87 uint8_t m_rpcHeaderVersion{RPC_HEADER_VERSION};
88 uint32_t m_lastKnownClientQueueIndex{UNKNOWN_CLIENT_QUEUE_INDEX};
89 cxx::UniqueId m_uniqueClientQueueId;
90 int64_t m_sequenceId{0};
91};
92
94{
95 public:
100 explicit RequestHeader(const cxx::UniqueId& uniqueClientQueueId, const uint32_t lastKnownClientQueueIndex) noexcept;
101
102 RequestHeader(const RequestHeader& other) = delete;
103 RequestHeader& operator=(const RequestHeader&) = delete;
104 RequestHeader(RequestHeader&& rhs) noexcept = default;
105 RequestHeader& operator=(RequestHeader&& rhs) noexcept = default;
107
114
115 static RequestHeader* fromPayload(void* const payload) noexcept;
117};
118
120{
121 public:
127 explicit ResponseHeader(const cxx::UniqueId& uniqueClientQueueId,
129 const int64_t sequenceId) noexcept;
130
131 ResponseHeader(const ResponseHeader& other) = delete;
132 ResponseHeader& operator=(const ResponseHeader&) = delete;
133 ResponseHeader(ResponseHeader&& rhs) noexcept = default;
134 ResponseHeader& operator=(ResponseHeader&& rhs) noexcept = default;
136
138 void setServerError() noexcept;
139
142 bool hasServerError() const noexcept;
143
144 static ResponseHeader* fromPayload(void* const payload) noexcept;
146
147 private:
148 bool m_hasServerError{false};
149};
150
151} // namespace popo
152} // namespace iox
153
154#endif // IOX_POSH_POPO_RPC_HEADER_HPP
Definition rpc_header.hpp:94
RequestHeader(const cxx::UniqueId &uniqueClientQueueId, const uint32_t lastKnownClientQueueIndex) noexcept
Constructs and initializes a RpcBaseHeader.
void setSequenceId(const int64_t sequenceId) noexcept
Sets the sequence ID which is used to match a response to a request.
Definition rpc_header.hpp:120
ResponseHeader(const cxx::UniqueId &uniqueClientQueueId, const uint32_t lastKnownClientQueueIndex, const int64_t sequenceId) noexcept
Constructs and initializes a RpcBaseHeader.
Definition rpc_header.hpp:31
void * getUserPayload() noexcept
Get the pointer to the user-payload.
RpcBaseHeader(const cxx::UniqueId &uniqueClientQueueId, const uint32_t lastKnownClientQueueIndex, const int64_t sequenceId, const uint8_t rpcHeaderVersion) noexcept
Constructs and initializes a RpcBaseHeader.
mepoo::ChunkHeader * getChunkHeader() noexcept
Get the pointer to the ChunkHeader.
uint8_t getRpcHeaderVersion() const noexcept
The RpcBaseHeader version is used to detect incompatibilities for record&replay functionality.
int64_t getSequenceId() const noexcept
static constexpr uint8_t RPC_HEADER_VERSION
From the 2.0 release onward, this must be incremented for each incompatible change,...
Definition rpc_header.hpp:55
the struct describes a callback with a user defined type which can be attached to a WaitSet or a List...
Definition notification_callback.hpp:58