iceoryx_posh 2.0.5
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
iox::popo::Trigger Class Reference

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. More...

#include <iceoryx_posh/popo/trigger.hpp>

Public Member Functions

 Trigger (const Trigger &)=delete
 
Triggeroperator= (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
 Creates a state based Trigger.
 
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
 Creates an event based Trigger.
 
 Trigger (Trigger &&rhs) noexcept
 
Triggeroperator= (Trigger &&rhs) noexcept
 
 ~Trigger () noexcept
 calls reset on destruction
 
 operator bool () const noexcept
 returns true if the Trigger is valid otherwise false A trigger is valid when:
 
bool isValid () const noexcept
 returns true if the trigger is valid otherwise false
 
bool isStateConditionSatisfied () const noexcept
 returns the result of the provided hasTriggeredCallback
 
void reset () noexcept
 resets and invalidates the Trigger
 
void invalidate () noexcept
 invalidates the Trigger without calling the reset callback
 
uint64_t getUniqueId () const noexcept
 returns the internal unique id of the trigger
 
bool isLogicalEqualTo (const void *const notificationOrigin, const uint64_t originTriggerType, const uint64_t originTriggerTypeHash) const noexcept
 returns true if the Triggers are logical equal otherwise false. Two Triggers are logical equal when
 
template<typename T >
void updateOrigin (T &newOrigin) noexcept
 sets a new origin of the trigger
 
const NotificationInfogetNotificationInfo () const noexcept
 returns the NotificationInfo
 
TriggerType getTriggerType () const noexcept
 returns the type of trigger
 

Static Public Attributes

static constexpr uint64_t INVALID_TRIGGER_ID = std::numeric_limits<uint64_t>::max()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Trigger() [1/2]

template<typename T , typename UserType >
iox::popo::Trigger::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

Creates a state based Trigger.

Parameters
[in]StateBasedTrigger_tsignals that we are creating a state based trigger
[in]stateOriginpointer to the class where the signal originates from, if it's set to nullptr the Trigger is in a defined but invalid state
[in]hasTriggeredCallbackcallback to a method which informs the trigger if it was triggered or not. If an empty callback is set the trigger is in a defined but invalid state.
[in]resetCallbackcallback which is called when the trigger goes out of scope.
[in]notificationIdid of the corresponding event/state
[in]callbackfunction pointer of type void(*)(T * const) to a callback which can be called by the trigger.
[in]uniqueIda context wide unique id to identify the trigger
[in]stateTypethe uint64_t value of the state origins state enum
[in]stateTypeHashthe uint64_t type hash of the state enum

◆ Trigger() [2/2]

template<typename T , typename UserType >
iox::popo::Trigger::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

Creates an event based Trigger.

Parameters
[in]EventBasedTrigger_tsignals that we are creating an event based trigger
[in]notificationOriginpointer to the class where the signal originates from, if it's set to nullptr the Trigger is in a defined but invalid state
[in]resetCallbackcallback which is called when the trigger goes out of scope.
[in]notificationIdid of the corresponding event
[in]callbackfunction pointer of type void(*)(T * const) to a callback which can be called by the trigger.
[in]uniqueIda context wide unique id to identify the trigger
[in]notificationTypethe uint64_t value of the events origins event enum
[in]notificationTypeHashthe uint64_t type hash of the event enum

Member Function Documentation

◆ isLogicalEqualTo()

bool iox::popo::Trigger::isLogicalEqualTo ( const void *const  notificationOrigin,
const uint64_t  originTriggerType,
const uint64_t  originTriggerTypeHash 
) const
noexcept

returns true if the Triggers are logical equal otherwise false. Two Triggers are logical equal when

  • both Trigger are valid
  • origin == rhs.origin
  • originTriggerType == rhs.originTriggerType
  • originTriggerTypeHash == rhs.originTriggerTypeHash

◆ isStateConditionSatisfied()

bool iox::popo::Trigger::isStateConditionSatisfied ( ) const
noexcept

returns the result of the provided hasTriggeredCallback

Note
an event based trigger returns always true when it's valid

◆ operator bool()

iox::popo::Trigger::operator bool ( ) const
explicitnoexcept

returns true if the Trigger is valid otherwise false A trigger is valid when:

  • origin != nullptr
  • hasTriggeredCallback is set

◆ updateOrigin()

template<typename T >
void iox::popo::Trigger::updateOrigin ( T newOrigin)
noexcept

sets a new origin of the trigger

Parameters
[in]newOriginreference to the new origin

The documentation for this class was generated from the following file: