iceoryx_posh/internal/popo/base_subscriber.hpp🔗
Namespaces🔗
Name |
---|
iox |
iox::runtime |
iox::popo |
Classes🔗
Name | |
---|---|
class | iox::popo::BaseSubscriber base class for all types of subscriber |
Source code🔗
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_POSH_POPO_BASE_SUBSCRIBER_HPP
#define IOX_POSH_POPO_BASE_SUBSCRIBER_HPP
#include "iceoryx_hoofs/cxx/expected.hpp"
#include "iceoryx_hoofs/cxx/optional.hpp"
#include "iceoryx_hoofs/cxx/unique_ptr.hpp"
#include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp"
#include "iceoryx_posh/popo/enum_trigger_type.hpp"
#include "iceoryx_posh/popo/sample.hpp"
#include "iceoryx_posh/popo/subscriber_options.hpp"
#include "iceoryx_posh/popo/wait_set.hpp"
#include "iceoryx_posh/runtime/posh_runtime.hpp"
namespace iox
{
namespace runtime
{
class ServiceDiscovery;
}
namespace popo
{
using uid_t = UniquePortId;
enum class SubscriberEvent : EventEnumIdentifier
{
DATA_RECEIVED
};
enum class SubscriberState : StateEnumIdentifier
{
HAS_DATA
};
template <typename port_t = iox::SubscriberPortUserType>
class BaseSubscriber
{
public:
virtual ~BaseSubscriber() noexcept;
uid_t getUid() const noexcept;
capro::ServiceDescription getServiceDescription() const noexcept;
void subscribe() noexcept;
SubscribeState getSubscriptionState() const noexcept;
void unsubscribe() noexcept;
bool hasData() const noexcept;
bool hasMissedData() noexcept;
void releaseQueuedData() noexcept;
friend class NotificationAttorney;
friend class iox::runtime::ServiceDiscovery;
protected:
using SelfType = BaseSubscriber<port_t>;
using PortType = port_t;
BaseSubscriber() noexcept; // Required for testing.
BaseSubscriber(const capro::ServiceDescription& service, const SubscriberOptions& subscriberOptions) noexcept;
BaseSubscriber(const BaseSubscriber& other) = delete;
BaseSubscriber& operator=(const BaseSubscriber&) = delete;
BaseSubscriber(BaseSubscriber&& rhs) = delete;
BaseSubscriber& operator=(BaseSubscriber&& rhs) = delete;
cxx::expected<const mepoo::ChunkHeader*, ChunkReceiveResult> takeChunk() noexcept;
void invalidateTrigger(const uint64_t trigger) noexcept;
void enableState(iox::popo::TriggerHandle&& triggerHandle, const SubscriberState subscriberState) noexcept;
WaitSetIsConditionSatisfiedCallback
getCallbackForIsStateConditionSatisfied(const SubscriberState subscriberState) const noexcept;
void disableState(const SubscriberState subscriberState) noexcept;
void enableEvent(iox::popo::TriggerHandle&& triggerHandle, const SubscriberEvent subscriberState) noexcept;
void disableEvent(const SubscriberEvent subscriberEvent) noexcept;
const port_t& port() const noexcept;
port_t& port() noexcept;
protected:
port_t m_port{nullptr};
TriggerHandle m_trigger;
};
} // namespace popo
} // namespace iox
#include "iceoryx_posh/internal/popo/base_subscriber.inl"
#endif // IOX_POSH_POPO_BASE_SUBSCRIBER_HPP
Updated on 2 April 2022 at 16:37:47 CEST