RKH
|
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). | |
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.
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.