iceoryx_posh/popo/trigger.hpp🔗
Namespaces🔗
Name |
---|
iox |
iox::popo |
Classes🔗
Name | |
---|---|
struct | iox::popo::StateBasedTrigger_t |
struct | iox::popo::EventBasedTrigger_t |
class | iox::popo::Trigger The Trigger class is usually managed by a factory class like a WaitSet and acquired by classes which would like to signal a notification. Multiple Trigger can share a common ConditionVariableData pointer so that multiple Trigger can signal a single instance. |
Source code🔗
// Copyright (c) 2020, 2021 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_TRIGGER_HPP
#define IOX_POSH_POPO_TRIGGER_HPP
#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/cxx/method_callback.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
#include "iceoryx_posh/popo/notification_callback.hpp"
#include "iceoryx_posh/popo/notification_info.hpp"
#include <type_traits>
#include <typeinfo>
namespace iox
{
namespace popo
{
struct StateBasedTrigger_t
{
};
constexpr StateBasedTrigger_t StateBasedTrigger{};
struct EventBasedTrigger_t
{
};
constexpr EventBasedTrigger_t EventBasedTrigger{};
enum class TriggerType
{
STATE_BASED,
EVENT_BASED,
INVALID
};
class Trigger
{
public:
static constexpr uint64_t INVALID_TRIGGER_ID = std::numeric_limits<uint64_t>::max();
Trigger() noexcept = delete;
Trigger(const Trigger&) = delete;
Trigger& operator=(const Trigger&) = delete;
template <typename T, typename UserType>
Trigger(StateBasedTrigger_t,
T* const stateOrigin,
const cxx::ConstMethodCallback<bool>& hasTriggeredCallback,
const cxx::MethodCallback<void, uint64_t>& resetCallback,
const uint64_t notificationId,
const NotificationCallback<T, UserType>& callback,
const uint64_t uniqueId,
const uint64_t stateType,
const uint64_t stateTypeHash) noexcept;
template <typename T, typename UserType>
Trigger(EventBasedTrigger_t,
T* const notificationOrigin,
const cxx::MethodCallback<void, uint64_t>& resetCallback,
const uint64_t notificationId,
const NotificationCallback<T, UserType>& callback,
const uint64_t uniqueId,
const uint64_t notificationType,
const uint64_t notificationTypeHash) noexcept;
Trigger(Trigger&& rhs) noexcept;
Trigger& operator=(Trigger&& rhs) noexcept;
~Trigger() noexcept;
explicit operator bool() const noexcept;
bool isValid() const noexcept;
bool isStateConditionSatisfied() const noexcept;
void reset() noexcept;
void invalidate() noexcept;
uint64_t getUniqueId() const noexcept;
bool isLogicalEqualTo(const void* const notificationOrigin,
const uint64_t originTriggerType,
const uint64_t originTriggerTypeHash) const noexcept;
template <typename T>
void updateOrigin(T& newOrigin) noexcept;
const NotificationInfo& getNotificationInfo() const noexcept;
TriggerType getTriggerType() const noexcept;
private:
template <typename T, typename ContextDataType>
Trigger(T* const notificationOrigin,
const cxx::ConstMethodCallback<bool>& hasTriggeredCallback,
const cxx::MethodCallback<void, uint64_t>& resetCallback,
const uint64_t notificationId,
const NotificationCallback<T, ContextDataType>& callback,
const uint64_t uniqueId,
const TriggerType triggerType,
const uint64_t originTriggerType,
const uint64_t originTriggerTypeHash) noexcept;
private:
NotificationInfo m_notificationInfo;
cxx::ConstMethodCallback<bool> m_hasTriggeredCallback;
cxx::MethodCallback<void, uint64_t> m_resetCallback;
uint64_t m_uniqueId = INVALID_TRIGGER_ID;
TriggerType m_triggerType = TriggerType::STATE_BASED;
uint64_t m_originTriggerType = INVALID_TRIGGER_ID;
uint64_t m_originTriggerTypeHash = INVALID_TRIGGER_ID;
};
} // namespace popo
} // namespace iox
#include "iceoryx_posh/internal/popo/trigger.inl"
#endif
Updated on 18 December 2023 at 13:11:43 CET