supla-device
Loading...
Searching...
No Matches
channel_conflict_resolver.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_DEVICE_CHANNEL_CONFLICT_RESOLVER_H_
5#define SRC_SUPLA_DEVICE_CHANNEL_CONFLICT_RESOLVER_H_
6
7#include <stdint.h>
8
9namespace Supla {
10namespace Device {
11
13 public:
14 virtual ~ChannelConflictObserver() = default;
15 virtual void onChannelConflictResolution(bool handled) = 0;
16};
17
19 public:
20 virtual ~ChannelConflictResolver() = default;
21 virtual bool onChannelConflictReport(
22 uint8_t *channelReport,
23 uint8_t channelReportSize,
24 bool hasConfilictInvalidType,
25 bool hasConfilictChannelMissingOnServer,
26 bool hasConflictChannelMissingOnDevice) = 0;
27
28 void setChannelConflictObserver(ChannelConflictObserver *newObserver) {
29 observer = newObserver;
30 }
31
32 protected:
33 void notifyChannelConflictResolution(bool handled) {
34 if (observer != nullptr) {
35 observer->onChannelConflictResolution(handled);
36 }
37 }
38
39 private:
40 ChannelConflictObserver *observer = nullptr;
41};
42
44 ChannelConflictResolver *resolver = nullptr;
45 ChannelConflictResolverListItem *next = nullptr;
46};
47
49 public:
51
52 bool add(ChannelConflictResolver *resolver);
53 bool remove(ChannelConflictResolver *resolver);
54 void clear();
55 bool contains(ChannelConflictResolver *resolver) const;
56 bool isEmpty() const;
57
58 bool onChannelConflictReport(
59 uint8_t *channelReport,
60 uint8_t channelReportSize,
61 bool hasConfilictInvalidType,
62 bool hasConfilictChannelMissingOnServer,
63 bool hasConflictChannelMissingOnDevice) override;
64
65 private:
66 ChannelConflictResolverListItem *first = nullptr;
67};
68
69} // namespace Device
70} // namespace Supla
71
72#endif // SRC_SUPLA_DEVICE_CHANNEL_CONFLICT_RESOLVER_H_
Definition channel_conflict_resolver.h:12
Definition channel_conflict_resolver.h:48
Definition channel_conflict_resolver.h:18
Definition channel_conflict_resolver.h:43