xronos-sdk 0.14.0
Xronos C++ SDK
Loading...
Searching...
No Matches
xronos::sdk::BaseReaction::Trigger< T > Class Template Reference

Declares a reaction trigger and provides read access to the triggering event source. More...

#include <xronos/sdk/reaction.hh>

Inheritance diagram for xronos::sdk::BaseReaction::Trigger< T >:
[legend]

Public Member Functions

template<template< class > class Serializer>
 Trigger (const InputPort< T, Serializer > &trigger, const ReactionContext &context)
 Constructor.
template<template< class > class Serializer>
 Trigger (const OutputPort< T, Serializer > &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const PeriodicTimer &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const PhysicalEvent< T > &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const ProgrammableTimer< T > &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const Shutdown &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 Trigger (const Startup &trigger, const ReactionContext &context)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
auto get () const noexcept -> ValueView< T > requires(!std::is_same_v< T, void >)
 Get a view of the current event's value.
auto is_present () const noexcept -> bool
 Check if an event is currently present.

Detailed Description

template<class T>
class xronos::sdk::BaseReaction::Trigger< T >

Declares a reaction trigger and provides read access to the triggering event source.

Template Parameters
TThe value type associated with events received on the triggering event source.

Constructor & Destructor Documentation

◆ Trigger()

template<class T>
template<template< class > class Serializer>
xronos::sdk::BaseReaction::Trigger< T >::Trigger ( const InputPort< T, Serializer > & trigger,
const ReactionContext & context )

Constructor.

Constructing a Trigger automatically registers the given event source as a trigger of the reaction, causing the reaction handler to run whenever the event source emits an event.

Parameters
triggerAn event source that should trigger the reaction.
contextContext of the reaction the trigger is declared for. Can be obtained using context().

Member Function Documentation

◆ get()

template<class T>
auto xronos::sdk::BaseReaction::Trigger< T >::get ( ) const -> ValueView< T > requires(!std::is_same_v< T, void >)
nodiscardnoexcept

Get a view of the current event's value.

Returns
A ValueView of the current event's value. The view is absent (evaluates to false) if no event is present. The view is only valid for the duration of the current reaction handler; copy it into a Value to keep it alive beyond that.

◆ is_present()

template<class T>
auto xronos::sdk::BaseReaction::Trigger< T >::is_present ( ) const -> bool
nodiscardnoexcept

Check if an event is currently present.

Returns
true if an event is present, false otherwise.

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