iceoryx_posh  2.0.2
response.hpp
1 // Copyright (c) 2022 by Apex.AI Inc. 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 
17 #ifndef IOX_POSH_POPO_RESPONSE_HPP
18 #define IOX_POSH_POPO_RESPONSE_HPP
19 
20 #include "iceoryx_hoofs/cxx/type_traits.hpp"
21 #include "iceoryx_hoofs/cxx/unique_ptr.hpp"
22 #include "iceoryx_posh/internal/log/posh_logging.hpp"
23 #include "iceoryx_posh/internal/popo/ports/server_port_user.hpp"
24 #include "iceoryx_posh/internal/popo/smart_chunk.hpp"
25 #include "iceoryx_posh/mepoo/chunk_header.hpp"
26 #include "iceoryx_posh/popo/rpc_header.hpp"
27 
28 
29 namespace iox
30 {
31 namespace popo
32 {
33 template <typename RpcType, typename SendErrorEnum>
34 class RpcInterface;
35 
38 template <typename T>
39 class Response : public SmartChunk<RpcInterface<Response<T>, ServerSendError>,
40  T,
41  cxx::add_const_conditionally_t<ResponseHeader, T>>
42 {
43  using BaseType =
44  SmartChunk<RpcInterface<Response<T>, ServerSendError>, T, cxx::add_const_conditionally_t<ResponseHeader, T>>;
45 
46  template <typename S, typename TT>
47  using ForServerOnly = typename BaseType::template ForProducerOnly<S, TT>;
48 
49  public:
53  using BaseType::BaseType;
54 
58  template <typename S = T, typename = ForServerOnly<S, T>>
59  cxx::expected<ServerSendError> send() noexcept;
60 
63  cxx::add_const_conditionally_t<ResponseHeader, T>& getResponseHeader() noexcept;
64 
67  const ResponseHeader& getResponseHeader() const noexcept;
68 
69  private:
70  template <typename, typename, typename>
71  friend class ClientImpl;
72  template <typename, typename, typename>
73  friend class ServerImpl;
74 
75  using BaseType::release;
76 
77  using BaseType::m_members;
78 };
79 } // namespace popo
80 } // namespace iox
81 
82 #include "iceoryx_posh/internal/popo/response.inl"
83 
84 #endif
The ClientImpl class implements the typed client API.
Definition: client_impl.hpp:40
Definition: rpc_header.hpp:120
The Response class is a mutable abstraction over types which are written to loaned shared memory....
Definition: response.hpp:42
cxx::expected< ServerSendError > send() noexcept
Sends the response via the server from which it was loaned and automatically release ownership to it.
cxx::add_const_conditionally_t< ResponseHeader, T > & getResponseHeader() noexcept
Retrieve the response-header of the underlying memory chunk loaned to the sample.
The ServerImpl class implements the typed server API.
Definition: server_impl.hpp:40