Zigbee Protocol Controller 1.6.0
zigpc_common_observable.h
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
99#ifndef ZIGPC_COMMON_OBSERVER_H
100#define ZIGPC_COMMON_OBSERVER_H
101
102#include <stdint.h>
103
104#include "sl_status.h"
105
106#ifdef __cplusplus
107extern "C" {
108#endif
109
114#define ZIGPC_OBSERVER_EVENTS_MAX 20
115
120#define ZIGPC_OBSERVER_EVENT_CALLBACKS_MAX 5
121
127
136typedef void (*zigpc_observer_callback_t)(void *data);
137
141};
142
149 uint8_t event_count;
150};
151
164 void *data);
195 const zigpc_observer_callback_t callback);
196
211 const zigpc_observer_event_t *event_list,
212 const uint8_t event_count);
213
219void zigpc_observable_clear(struct zigpc_observable *observable);
220
221#ifdef __cplusplus
222}
223#endif
224
225#endif /* ZIGPC_COMMON_OBSERVER_H */
226
#define data
Definition: ctimer.c:49
uint32_t sl_status_t
Definition: sl_status.h:139
#define ZIGPC_OBSERVER_EVENTS_MAX
Maximum number of events supported by an observable instance.
Definition: zigpc_common_observable.h:114
sl_status_t zigpc_observable_unregister(struct zigpc_observable *observable, const zigpc_observer_event_t event, const zigpc_observer_callback_t callback)
Unregister an observer with a corresponding event from observable instance.
Definition: zigpc_common_observable.c:171
#define ZIGPC_OBSERVER_EVENT_CALLBACKS_MAX
Maximum number of listeners per event supported by an observable instance.
Definition: zigpc_common_observable.h:120
sl_status_t zigpc_observable_register(struct zigpc_observable *observable, const zigpc_observer_event_t event, zigpc_observer_callback_t callback)
Register an observer with a corresponding event to observable instance.
Definition: zigpc_common_observable.c:136
void(* zigpc_observer_callback_t)(void *data)
Observer callback that is called by subjects when notifying observers of new events.
Definition: zigpc_common_observable.h:136
sl_status_t zigpc_observable_init(struct zigpc_observable *observable, const zigpc_observer_event_t *event_list, const uint8_t event_count)
Initialize observable with an approved event list.
Definition: zigpc_common_observable.c:231
uint8_t zigpc_observer_event_t
Observer event type.
Definition: zigpc_common_observable.h:126
sl_status_t zigpc_observable_notify(const struct zigpc_observable *observable, const zigpc_observer_event_t event, void *data)
Inform Observers of observable instance of an event with data.
Definition: zigpc_common_observable.c:79
void zigpc_observable_clear(struct zigpc_observable *observable)
Stop all observers from being notified.
Definition: zigpc_common_observable.c:264
SL Status Codes.
Definition: zigpc_common_observable.h:138
zigpc_observer_callback_t callbacks[ZIGPC_OBSERVER_EVENT_CALLBACKS_MAX]
Definition: zigpc_common_observable.h:140
zigpc_observer_event_t event
Definition: zigpc_common_observable.h:139
Observable instance.
Definition: zigpc_common_observable.h:147
struct zigpc_observable_event_entry event_list[ZIGPC_OBSERVER_EVENTS_MAX]
Definition: zigpc_common_observable.h:148
uint8_t event_count
Definition: zigpc_common_observable.h:149