FastArduino  v1.7
C++ library to build fast but small Arduino/AVR projects
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.
 

Public Member Functions

 Event (const Event< T > &)=default
 
Event< T > & operator= (const Event< T > &)=default
 
 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.
 
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.

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 160 of file events.h.

Member Function Documentation

◆ 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 175 of file events.h.


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