supla-device
Loading...
Searching...
No Matches
local_action.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_LOCAL_ACTION_H_
5#define SRC_SUPLA_LOCAL_ACTION_H_
6
7#include <stdint.h>
8
9namespace Supla {
10
11class ActionHandler;
12class LocalAction;
13
15 public:
17
18 virtual ~ActionHandlerClient();
19
20 LocalAction *trigger = nullptr;
21 ActionHandler *client = nullptr;
22 ActionHandlerClient *next = nullptr;
23 uint16_t onEvent = 0;
24 uint16_t action = 0;
25 static ActionHandlerClient *begin;
26
27 bool isEnabled();
28
29 virtual void setAlwaysEnabled();
30 virtual void enable();
31 virtual void disable();
32 void disableForConfigMode();
33 void restoreAfterConfigMode();
34 virtual bool isAlwaysEnabled();
35
36 protected:
37 bool enabled = true;
38 bool alwaysEnabled = false;
39 bool disabledForConfigMode = false;
40};
41
43 public:
44 virtual ~LocalAction();
45 virtual void addAction(uint16_t action,
46 ActionHandler &client, // NOLINT(runtime/references)
47 uint16_t event,
48 bool alwaysEnabled = false);
49 virtual void addAction(uint16_t action, ActionHandler *client, uint16_t event,
50 bool alwaysEnabled = false);
51
52 virtual void runAction(uint16_t event) const;
53
54 virtual bool isEventAlreadyUsed(uint16_t event, bool ignoreAlwaysEnabled);
55 virtual ActionHandlerClient *getHandlerForFirstClient(uint16_t event);
56 virtual ActionHandlerClient *getHandlerForClient(ActionHandler *client,
57 uint16_t event);
58
59 virtual void disableOtherClients(const ActionHandler &client, uint16_t event);
60 virtual void enableOtherClients(const ActionHandler &client, uint16_t event);
61 virtual void disableOtherClients(const ActionHandler *client, uint16_t event);
62 virtual void enableOtherClients(const ActionHandler *client, uint16_t event);
63
64 static void DeleteActionsHandledBy(const ActionHandler *client);
65 static void DeleteActionsTriggeredBy(const LocalAction *action);
66 static void DeleteAction(const LocalAction *trigger,
67 const ActionHandler *client,
68 uint16_t event,
69 uint16_t action);
70 static void NullifyActionsHandledBy(const ActionHandler *client);
71
72 // action and event are internally uint16_t type, however -1 is used
73 // as "all events/actions", so here we pass int32_t
74 virtual void disableAction(int32_t action,
75 ActionHandler *client,
76 int32_t event);
77 virtual void enableAction(int32_t action,
78 ActionHandler *client,
79 int32_t event);
80
81 virtual bool disableActionsInConfigMode();
82
83 static ActionHandlerClient *getClientListPtr();
84};
85
86}; // namespace Supla
87
88#endif // SRC_SUPLA_LOCAL_ACTION_H_
Definition local_action.h:14
Definition action_handler.h:8
Definition local_action.h:42