FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
events::Event< T > Class Template Reference

A standard Event as managed by FastArduino event API. More...

#include <fastarduino/events.h>

Public Types

using TYPE = T
 The type of additional event value, as defined in template paraneter T. More...
 

Public Member Functions

 Event (uint8_t type=Type::NO_EVENT, T value=T{}) INLINE
 Create a new event with the given type and the given value. More...
 
uint8_t type () const INLINE
 The type of this event. More...
 
value () const INLINE
 The associated value of this event. More...
 

Detailed Description

template<typename T>
class events::Event< T >

A standard Event as managed by FastArduino event API.

By default an event just holds a type as defined in events::Type. It may also hold a value of any type T, which you may use for any purpose you see fit.

Please note that calue type T will have an impact on the byte size of each event, hence the size of your event queue. You should then select the smallest type that you need, and even void if you do not need any additional value for your events.

All FastArduino API that produce events do not use any value for events, only their type, hence they will work with ANY Event<T> you may define.

Template Parameters
Tthe type of value held by all events; this type must have public default and copy constructors. T shall not be a reference type.
See also
events::Type

Definition at line 143 of file events.h.

Member Typedef Documentation

◆ TYPE

template<typename T >
using events::Event< T >::TYPE = T

The type of additional event value, as defined in template paraneter T.

Definition at line 154 of file events.h.

Constructor & Destructor Documentation

◆ Event()

template<typename T >
events::Event< T >::Event ( uint8_t  type = Type::NO_EVENT,
value = T{} 
)
inlineexplicit

Create a new event with the given type and the given value.

Parameters
typethe type of this event, Type::NO_EVENT by default.
valuethe value of this event, T{} by default; for an Event<void>, this argument shall not be provided or a compile error will occur.

Definition at line 162 of file events.h.

Member Function Documentation

◆ type()

template<typename T >
uint8_t events::Event< T >::type ( ) const
inline

The type of this event.

Definition at line 167 of file events.h.

◆ value()

template<typename T >
T events::Event< T >::value ( ) const
inline

The associated value of this event.

For an Event<void>, this method does not exist and shall not be called, otherwise a compile error will occur.

Definition at line 177 of file events.h.


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