iceoryx_doc  1.0.1
subscriber.hpp
1 // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2 // Copyright (c) 2020 - 2021 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_TYPED_SUBSCRIBER_HPP
19 #define IOX_POSH_POPO_TYPED_SUBSCRIBER_HPP
20 
21 #include "iceoryx_posh/internal/popo/sample_deleter.hpp"
22 #include "iceoryx_posh/popo/base_subscriber.hpp"
23 
24 namespace iox
25 {
26 namespace popo
27 {
28 template <typename T, typename H = iox::mepoo::NoUserHeader, typename BaseSubscriber_t = BaseSubscriber<>>
29 class SubscriberImpl : public BaseSubscriber_t
30 {
32  static_assert(!std::is_void<T>::value, "Type must not be void. Use the UntypedSubscriber for void types.");
33 
34  public:
36  const SubscriberOptions& subscriberOptions = SubscriberOptions());
37  SubscriberImpl(const SubscriberImpl& other) = delete;
38  SubscriberImpl& operator=(const SubscriberImpl&) = delete;
39  SubscriberImpl(SubscriberImpl&& rhs) = delete;
40  SubscriberImpl& operator=(SubscriberImpl&& rhs) = delete;
41  virtual ~SubscriberImpl() noexcept;
42 
49  cxx::expected<Sample<const T, const H>, ChunkReceiveResult> take() noexcept;
50 
51  using PortType = typename BaseSubscriber_t::PortType;
53 
54  protected:
55  using BaseSubscriber_t::port;
56 
57  private:
58  SubscriberSampleDeleter m_sampleDeleter{port()};
59 };
60 
61 template <typename T, typename H = mepoo::NoUserHeader>
63 
64 } // namespace popo
65 } // namespace iox
66 
67 #include "iceoryx_posh/internal/popo/subscriber.inl"
68 
69 #endif // IOX_POSH_POPO_TYPED_SUBSCRIBER_HPP
class for the identification of a communication event including information on the service,...
Definition: service_description.hpp:86
base class for all types of subscriber
Definition: base_subscriber.hpp:51
const port_t & port() const noexcept
const accessor of the underlying port
Definition: base_subscriber.inl:199
Definition: subscriber.hpp:30
cxx::expected< Sample< const T, const H >, ChunkReceiveResult > take() noexcept
Take the samples from the top of the receive queue.
Definition: subscriber.inl:34
Definition: service_description.hpp:29
This struct is used to configure the subscriber.
Definition: subscriber_options.hpp:31