iceoryx_doc  1.0.1
base_publisher.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_BASE_PUBLISHER_HPP
19 #define IOX_POSH_POPO_BASE_PUBLISHER_HPP
20 
21 #include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp"
22 #include "iceoryx_posh/internal/popo/sample_deleter.hpp"
23 #include "iceoryx_posh/popo/sample.hpp"
24 #include "iceoryx_utils/cxx/expected.hpp"
25 #include "iceoryx_utils/cxx/optional.hpp"
26 
27 namespace iox
28 {
29 namespace popo
30 {
31 using uid_t = UniquePortId;
32 
33 
37 template <typename port_t = iox::PublisherPortUserType>
39 {
40  public:
41  using PortType = port_t;
42 
43  BasePublisher(const BasePublisher& other) = delete;
44  BasePublisher& operator=(const BasePublisher&) = delete;
45  BasePublisher(BasePublisher&& rhs) = delete;
46  BasePublisher& operator=(BasePublisher&& rhs) = delete;
47  virtual ~BasePublisher();
48 
53  uid_t getUid() const noexcept;
54 
60 
64  void offer() noexcept;
65 
69  void stopOffer() noexcept;
70 
75  bool isOffered() const noexcept;
76 
81  bool hasSubscribers() const noexcept;
82 
83  protected:
84  BasePublisher() = default; // Required for testing.
85  BasePublisher(const capro::ServiceDescription& service, const PublisherOptions& publisherOptions);
86 
91  const port_t& port() const noexcept;
92 
97  port_t& port() noexcept;
98 
99  port_t m_port{nullptr};
100 };
101 
102 } // namespace popo
103 } // namespace iox
104 
105 #include "iceoryx_posh/internal/popo/base_publisher.inl"
106 
107 #endif // IOX_POSH_POPO_BASE_PUBLISHER_HPP
class for the identification of a communication event including information on the service,...
Definition: service_description.hpp:86
The BasePublisher class contains the common implementation for the different publisher specialization...
Definition: base_publisher.hpp:39
bool hasSubscribers() const noexcept
hasSubscribers
Definition: base_publisher.inl:71
capro::ServiceDescription getServiceDescription() const noexcept
getServiceDescription Get the service description of the publisher.
Definition: base_publisher.inl:47
uid_t getUid() const noexcept
uid Get the UID of the publisher.
Definition: base_publisher.inl:41
void stopOffer() noexcept
stopOffer Stop offering the service.
Definition: base_publisher.inl:59
bool isOffered() const noexcept
isOffered
Definition: base_publisher.inl:65
void offer() noexcept
offer Offer the service to be subscribed to.
Definition: base_publisher.inl:53
const port_t & port() const noexcept
port
Definition: base_publisher.inl:77
Definition: service_description.hpp:29
This struct is used to configure the publisher.
Definition: publisher_options.hpp:30