supla-device
Loading...
Searching...
No Matches
local_action.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15*/
16
17#ifndef SRC_SUPLA_LOCAL_ACTION_H_
18#define SRC_SUPLA_LOCAL_ACTION_H_
19
20#include <stdint.h>
21#include "action_handler.h"
22
23namespace Supla {
24
25class LocalAction;
26class Condition;
27
28class ActionHandlerClient {
29 public:
30 ActionHandlerClient();
31
32 virtual ~ActionHandlerClient();
33
34 LocalAction *trigger = nullptr;
35 ActionHandler *client = nullptr;
36 ActionHandlerClient *next = nullptr;
37 uint16_t onEvent = 0;
38 uint16_t action = 0;
39 static ActionHandlerClient *begin;
40
41 bool isEnabled();
42
43 virtual void setAlwaysEnabled();
44 virtual void enable();
45 virtual void disable();
46 virtual bool isAlwaysEnabled();
47
48 protected:
49 bool enabled = true;
50 bool alwaysEnabled = false;
51};
52
54 public:
55 virtual ~LocalAction();
56 virtual void addAction(uint16_t action,
57 ActionHandler &client, // NOLINT(runtime/references)
58 uint16_t event,
59 bool alwaysEnabled = false);
60 virtual void addAction(uint16_t action, ActionHandler *client, uint16_t event,
61 bool alwaysEnabled = false);
62
63 virtual void runAction(uint16_t event) const;
64
65 virtual bool isEventAlreadyUsed(uint16_t event, bool ignoreAlwaysEnabled);
66 virtual ActionHandlerClient *getHandlerForFirstClient(uint16_t event);
67 virtual ActionHandlerClient *getHandlerForClient(ActionHandler *client,
68 uint16_t event);
69
70 virtual void disableOtherClients(const ActionHandler &client, uint16_t event);
71 virtual void enableOtherClients(const ActionHandler &client, uint16_t event);
72 virtual void disableOtherClients(const ActionHandler *client, uint16_t event);
73 virtual void enableOtherClients(const ActionHandler *client, uint16_t event);
74
75 static void DeleteActionsHandledBy(const ActionHandler *client);
76 static void DeleteActionsTriggeredBy(const LocalAction *action);
77 static void NullifyActionsHandledBy(const ActionHandler *client);
78
79 // action and event are internally uint16_t type, however -1 is used
80 // as "all events/actions", so here we pass int32_t
81 virtual void disableAction(int32_t action,
82 ActionHandler *client,
83 int32_t event);
84 virtual void enableAction(int32_t action,
85 ActionHandler *client,
86 int32_t event);
87
88 virtual bool disableActionsInConfigMode();
89
90 static ActionHandlerClient *getClientListPtr();
91};
92
93}; // namespace Supla
94
95#endif // SRC_SUPLA_LOCAL_ACTION_H_
Definition local_action.h:28
Definition action_handler.h:21
Definition condition.h:27
Definition local_action.h:53