xronos-sdk 0.5.0
Xronos C++ SDK
Loading...
Searching...
No Matches
xronos::sdk::PhysicalEvent< T > Class Template Reference

A reactor element for receiving events from external sources. More...

#include <xronos/sdk/physical_event.hh>

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

Public Member Functions

 PhysicalEvent (std::string_view name, ReactorContext context)
 Constructor.
void trigger (const ImmutableValuePtr< T > &value) noexcept
 Emit a new event with an associated value and trigger reactions.
void trigger (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.
void trigger (const 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 trigger (T &&value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Public Member Functions inherited from xronos::sdk::Element
auto name () const noexcept -> const std::string &
 Get the element's name.
auto fqn () const noexcept -> const std::string &
 Get the element's fully qualified name.
auto add_attribute (std::string_view key, const AttributeValue &value) noexcept -> bool
 Annotate an element with an attribute.
template<std::ranges::input_range R>
requires requires(std::ranges::range_value_t<R> pair) { { pair.first } -> std::convertible_to<std::string_view>; { pair.second } -> std::convertible_to<AttributeValue>; }
auto add_attributes (const R &range) noexcept -> bool
 Annotate an element with multiple attributes.
auto add_attributes (std::initializer_list< std::pair< std::string_view, AttributeValue > > attributes) -> bool
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
virtual ~Element ()=default
 Virtual destructor.

Detailed Description

template<class T>
class xronos::sdk::PhysicalEvent< T >

A reactor element for receiving events from external sources.

Physical events may be used to trigger reactions from a context outside of the scope of the reactor program. These could be external event handlers that respond to sensor inputs.

Can be used as a reaction trigger allowing the reaction handler to read the associated value.

Template Parameters
TThe type of values carried by emitted events.

Constructor & Destructor Documentation

◆ PhysicalEvent()

template<class T>
xronos::sdk::PhysicalEvent< T >::PhysicalEvent ( std::string_view name,
ReactorContext context )

Constructor.

Parameters
nameThe name of the physical event.
contextThe containing reactor's context.

Member Function Documentation

◆ trigger() [1/3]

template<class T>
void xronos::sdk::PhysicalEvent< T >::trigger ( const ImmutableValuePtr< T > & value)
noexcept

Emit a new event with an associated value and trigger reactions.

The event will be assigned a timestamp equal to the current wall-clock time.

Parameters
valueThe value to be associated with the emitted event.

◆ trigger() [2/3]

template<class T>
void xronos::sdk::PhysicalEvent< T >::trigger ( const T & value)

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

Copy constructs the value using the given lvalue reference.

◆ trigger() [3/3]

template<class T>
void xronos::sdk::PhysicalEvent< T >::trigger ( T && 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 files: