RKH
RKH_EVT_T Struct Reference

Represents events without parameters. More...

#include <rkhevt.h>

Data Fields

RKH_SIG_T e
 Signal of the event instance.
 
rui8_t nref
 Attribute of dynamic events.
 
rui8_t pool
 Attribute of dynamic events (0 for static event).
 

Detailed Description

Represents events without parameters.

An event can have associated parameters, allowing the event instance to convey not only the occurrence of some interesting incident but also quantitative information regarding that occurrence. Implementing the single inheritance in C is very simply by literally embedding the base structure, RKH_EVT_T in this case, as the first member of the derived structure. For example, the structure MYEVT_T derived from the base structure RKH_EVT_T by embedding the RKH_EVT_T instance as the first member of MYEVT_T.

typedef struct
{
RKH_EVT_T evt; // base structure
int x; // parameter 'x'
int y; // parameter 'y'
} MYEVT_T;
Represents events without parameters.
Definition: rkhevt.h:170

Such nesting of structures always aligns the data member 'evt' at the beginning of every instance of the derived structure. In particular, this alignment lets you treat a pointer to the derived MYEVT_T structure as a pointer to the RKH_EVT_T base structure. Consequently, you can always safely pass a pointer to MYEVT_T to any C function that expects a pointer to RKH_EVT_T. (To be strictly correct in C, you should explicitly cast this pointer. In OOP such casting is called upcasting and is always safe.) Therefore, all functions designed for the RKH_EVT_T structure are automatically available to the MYEVT_T structure as well as other structures derived from RKH_EVT_T.

Note
The RKH takes the 'e' member of RKH_EVT_T structure for triggering a state transition.
See also
rkh_put_fifo(), rkh_put_lifo(), rkh_alloc_event(), rkh_set_static_event() and rkh_fwk_gc().

Definition at line 169 of file rkhevt.h.


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