iceoryx_posh  2.0.2
untyped_publisher_impl.hpp
1 // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2 // Copyright (c) 2020 - 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_UNTYPED_PUBLISHER_IMPL_HPP
19 #define IOX_POSH_POPO_UNTYPED_PUBLISHER_IMPL_HPP
20 
21 #include "iceoryx_posh/internal/popo/base_publisher.hpp"
22 #include "iceoryx_posh/popo/sample.hpp"
23 
24 namespace iox
25 {
26 namespace popo
27 {
30 template <typename BasePublisherType = BasePublisher<>>
31 class UntypedPublisherImpl : public BasePublisherType
32 {
33  public:
34  explicit UntypedPublisherImpl(const capro::ServiceDescription& service,
35  const PublisherOptions& publisherOptions = PublisherOptions());
36  UntypedPublisherImpl(const UntypedPublisherImpl& other) = delete;
37  UntypedPublisherImpl& operator=(const UntypedPublisherImpl&) = delete;
39  UntypedPublisherImpl& operator=(UntypedPublisherImpl&& rhs) = delete;
40  virtual ~UntypedPublisherImpl() = default;
41 
50  cxx::expected<void*, AllocationError>
51  loan(const uint32_t userPayloadSize,
52  const uint32_t userPayloadAlignment = iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT,
53  const uint32_t userHeaderSize = iox::CHUNK_NO_USER_HEADER_SIZE,
54  const uint32_t userHeaderAlignment = iox::CHUNK_NO_USER_HEADER_ALIGNMENT) noexcept;
55 
61  void publish(void* const userPayload) noexcept;
62 
70  void release(void* const userPayload) noexcept;
71 
72  protected:
73  using BasePublisherType::port;
74 };
75 
76 } // namespace popo
77 } // namespace iox
78 
79 #include "iceoryx_posh/internal/popo/untyped_publisher_impl.inl"
80 
81 #endif // IOX_POSH_POPO_UNTYPED_PUBLISHER_IMPL_HPP
class for the identification of a communication event including information on the service,...
Definition: service_description.hpp:81
The UntypedPublisherImpl class implements the untyped publisher API.
Definition: untyped_publisher_impl.hpp:32
cxx::expected< void *, AllocationError > loan(const uint32_t userPayloadSize, const uint32_t userPayloadAlignment=iox::CHUNK_DEFAULT_USER_PAYLOAD_ALIGNMENT, const uint32_t userHeaderSize=iox::CHUNK_NO_USER_HEADER_SIZE, const uint32_t userHeaderAlignment=iox::CHUNK_NO_USER_HEADER_ALIGNMENT) noexcept
Get a chunk from loaned shared memory.
void release(void *const userPayload) noexcept
Releases the ownership of the chunk provided by the user-payload pointer.
void publish(void *const userPayload) noexcept
Publish the provided memory chunk.
This struct is used to configure the publisher.
Definition: publisher_options.hpp:33