iceoryx_doc  1.0.1
client_server_port_types.hpp
1 // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // SPDX-License-Identifier: Apache-2.0
16 #ifndef IOX_POSH_POPO_PORTS_CLIENT_SERVER_PORT_TYPES_HPP
17 #define IOX_POSH_POPO_PORTS_CLIENT_SERVER_PORT_TYPES_HPP
18 
19 #include "iceoryx_posh/iceoryx_posh_types.hpp"
20 #include "iceoryx_posh/internal/popo/building_blocks/chunk_receiver_data.hpp"
21 #include "iceoryx_posh/internal/popo/building_blocks/chunk_sender_data.hpp"
22 #include "iceoryx_posh/internal/popo/building_blocks/locking_policy.hpp"
23 #include "iceoryx_utils/internal/relocatable_pointer/relative_pointer.hpp"
24 
25 #include <cstdint>
26 
27 namespace iox
28 {
29 namespace popo
30 {
32 {
33  static constexpr uint32_t MAX_QUEUES = 1;
34  static constexpr uint64_t MAX_HISTORY_CAPACITY = 1; // could be 0, but problem for the container then
35 };
36 
38 {
39  static constexpr uint32_t MAX_QUEUES = MAX_CLIENTS_PER_SERVER;
40  static constexpr uint64_t MAX_HISTORY_CAPACITY = 1; // could be 0, but problem for the container then
41 };
42 
44 {
45  static constexpr uint64_t MAX_QUEUE_CAPACITY = MAX_RESPONSE_QUEUE_CAPACITY;
46 };
47 
49 {
50  static constexpr uint64_t MAX_QUEUE_CAPACITY = MAX_REQUEST_QUEUE_CAPACITY;
51 };
52 
54 
56 
59 
62 
64 
66 
68 
70 
72 {
73  public:
74  explicit RPCBaseHeader(cxx::not_null<ClientChunkQueueData_t* const> chunkQueueDataPtr, const int64_t sequenceNumber)
75  : m_clientQueueDataPtr(chunkQueueDataPtr)
76  , m_sequenceNumber(sequenceNumber)
77  {
78  }
79 
80  RPCBaseHeader(const RPCBaseHeader& other) = delete;
81  RPCBaseHeader& operator=(const RPCBaseHeader&) = delete;
82  RPCBaseHeader(RPCBaseHeader&& rhs) = default;
83  RPCBaseHeader& operator=(RPCBaseHeader&& rhs) = default;
84  virtual ~RPCBaseHeader() = default;
85 
86  int64_t getSequenceNumber() const noexcept
87  {
88  return m_sequenceNumber;
89  }
90 
91  protected:
92  rp::RelativePointer<ClientChunkQueueData_t> m_clientQueueDataPtr;
93  int64_t m_sequenceNumber{0};
94 };
95 
97 {
98  public:
99  explicit RequestHeader(cxx::not_null<ClientChunkQueueData_t* const> chunkQueueDataPtr) noexcept
100  : RPCBaseHeader(chunkQueueDataPtr, 0)
101  {
102  }
103 
104  RequestHeader(const RequestHeader& other) = delete;
105  RequestHeader& operator=(const RequestHeader&) = delete;
106  RequestHeader(RequestHeader&& rhs) = default;
107  RequestHeader& operator=(RequestHeader&& rhs) = default;
108  virtual ~RequestHeader() = default;
109 
110  void setSequenceNumber(const int64_t sequenceNumber) noexcept
111  {
112  this->m_sequenceNumber = sequenceNumber;
113  }
114 
115  void setFireAndForget(const bool fireAndForget) noexcept
116  {
117  m_isFireAndForget = fireAndForget;
118  }
119 
121  {
123  return nullptr;
124  }
125  void* getUserPayload() noexcept
126  {
128  return nullptr;
129  }
130 
131  private:
132  bool m_isFireAndForget{false};
133 };
134 
136 {
137  public:
138  ResponseHeader(cxx::not_null<ClientChunkQueueData_t* const> chunkQueueDataPtr,
139  const int64_t sequenceNumber) noexcept
140  : RPCBaseHeader(chunkQueueDataPtr, sequenceNumber)
141  {
142  }
143 
144  ResponseHeader(const ResponseHeader& other) = delete;
145  ResponseHeader& operator=(const ResponseHeader&) = delete;
146  ResponseHeader(ResponseHeader&& rhs) = default;
147  ResponseHeader& operator=(ResponseHeader&& rhs) = default;
148  virtual ~ResponseHeader() = default;
149 
150  void setServerError(bool serverError) noexcept
151  {
152  m_hasServerError = serverError;
153  }
154 
155  bool hasServerError() const noexcept
156  {
157  return m_hasServerError;
158  }
159 
160  const mepoo::ChunkHeader* getChunkHeader() const noexcept
161  {
163  return nullptr;
164  }
165  const void* getUserPayload() const noexcept
166  {
168  return nullptr;
169  }
170 
171  private:
172  bool m_hasServerError{false};
173 };
174 
175 
176 } // namespace popo
177 } // namespace iox
178 
179 #endif // IOX_POSH_POPO_PORTS_CLIENT_SERVER_PORT_TYPES_HPP
Definition: client_server_port_types.hpp:72
Definition: client_server_port_types.hpp:97
mepoo::ChunkHeader * getChunkHeader() const noexcept
Definition: client_server_port_types.hpp:120
void * getUserPayload() noexcept
Definition: client_server_port_types.hpp:125
Definition: client_server_port_types.hpp:136
const mepoo::ChunkHeader * getChunkHeader() const noexcept
Definition: client_server_port_types.hpp:160
const void * getUserPayload() const noexcept
Definition: client_server_port_types.hpp:165
Definition: service_description.hpp:29
constexpr uint32_t MAX_CLIENTS_PER_SERVER
Definition: iceoryx_posh_types.hpp:99
Definition: chunk_header.hpp:42
Definition: chunk_distributor_data.hpp:40
Definition: chunk_queue_data.hpp:35
Definition: client_server_port_types.hpp:32
Definition: client_server_port_types.hpp:44
Definition: client_server_port_types.hpp:38
Definition: client_server_port_types.hpp:49