iceoryx_posh  2.0.2
sample.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_SAMPLE_HPP
19 #define IOX_POSH_POPO_SAMPLE_HPP
20 
21 #include "iceoryx_hoofs/cxx/type_traits.hpp"
22 #include "iceoryx_hoofs/cxx/unique_ptr.hpp"
23 #include "iceoryx_posh/internal/log/posh_logging.hpp"
24 #include "iceoryx_posh/internal/popo/smart_chunk.hpp"
25 #include "iceoryx_posh/mepoo/chunk_header.hpp"
26 
27 namespace iox
28 {
29 namespace popo
30 {
31 template <typename T, typename H>
33 
36 template <typename T, typename H = cxx::add_const_conditionally_t<mepoo::NoUserHeader, T>>
37 class Sample : public SmartChunk<PublisherInterface<T, H>, T, H>
38 {
39  using BaseType = SmartChunk<PublisherInterface<T, H>, T, H>;
40 
41  public:
42  template <typename T1, typename T2>
43  using ForPublisherOnly = typename BaseType::template ForProducerOnly<T1, T2>;
44 
50  using BaseType::BaseType;
51 
54  using BaseType::getUserHeader;
55 
59  template <typename S = T, typename = ForPublisherOnly<S, T>>
60  void publish() noexcept;
61 
62  private:
63  template <typename, typename, typename>
64  friend class PublisherImpl;
65 
68  using BaseType::release;
69 
70  using BaseType::m_members;
71 };
72 
73 } // namespace popo
74 } // namespace iox
75 
76 #include "iceoryx_posh/internal/popo/sample.inl"
77 
78 #endif // IOX_POSH_POPO_SAMPLE_HPP
The PublisherImpl class implements the typed publisher API.
Definition: publisher_impl.hpp:35
Definition: sample.hpp:32
The Sample class is a mutable abstraction over types which are written to loaned shared memory....
Definition: sample.hpp:38
void publish() noexcept
Publish the sample via the publisher from which it was loaned and automatically release ownership to ...