|
OBSERVER Embedded C library v1.0.0
|
Deterministic Observer pattern implementation for safety-critical systems. More...

Functions | |
| subscr_status_e | subscribe (observer_cb_t *subscription_table, observer_cb_t cb_2_register, uint8_t subscription_table_size) |
| Register a callback in the subscription table (void callbacks). More... | |
| subscr_status_e | unsubscribe (observer_cb_t *subscription_table, observer_cb_t cb_2_remove, uint8_t subscription_table_size) |
| Unregister a callback from the subscription table (void callbacks). More... | |
| subscr_status_e | notify (observer_cb_t *subscription_table, uint8_t subscription_table_size) |
| Notify all registered callbacks (no argument). More... | |
| subscr_status_e | subscribe_state_change (observer_cb_state_t *subscription_table, observer_cb_state_t cb_2_register, uint8_t subscription_table_size) |
| Register a callback with event_state_e argument. More... | |
| subscr_status_e | unsubscribe_state_change (observer_cb_state_t *subscription_table, observer_cb_state_t cb_2_remove, uint8_t subscription_table_size) |
| Unregister a callback with event_state_e argument. More... | |
| subscr_status_e | notify_state_change (observer_cb_state_t *subscription_table, uint8_t subscription_table_size, event_state_e state) |
| Notify all registered callbacks with event_state_e argument. More... | |
| subscr_status_e | subscribe_u8 (observer_cb_u8_arg_t *subscription_table, observer_cb_u8_arg_t cb_2_register, uint8_t subscription_table_size) |
| Register a callback with uint8_t argument. More... | |
| subscr_status_e | unsubscribe_u8 (observer_cb_u8_arg_t *subscription_table, observer_cb_u8_arg_t cb_2_remove, uint8_t subscription_table_size) |
| Unregister a callback with uint8_t argument. More... | |
| subscr_status_e | notify_u8 (observer_cb_u8_arg_t *subscription_table, uint8_t subscription_table_size, uint8_t data) |
| Notify all registered callbacks with uint8_t argument. More... | |
Deterministic Observer pattern implementation for safety-critical systems.
Implements a static, deterministic variant of the Observer pattern suitable for safety-critical and resource-constrained embedded environments.
All API functions:
@thread_safety None of the API functions are reentrant or thread-safe. Caller must ensure synchronization if used concurrently.
@autho niwciu (niwci.nosp@m.u@gm.nosp@m.ail.c.nosp@m.om)
@safety Designed to meet MISRA C 2012 and ISO 26262 Part 6 software safety goals.
| subscr_status_e notify | ( | observer_cb_t * | subscription_table, |
| uint8_t | subscription_table_size | ||
| ) |
Notify all registered callbacks (no argument).
Invokes all non-NULL callbacks in ascending index order.
| [in] | subscription_table | Pointer to an array of observer_cb_t. |
| [in] | subscription_table_size | Table length. |
| subscr_status_e notify_state_change | ( | observer_cb_state_t * | subscription_table, |
| uint8_t | subscription_table_size, | ||
| event_state_e | state | ||
| ) |
Notify all registered callbacks with event_state_e argument.
Calls all valid (non-NULL) callbacks, passing the given event state.
| [in] | subscription_table | Pointer to array of observer_cb_state_t. |
| [in] | subscription_table_size | Table length. |
| [in] | state | Event state passed to callbacks. |
state. @safety Not reentrant; caller must ensure synchronization. @traceability OBSR-FUNC-006 | subscr_status_e notify_u8 | ( | observer_cb_u8_arg_t * | subscription_table, |
| uint8_t | subscription_table_size, | ||
| uint8_t | data | ||
| ) |
Notify all registered callbacks with uint8_t argument.
Invokes all registered callbacks, passing a uint8_t data value.
| [in] | subscription_table | Pointer to array of observer_cb_u8_arg_t. |
| [in] | subscription_table_size | Table length. |
| [in] | data | Data argument passed to each callback. |
data. @safety Not reentrant; caller must ensure synchronization. @traceability OBSR-FUNC-009 | subscr_status_e subscribe | ( | observer_cb_t * | subscription_table, |
| observer_cb_t | cb_2_register, | ||
| uint8_t | subscription_table_size | ||
| ) |
Register a callback in the subscription table (void callbacks).
Registers a callback function in the provided subscription table. If the callback is already present, it is not added again.
| [in,out] | subscription_table | Pointer to an array of observer_cb_t. |
| [in] | cb_2_register | Callback function to register. |
| [in] | subscription_table_size | Number of entries in the table (must be > 0). |
subscription_table points to a valid array of given size. cb_2_register is stored in the table. @safety Not reentrant; caller must ensure synchronization. @traceability OBSR-FUNC-001 | subscr_status_e subscribe_state_change | ( | observer_cb_state_t * | subscription_table, |
| observer_cb_state_t | cb_2_register, | ||
| uint8_t | subscription_table_size | ||
| ) |
Register a callback with event_state_e argument.
Registers a state-change callback in the given subscription table. Prevents duplicate registrations.
| [in,out] | subscription_table | Pointer to array of observer_cb_state_t. |
| [in] | cb_2_register | Callback function to register. |
| [in] | subscription_table_size | Table length (must be > 0). |
| subscr_status_e subscribe_u8 | ( | observer_cb_u8_arg_t * | subscription_table, |
| observer_cb_u8_arg_t | cb_2_register, | ||
| uint8_t | subscription_table_size | ||
| ) |
Register a callback with uint8_t argument.
Registers a callback in the given table if not already present.
| [in,out] | subscription_table | Pointer to array of observer_cb_u8_arg_t. |
| [in] | cb_2_register | Callback to register. |
| [in] | subscription_table_size | Table length (must be > 0). |
| subscr_status_e unsubscribe | ( | observer_cb_t * | subscription_table, |
| observer_cb_t | cb_2_remove, | ||
| uint8_t | subscription_table_size | ||
| ) |
Unregister a callback from the subscription table (void callbacks).
Removes a registered callback and compacts the table by shifting subsequent entries left.
| [in,out] | subscription_table | Pointer to an array of observer_cb_t. |
| [in] | cb_2_remove | Callback function to remove. |
| [in] | subscription_table_size | Table length. |
| subscr_status_e unsubscribe_state_change | ( | observer_cb_state_t * | subscription_table, |
| observer_cb_state_t | cb_2_remove, | ||
| uint8_t | subscription_table_size | ||
| ) |
Unregister a callback with event_state_e argument.
Removes a previously registered callback from the table and compacts it.
| [in,out] | subscription_table | Pointer to array of observer_cb_state_t. |
| [in] | cb_2_remove | Callback function to remove. |
| [in] | subscription_table_size | Table length. |
| subscr_status_e unsubscribe_u8 | ( | observer_cb_u8_arg_t * | subscription_table, |
| observer_cb_u8_arg_t | cb_2_remove, | ||
| uint8_t | subscription_table_size | ||
| ) |
Unregister a callback with uint8_t argument.
Removes a callback from the table and shifts subsequent entries left.
| [in,out] | subscription_table | Pointer to array of observer_cb_u8_arg_t. |
| [in] | cb_2_remove | Callback to remove. |
| [in] | subscription_table_size | Table length. |