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

Allows a reaction to write data to a given port. More...

#include <xronos/sdk/reaction.hh>

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

Public Member Functions

template<template< class > class Serializer>
 PortEffect (InputPort< T, Serializer > &port, const ReactionContext &context)
 Constructor.
template<template< class > class Serializer>
 PortEffect (OutputPort< T, Serializer > &port, 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 a previously set value.
auto is_present () const noexcept -> bool
 Check if an event is currently present.
void set ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void set (const U &value)
 Write a value to the port, sending a message to connected ports.
void set (const Value< T > &value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void set (const ValueView< T > &view)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void set (U &&value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Detailed Description

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

Allows a reaction to write data to a given port.

Template Parameters
TThe value type associated with the port.

Constructor & Destructor Documentation

◆ PortEffect()

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

Constructor.

Parameters
portThe port for which the reaction should have write access.
contextThe context of the reaction the effect is declared for. Can be obtained using context().

Member Function Documentation

◆ get()

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

Get a view of a previously set value.

Returns
A ValueView of the port's current value. The view is absent (evaluates to false) if no value was set at the current timestamp. 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::PortEffect< T >::is_present ( ) const -> bool
nodiscardnoexcept

Check if an event is currently present.

Returns
true if an event is present, false otherwise.

◆ set() [1/5]

template<class T>
void xronos::sdk::BaseReaction::PortEffect< T >::set ( )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Set the port without sending a value. This is only available if T is void.

◆ set() [2/5]

template<class T>
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void xronos::sdk::BaseReaction::PortEffect< T >::set ( const U & value)

Write a value to the port, sending a message to connected ports.

May be called multiple times, but at most one message is sent to connected ports at any given timestamp: when called repeatedly, the previously written value is replaced.

Parameters
valueThe value to be written to the referenced port. Copy constructs the value from the given lvalue reference.
Exceptions
ValidationErrorIf called before execution has started.

◆ set() [3/5]

template<class T>
void xronos::sdk::BaseReaction::PortEffect< T >::set ( const Value< T > & value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sends the given value without copying it. The value must not be empty (asserted in debug builds); nothing is sent otherwise.

◆ set() [4/5]

template<class T>
void xronos::sdk::BaseReaction::PortEffect< T >::set ( const ValueView< T > & view)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sends the viewed value without copying it. Use this to relay a value received on a trigger. The view must not be absent (asserted in debug builds); nothing is sent otherwise.

◆ set() [5/5]

template<class T>
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void xronos::sdk::BaseReaction::PortEffect< T >::set ( U && value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Move constructs the value using the given rvalue reference.


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