iceoryx_posh  2.0.2
request.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_REQUEST_HPP
18 #define IOX_POSH_POPO_REQUEST_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/client_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 namespace iox
29 {
30 namespace popo
31 {
32 template <typename RpcType, typename SendErrorEnum>
34 
37 template <typename T>
38 class Request
39  : public SmartChunk<RpcInterface<Request<T>, ClientSendError>, T, cxx::add_const_conditionally_t<RequestHeader, T>>
40 {
41  using BaseType =
42  SmartChunk<RpcInterface<Request<T>, ClientSendError>, T, cxx::add_const_conditionally_t<RequestHeader, T>>;
43 
44  template <typename S, typename TT>
45  using ForClientOnly = typename BaseType::template ForProducerOnly<S, TT>;
46 
47  public:
51  using BaseType::BaseType;
52 
56  template <typename S = T, typename = ForClientOnly<S, T>>
57  cxx::expected<ClientSendError> send() noexcept;
58 
61  cxx::add_const_conditionally_t<RequestHeader, T>& getRequestHeader() noexcept;
62 
65  const RequestHeader& getRequestHeader() const noexcept;
66 
67  private:
68  template <typename, typename, typename>
69  friend class ClientImpl;
70  template <typename, typename, typename>
71  friend class ServerImpl;
72 
73  using BaseType::release;
74 
75  using BaseType::m_members;
76 };
77 } // namespace popo
78 } // namespace iox
79 
80 #include "iceoryx_posh/internal/popo/request.inl"
81 
82 #endif
The ClientImpl class implements the typed client API.
Definition: client_impl.hpp:40
Definition: rpc_header.hpp:94
The Request class is a mutable abstraction over types which are written to loaned shared memory....
Definition: request.hpp:40
cxx::add_const_conditionally_t< RequestHeader, T > & getRequestHeader() noexcept
Retrieve the request-header of the underlying memory chunk loaned to the sample.
cxx::expected< ClientSendError > send() noexcept
Sends the request via the client from which it was loaned and automatically release ownership to it.
Definition: request.hpp:33
The ServerImpl class implements the typed server API.
Definition: server_impl.hpp:40