inc/ecu/event.h File Reference
| ECU |
Go to the source code of this file.
Data Structures | |
| struct | ecu_event |
| Base event class. Custom event data is stored by inheriting this class. More... | |
Macros | |
| #define | ECU_EVENT_BASE_CAST(event_ptr_) ((struct ecu_event *)(event_ptr_)) |
| Upcasts derived event back into the ecu_event base class. More... | |
| #define | ECU_EVENT_CONST_BASE_CAST(event_ptr_) ((const struct ecu_event *)(event_ptr_)) |
| Same as ECU_EVENT_BASE_CAST() but performs a const-qualified upcast. More... | |
| #define | ECU_EVENT_CTOR(id_, size_) |
| Constructs an ecu_event at compile-time. More... | |
| #define | ECU_EVENT_IS_BASE_OF(base_, derived_) ECU_IS_BASE_OF(base_, derived_) |
| Verifies, at compile-time, that derived event correctly inherits base event class via C-style inheritance. Returns true if this condition is satisfied. False otherwise. More... | |
| #define | ECU_EVENT_SIZE_UNUSED ((size_t)0) |
| Helper macro supplied to event constructors if event's size field is unused. | |
Typedefs | |
| typedef int32_t | ecu_event_id_t |
| Event ID type. Used so the library can implicitly typecast between this value, ecu_reserved_event_ids, and user-defined event ID enumerations. More... | |
Enumerations | |
| enum | ecu_reserved_event_ids { ECU_RESERVED_EVENT_ID = -1, ECU_VALID_EVENT_ID_BEGIN = 0, ECU_USER_EVENT_ID_BEGIN = ECU_VALID_EVENT_ID_BEGIN } |
| Event IDs reserved for ECU library. This scheme allows the library and users to uniquely define their own event IDs without conflicts. Event IDs reserved for ECU library will always be negative. Event IDs the user defines will start at 0 which is always ECU_USER_EVENT_ID_BEGIN. More... | |
Functions | |
Constructors | |
| void | ecu_event_ctor (struct ecu_event *me, ecu_event_id_t id, size_t size) |
| Constructs an ecu_event at run-time. More... | |
Member Functions | |
| ecu_event_id_t | ecu_event_id (const struct ecu_event *me) |
| Returns the event's ID. More... | |
| size_t | ecu_event_size (const struct ecu_event *me) |
| Returns the size (number of bytes) of the derived event. More... | |
Detailed Description
Macro Definition Documentation
◆ ECU_EVENT_BASE_CAST
| #define ECU_EVENT_BASE_CAST | ( | event_ptr_ | ) | ((struct ecu_event *)(event_ptr_)) |
◆ ECU_EVENT_CONST_BASE_CAST
| #define ECU_EVENT_CONST_BASE_CAST | ( | event_ptr_ | ) | ((const struct ecu_event *)(event_ptr_)) |
Same as ECU_EVENT_BASE_CAST() but performs a const-qualified upcast.
- Parameters
-
event_ptr_ Pointer to derived event. This type must inherit ecu_event base class. Can be either pointer to const or non-const.
◆ ECU_EVENT_CTOR
| #define ECU_EVENT_CTOR | ( | id_, | |
| size_ | |||
| ) |
Constructs an ecu_event at compile-time.
- Warning
- Validity of ID is not checked.
- Parameters
-
id_ ID to assign event. size_ Number of bytes of derived event. Allows for easier handling. I.e. reading and writing events to queues. Supply ECU_EVENT_SIZE_UNUSED if unused.
◆ ECU_EVENT_IS_BASE_OF
| #define ECU_EVENT_IS_BASE_OF | ( | base_, | |
| derived_ | |||
| ) | ECU_IS_BASE_OF(base_, derived_) |
Verifies, at compile-time, that derived event correctly inherits base event class via C-style inheritance. Returns true if this condition is satisfied. False otherwise.
- Parameters
-
base_ Name of base class member within user's derived_event type.derived_ Derived event type to check.
Typedef Documentation
◆ ecu_event_id_t
| typedef int32_t ecu_event_id_t |
Event ID type. Used so the library can implicitly typecast between this value, ecu_reserved_event_ids, and user-defined event ID enumerations.
- Warning
- This must be a signed integer type in order to handle ecu_reserved_event_ids enumerations less than 0. A compilation error will occur if this is declared as an unsigned type.
Enumeration Type Documentation
◆ ecu_reserved_event_ids
Event IDs reserved for ECU library. This scheme allows the library and users to uniquely define their own event IDs without conflicts. Event IDs reserved for ECU library will always be negative. Event IDs the user defines will start at 0 which is always ECU_USER_EVENT_ID_BEGIN.
Function Documentation
◆ ecu_event_ctor()
| void ecu_event_ctor | ( | struct ecu_event * | me, |
| ecu_event_id_t | id, | ||
| size_t | size | ||
| ) |
Constructs an ecu_event at run-time.
- Precondition
- Memory already allocated for
me
- Parameters
-
me Event to construct. This should be a derived event passed into this function via ECU_EVENT_BASE_CAST(). id User-defined event ID. This must be greater than or equal to ECU_VALID_EVENT_ID_BEGIN. size Number of bytes of derived event. Allows for easier handling. I.e. reading and writing events to queues. Supply ECU_EVENT_SIZE_UNUSED if unused.
◆ ecu_event_id()
| ecu_event_id_t ecu_event_id | ( | const struct ecu_event * | me | ) |
Returns the event's ID.
- Precondition
meconstructed via ECU_EVENT_CTOR() or ecu_event_ctor().
- Parameters
-
me Event to check. This should be a derived event passed into this function via ECU_EVENT_CONST_BASE_CAST().
◆ ecu_event_size()
| size_t ecu_event_size | ( | const struct ecu_event * | me | ) |
Returns the size (number of bytes) of the derived event.
- Precondition
meconstructed via ECU_EVENT_CTOR() or ecu_event_ctor().
- Parameters
-
me Event to check. This should be a derived event passed into this function via ECU_EVENT_CONST_BASE_CAST().
Generated by