1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HDF_OBSERVER_RECORD_H
10 #define HDF_OBSERVER_RECORD_H
11 
12 #include "hdf_device.h"
13 #include "hdf_object.h"
14 #include "hdf_slist.h"
15 #include "osal_mutex.h"
16 
17 struct HdfServiceObserverRecord {
18     struct HdfSListNode entry;
19     uint32_t serviceKey;
20     uint16_t policy;
21     devid_t devId;
22     struct OsalMutex obsRecMutex;
23     struct HdfSList subscribers;
24     struct HdfObject *publisher;
25 };
26 
27 struct HdfServiceObserverRecord *HdfServiceObserverRecordObtain(uint32_t serviceKey);
28 void HdfServiceObserverRecordRecycle(struct HdfServiceObserverRecord *observerRecord);
29 bool HdfServiceObserverRecordCompare(struct HdfSListNode *listEntry, uint32_t serviceKey);
30 void HdfServiceObserverRecordNotifySubscribers(
31     struct HdfServiceObserverRecord *record, devid_t deviceId, uint16_t policy);
32 void HdfServiceObserverRecordDelete(struct HdfSListNode *listEntry);
33 
34 #endif /* HDF_OBSERVER_RECORD_H */
35