Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
Event Struct Reference

Represents a framework event, optionally carrying payload data. More...

#include <Event.h>

+ Collaboration diagram for Event:

Public Member Functions

 Event ()=default
 Default constructor (creates a SystemNotification::None event).
 
 Event (SystemNotification type, const void *data=nullptr, size_t size=0, void *source=nullptr, FrameworkTask *target=nullptr)
 Construct an event with a system notification.
 
 Event (SystemNotification type, const GpioEvent &gpioEvent, size_t size=sizeof(GpioEvent), void *source=nullptr, FrameworkTask *target=nullptr)
 Construct an event with a GpioEvent payload.
 
 Event (uint8_t userCode, const void *data=nullptr, size_t size=0, void *source=nullptr, FrameworkTask *target=nullptr)
 Construct an event with a user-defined notification.
 
bool isUser () const
 Returns true if this is a user-defined event.
 
bool isSystem () const
 Returns true if this is a system-defined event.
 
uint8_t userCode () const
 Returns the raw user-defined code (safe to cast in app code)
 
SystemNotification systemCode () const
 Returns the system-defined enum value.
 

Public Attributes

Notification notification
 Notification identifier (system or user)
 
union { 
 
   GpioEvent   gpioEvent 
 Inline data if GpioChange. More...
 
   const void *   data 
 For user use. More...
 
};  
 
size_t size = 0
 Size of payload data

 
void * source = nullptr
 Optional source (e.g. controller that generated the event)
 
FrameworkTasktarget = nullptr
 Optional specific target (for directed delivery)
 

Detailed Description

Definition at line 23 of file Event.h.

Constructor & Destructor Documentation

◆ Event() [1/4]

Event::Event ( )
default

◆ Event() [2/4]

Event::Event ( SystemNotification  type,
const void *  data = nullptr,
size_t  size = 0,
void *  source = nullptr,
FrameworkTask target = nullptr 
)
inline
Parameters
typeSystem notification type
dataOptional pointer to payload
sizePayload size
sourceOptional source pointer
targetOptional target task

Definition at line 48 of file Event.h.

Notification notification
Notification identifier (system or user)
Definition Event.h:25
FrameworkTask * target
Optional specific target (for directed delivery)
Definition Event.h:32
size_t size
Size of payload data
Definition Event.h:30
void * source
Optional source (e.g. controller that generated the event)
Definition Event.h:31
const void * data
For user use.
Definition Event.h:28

◆ Event() [3/4]

Event::Event ( SystemNotification  type,
const GpioEvent gpioEvent,
size_t  size = sizeof(GpioEvent),
void *  source = nullptr,
FrameworkTask target = nullptr 
)
inline
Parameters
typeSystem notification type (must be SystemNotification::GpioChange)
gpioEventGpioEvent payload
sourceOptional source pointer
targetOptional target task

Definition at line 60 of file Event.h.

GpioEvent gpioEvent
Inline data if GpioChange.
Definition Event.h:27

◆ Event() [4/4]

Event::Event ( uint8_t  userCode,
const void *  data = nullptr,
size_t  size = 0,
void *  source = nullptr,
FrameworkTask target = nullptr 
)
inline
Parameters
userCodeUser-defined notification value
dataOptional pointer to payload
sizePayload size
sourceOptional source pointer
targetOptional target task

Definition at line 75 of file Event.h.

uint8_t userCode() const
Returns the raw user-defined code (safe to cast in app code)
Definition Event.h:91

Member Function Documentation

◆ isSystem()

bool Event::isSystem ( ) const
inline

Definition at line 86 of file Event.h.

86 {
88 }
NotificationKind kind

References Notification::kind, notification, and System.

◆ isUser()

bool Event::isUser ( ) const
inline

Definition at line 81 of file Event.h.

References Notification::kind, notification, and User.

◆ systemCode()

SystemNotification Event::systemCode ( ) const
inline

Definition at line 96 of file Event.h.

96 {
97 return notification.system;
98 }
SystemNotification system

References notification, and Notification::system.

◆ userCode()

uint8_t Event::userCode ( ) const
inline

Definition at line 91 of file Event.h.

91 {
93 }
uint8_t user_code

References notification, and Notification::user_code.

Member Data Documentation

◆ [union]

union { ... } Event

◆ data

const void* Event::data

Definition at line 28 of file Event.h.

◆ gpioEvent

GpioEvent Event::gpioEvent

Definition at line 27 of file Event.h.

Referenced by App::onEvent().

◆ notification

◆ size

size_t Event::size = 0

Definition at line 30 of file Event.h.

◆ source

void* Event::source = nullptr

Definition at line 31 of file Event.h.

◆ target

FrameworkTask* Event::target = nullptr

Definition at line 32 of file Event.h.

Referenced by EventManager::postEvent().


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