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

Access to a port that this reaction may write to. More...

#include <xronos/sdk/reaction.hh>

Public Member Functions

 PortEffect (Port< T > &port, ReactionContext context)
 Construct a new PortEffect object.
 
void set (const ImmutableValuePtr< T > &value_ptr)
 Set the port value and send a message to connected ports.
 
void set (MutableValuePtr< T > &&value_ptr)
 
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void set (const U &value)
 
template<class U>
requires (!std::is_same_v<U, void> && std::is_same_v<T, U>)
void set (U &&value)
 
void set ()
 Set the port without sending any value to connected ports.
 
auto get () const noexcept -> ImmutableValuePtr< T > requires(!std::is_same_v< T, void >)
 Get a previously set value.
 
auto is_present () const noexcept -> bool
 Check if an event is present at the current timestamp.
 

Detailed Description

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

Access to a port that this reaction may write to.

Template Parameters
TThe type of value carried by the port.

Constructor & Destructor Documentation

◆ PortEffect()

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

Construct a new PortEffect object.

Parameters
portAn port of the containing reactor, which can be obtained using the Reaction::self method.
contextThe current reaction's initialization context, which can be obtained using the BaseReaction::context method.

Member Function Documentation

◆ set() [1/4]

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

Set the port value and send a message to connected ports.

Can be called multiple times, but at each time at most one value is sent to connected ports. When called repeatedly at a given timestamp, the previous value is overwritten.

Parameters
value_ptrA pointer to the value to be written to the referenced port.

◆ set() [2/4]

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

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

◆ set() [3/4]

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)

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

◆ set() [4/4]

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.

◆ get()

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

Get a previously set value.

Returns
ImmutableValuePtr<T> A pointer to the current value of the port or nullptr if no value was set at the current timestamp.

◆ is_present()

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

Check if an event is present at the current timestamp.

Returns
bool true if an event is present, false otherwise.

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