iceoryx_posh 2.0.5
Loading...
Searching...
No Matches
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_hoofs/cxx/expected.hpp"
22#include "iceoryx_hoofs/cxx/optional.hpp"
23#include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp"
24#include "iceoryx_posh/internal/popo/sample_deleter.hpp"
25#include "iceoryx_posh/popo/sample.hpp"
26
27namespace iox
28{
29namespace popo
30{
31using uid_t = UniquePortId;
32
33
38template <typename port_t = iox::PublisherPortUserType>
40{
41 public:
42 using PortType = port_t;
43
44 BasePublisher(const BasePublisher& other) = delete;
45 BasePublisher& operator=(const BasePublisher&) = delete;
46 BasePublisher(BasePublisher&& rhs) = delete;
47 BasePublisher& operator=(BasePublisher&& rhs) = delete;
48 virtual ~BasePublisher() noexcept;
49
54 uid_t getUid() const noexcept;
55
60 capro::ServiceDescription getServiceDescription() const noexcept;
61
65 void offer() noexcept;
66
70 void stopOffer() noexcept;
71
76 bool isOffered() const noexcept;
77
82 bool hasSubscribers() const noexcept;
83
84 protected:
85 BasePublisher() = default; // Required for testing.
86 BasePublisher(const capro::ServiceDescription& service, const PublisherOptions& publisherOptions);
87
92 const port_t& port() const noexcept;
93
98 port_t& port() noexcept;
99
100 port_t m_port{nullptr};
101};
102
103} // namespace popo
104} // namespace iox
105
106#include "iceoryx_posh/internal/popo/base_publisher.inl"
107
108#endif // IOX_POSH_POPO_BASE_PUBLISHER_HPP
The BasePublisher class contains the common implementation for the different publisher specialization...
Definition base_publisher.hpp:40
bool hasSubscribers() const noexcept
hasSubscribers
capro::ServiceDescription getServiceDescription() const noexcept
getServiceDescription Get the service description of the publisher.
uid_t getUid() const noexcept
uid Get the UID of the publisher.
void stopOffer() noexcept
stopOffer Stop offering the service.
bool isOffered() const noexcept
isOffered
void offer() noexcept
offer Offer the service to be subscribed to.
const port_t & port() const noexcept
port
This struct is used to configure the publisher.
Definition publisher_options.hpp:33