OpenZWave Library: CompatOptionManager.h Source File

| OpenZWave Library 1.6.0

CompatOptionManager.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // CompatOptionManager.h
4 //
5 // Handles Compatibility Flags in Config Files
6 //
7 // Copyright (c) 2019 Justin Hammond <justin@dynam.ac>
8 //
9 // SOFTWARE NOTICE AND LICENSE
10 //
11 // This file is part of OpenZWave.
12 //
13 // OpenZWave is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License as published
15 // by the Free Software Foundation, either version 3 of the License,
16 // or (at your option) any later version.
17 //
18 // OpenZWave is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public License
24 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25 //
26 //-----------------------------------------------------------------------------
27
28 #ifndef CPP_SRC_COMPATOPTIONMANAGER_H_
29 #define CPP_SRC_COMPATOPTIONMANAGER_H_
30
31 #include "Defs.h"
32 #include "tinyxml.h"
33
34 #include <map>
35
36 namespace OpenZWave {
37
38 enum CompatOptionFlags
39 {
40 COMPAT_FLAG_GETSUPPORTED,
41 COMPAT_FLAG_OVERRIDEPRECISION,
42 COMPAT_FLAG_FORCEVERSION,
43 COMPAT_FLAG_CREATEVARS,
44 COMPAT_FLAG_REFRESHONWAKEUP,
45 COMPAT_FLAG_BASIC_IGNOREREMAPPING,
46 COMPAT_FLAG_BASIC_SETASREPORT,
47 COMPAT_FLAG_BASIC_MAPPING,
48 COMPAT_FLAG_COLOR_IDXBUG,
49 COMPAT_FLAG_MCA_FORCEINSTANCES,
50 COMPAT_FLAG_MI_MAPROOTTOENDPOINT,
51 COMPAT_FLAG_MI_FORCEUNIQUEENDPOINTS,
52 COMPAT_FLAG_MI_IGNMCCAPREPORTS,
53 COMPAT_FLAG_MI_ENDPOINTHINT,
54 COMPAT_FLAG_TSSP_BASE,
55 COMPAT_FLAG_TSSP_ALTTYPEINTERPRETATION,
56 COMPAT_FLAG_UC_EXPOSERAWVALUE,
57 COMPAT_FLAG_VERSION_GETCLASSVERSION,
58 COMPAT_FLAG_WAKEUP_DELAYNMI,
59 STATE_FLAG_CCVERSION,
60 STATE_FLAG_STATIC_REQUESTS,
61 STATE_FLAG_AFTERMARK,
62 STATE_FLAG_ENCRYPTED,
63 STATE_FLAG_INNIF,
64 STATE_FLAG_CS_SCENECOUNT,
65 STATE_FLAG_CS_CLEARTIMEOUT,
66 STATE_FLAG_CCS_CHANGECOUNTER,
67 STATE_FLAG_COLOR_CHANNELS,
68 STATE_FLAG_DOORLOCK_TIMEOUT,
69 STATE_FLAG_DOORLOCK_INSIDEMODE,
70 STATE_FLAG_DOORLOCK_OUTSIDEMODE,
71 STATE_FLAG_DOORLOCK_TIMEOUTMINS,
72 STATE_FLAG_DOORLOCK_TIMEOUTSECS,
73 STATE_FLAG_DOORLOCKLOG_MAXRECORDS,
74 STATE_FLAG_USERCODE_COUNT,
75 };
76
77 enum CompatOptionFlagType
78 {
79 COMPAT_FLAG_TYPE_BOOL,
80 COMPAT_FLAG_TYPE_BYTE,
81 COMPAT_FLAG_TYPE_SHORT,
82 COMPAT_FLAG_TYPE_INT
83 };
84
85 enum CompatOptionType
86 {
87 CompatOptionType_Compatibility,
88 CompatOptionType_Discovery
89 };
90
91 struct CompatOptionFlagStorage {
92 CompatOptionFlags flag;
93 CompatOptionFlagType type;
94 bool changed;
95 union {
96 bool valBool;
97 uint8_t valByte;
98 uint16_t valShort;
99 uint32_t valInt;
100 };
101 };
102
103 struct CompatOptionFlagDefintions {
104 string name;
105 CompatOptionFlags flag;
106 CompatOptionFlagType type;
107 };
108
109 class CommandClass;
110 class CompatOptionManager {
111 public:
112 CompatOptionManager(CompatOptionType type, CommandClass *cc);
113 virtual ~CompatOptionManager();
114
115 void SetNodeAndCC(uint8_t node, uint8_t cc);
116 void EnableFlag(CompatOptionFlags flag, uint32_t defaultval);
117
118 void ReadXML( TiXmlElement const* _ccElement );
119 void WriteXML( TiXmlElement* _ccElement );
120 bool GetFlagBool(CompatOptionFlags flag) const;
121 uint8_t GetFlagByte(CompatOptionFlags flag) const;
122 uint16_t GetFlagShort(CompatOptionFlags flag) const;
123 uint32_t GetFlagInt(CompatOptionFlags flag) const;
124 bool SetFlagBool(CompatOptionFlags flag, bool value);
125 bool SetFlagByte(CompatOptionFlags flag, uint8_t value);
126 bool SetFlagShort(CompatOptionFlags flag, uint16_t value);
127 bool SetFlagInt(CompatOptionFlags flag, uint32_t value);
128 private:
129 string GetFlagName(CompatOptionFlags flag) const;
130 string GetXMLTagName();
131 map<CompatOptionFlags, CompatOptionFlagStorage> m_CompatVals;
132 map<string, CompatOptionFlags> m_enabledCompatFlags;
133 CommandClass *m_owner;
134 CompatOptionType m_comtype;
135 CompatOptionFlagDefintions *m_availableFlags;
136 uint32_t m_availableFlagsCount;
137 };
138
139 } /* namespace OpenZWave */
140
141 #endif /* CPP_SRC_COMPATOPTIONMANAGER_H_ */
OpenZWave::COMPAT_FLAG_BASIC_MAPPING
@ COMPAT_FLAG_BASIC_MAPPING
Definition: CompatOptionManager.h:47
OpenZWave::STATE_FLAG_DOORLOCK_TIMEOUT
@ STATE_FLAG_DOORLOCK_TIMEOUT
Definition: CompatOptionManager.h:68
OpenZWave::COMPAT_FLAG_UC_EXPOSERAWVALUE
@ COMPAT_FLAG_UC_EXPOSERAWVALUE
Definition: CompatOptionManager.h:56
OpenZWave::STATE_FLAG_CS_SCENECOUNT
@ STATE_FLAG_CS_SCENECOUNT
Definition: CompatOptionManager.h:64
OpenZWave::COMPAT_FLAG_MI_FORCEUNIQUEENDPOINTS
@ COMPAT_FLAG_MI_FORCEUNIQUEENDPOINTS
Definition: CompatOptionManager.h:51
OpenZWave::STATE_FLAG_DOORLOCK_TIMEOUTMINS
@ STATE_FLAG_DOORLOCK_TIMEOUTMINS
Definition: CompatOptionManager.h:71
OpenZWave::CompatOptionManager::GetFlagShort
uint16_t GetFlagShort(CompatOptionFlags flag) const
Definition: CompatOptionManager.cpp:301
OpenZWave::STATE_FLAG_CCS_CHANGECOUNTER
@ STATE_FLAG_CCS_CHANGECOUNTER
Definition: CompatOptionManager.h:66
OpenZWave::STATE_FLAG_STATIC_REQUESTS
@ STATE_FLAG_STATIC_REQUESTS
Definition: CompatOptionManager.h:60
OpenZWave::CommandClass
Base class for all Z-Wave command classes.
Definition: CommandClass.h:56
OpenZWave::COMPAT_FLAG_BASIC_IGNOREREMAPPING
@ COMPAT_FLAG_BASIC_IGNOREREMAPPING
Definition: CompatOptionManager.h:45
OpenZWave::COMPAT_FLAG_MI_IGNMCCAPREPORTS
@ COMPAT_FLAG_MI_IGNMCCAPREPORTS
Definition: CompatOptionManager.h:52
OpenZWave::CompatOptionManager::SetFlagBool
bool SetFlagBool(CompatOptionFlags flag, bool value)
Definition: CompatOptionManager.cpp:335
OpenZWave::CompatOptionManager::SetFlagInt
bool SetFlagInt(CompatOptionFlags flag, uint32_t value)
Definition: CompatOptionManager.cpp:395
OpenZWave::COMPAT_FLAG_TYPE_SHORT
@ COMPAT_FLAG_TYPE_SHORT
Definition: CompatOptionManager.h:81
OpenZWave::COMPAT_FLAG_TYPE_INT
@ COMPAT_FLAG_TYPE_INT
Definition: CompatOptionManager.h:82
OpenZWave::CompatOptionFlagType
CompatOptionFlagType
Definition: CompatOptionManager.h:78
OpenZWave::CompatOptionFlagStorage::changed
bool changed
Definition: CompatOptionManager.h:94
OpenZWave::CompatOptionFlagStorage
Definition: CompatOptionManager.h:91
OpenZWave::CompatOptionManager::CompatOptionManager
CompatOptionManager(CompatOptionType type, CommandClass *cc)
Definition: CompatOptionManager.cpp:82
OpenZWave::CompatOptionFlagStorage::type
CompatOptionFlagType type
Definition: CompatOptionManager.h:93
OpenZWave::COMPAT_FLAG_VERSION_GETCLASSVERSION
@ COMPAT_FLAG_VERSION_GETCLASSVERSION
Definition: CompatOptionManager.h:57
OpenZWave::COMPAT_FLAG_MCA_FORCEINSTANCES
@ COMPAT_FLAG_MCA_FORCEINSTANCES
Definition: CompatOptionManager.h:49
OpenZWave::COMPAT_FLAG_WAKEUP_DELAYNMI
@ COMPAT_FLAG_WAKEUP_DELAYNMI
Definition: CompatOptionManager.h:58
OpenZWave::CompatOptionManager::SetFlagByte
bool SetFlagByte(CompatOptionFlags flag, uint8_t value)
Definition: CompatOptionManager.cpp:355
OpenZWave::STATE_FLAG_DOORLOCK_TIMEOUTSECS
@ STATE_FLAG_DOORLOCK_TIMEOUTSECS
Definition: CompatOptionManager.h:72
OpenZWave::CompatOptionFlagDefintions::flag
CompatOptionFlags flag
Definition: CompatOptionManager.h:105
OpenZWave::CompatOptionManager::WriteXML
void WriteXML(TiXmlElement *_ccElement)
Definition: CompatOptionManager.cpp:228
OpenZWave::COMPAT_FLAG_TSSP_BASE
@ COMPAT_FLAG_TSSP_BASE
Definition: CompatOptionManager.h:54
OpenZWave::COMPAT_FLAG_TSSP_ALTTYPEINTERPRETATION
@ COMPAT_FLAG_TSSP_ALTTYPEINTERPRETATION
Definition: CompatOptionManager.h:55
OpenZWave::STATE_FLAG_CCVERSION
@ STATE_FLAG_CCVERSION
Definition: CompatOptionManager.h:59
OpenZWave::COMPAT_FLAG_REFRESHONWAKEUP
@ COMPAT_FLAG_REFRESHONWAKEUP
Definition: CompatOptionManager.h:44
OpenZWave::STATE_FLAG_DOORLOCK_INSIDEMODE
@ STATE_FLAG_DOORLOCK_INSIDEMODE
Definition: CompatOptionManager.h:69
OpenZWave::CompatOptionType
CompatOptionType
Definition: CompatOptionManager.h:86
OpenZWave::STATE_FLAG_DOORLOCK_OUTSIDEMODE
@ STATE_FLAG_DOORLOCK_OUTSIDEMODE
Definition: CompatOptionManager.h:70
OpenZWave::CompatOptionManager::SetFlagShort
bool SetFlagShort(CompatOptionFlags flag, uint16_t value)
Definition: CompatOptionManager.cpp:375
OpenZWave::COMPAT_FLAG_FORCEVERSION
@ COMPAT_FLAG_FORCEVERSION
Definition: CompatOptionManager.h:42
OpenZWave::CompatOptionFlagStorage::valBool
bool valBool
Definition: CompatOptionManager.h:96
OpenZWave::CompatOptionManager::GetFlagByte
uint8_t GetFlagByte(CompatOptionFlags flag) const
Definition: CompatOptionManager.cpp:284
OpenZWave::COMPAT_FLAG_BASIC_SETASREPORT
@ COMPAT_FLAG_BASIC_SETASREPORT
Definition: CompatOptionManager.h:46
OpenZWave::STATE_FLAG_AFTERMARK
@ STATE_FLAG_AFTERMARK
Definition: CompatOptionManager.h:61
OpenZWave::COMPAT_FLAG_MI_ENDPOINTHINT
@ COMPAT_FLAG_MI_ENDPOINTHINT
Definition: CompatOptionManager.h:53
OpenZWave::COMPAT_FLAG_CREATEVARS
@ COMPAT_FLAG_CREATEVARS
Definition: CompatOptionManager.h:43
OpenZWave::CompatOptionFlagStorage::valShort
uint16_t valShort
Definition: CompatOptionManager.h:98
OpenZWave::CompatOptionManager::GetFlagInt
uint32_t GetFlagInt(CompatOptionFlags flag) const
Definition: CompatOptionManager.cpp:318
OpenZWave::COMPAT_FLAG_OVERRIDEPRECISION
@ COMPAT_FLAG_OVERRIDEPRECISION
Definition: CompatOptionManager.h:41
OpenZWave::CompatOptionManager::EnableFlag
void EnableFlag(CompatOptionFlags flag, uint32_t defaultval)
Definition: CompatOptionManager.cpp:109
OpenZWave::COMPAT_FLAG_TYPE_BYTE
@ COMPAT_FLAG_TYPE_BYTE
Definition: CompatOptionManager.h:80
OpenZWave::CompatOptionFlagDefintions
Definition: CompatOptionManager.h:103
OpenZWave::CompatOptionType_Discovery
@ CompatOptionType_Discovery
Definition: CompatOptionManager.h:88
OpenZWave::CompatOptionFlagStorage::flag
CompatOptionFlags flag
Definition: CompatOptionManager.h:92
OpenZWave::CompatOptionManager::~CompatOptionManager
virtual ~CompatOptionManager()
Definition: CompatOptionManager.cpp:102
OpenZWave::STATE_FLAG_USERCODE_COUNT
@ STATE_FLAG_USERCODE_COUNT
Definition: CompatOptionManager.h:74
OpenZWave::STATE_FLAG_CS_CLEARTIMEOUT
@ STATE_FLAG_CS_CLEARTIMEOUT
Definition: CompatOptionManager.h:65
OpenZWave::CompatOptionFlags
CompatOptionFlags
Definition: CompatOptionManager.h:39
OpenZWave::CompatOptionFlagStorage::valInt
uint32_t valInt
Definition: CompatOptionManager.h:99
OpenZWave::COMPAT_FLAG_GETSUPPORTED
@ COMPAT_FLAG_GETSUPPORTED
Definition: CompatOptionManager.h:40
OpenZWave::COMPAT_FLAG_COLOR_IDXBUG
@ COMPAT_FLAG_COLOR_IDXBUG
Definition: CompatOptionManager.h:48
OpenZWave::STATE_FLAG_ENCRYPTED
@ STATE_FLAG_ENCRYPTED
Definition: CompatOptionManager.h:62
OpenZWave::COMPAT_FLAG_MI_MAPROOTTOENDPOINT
@ COMPAT_FLAG_MI_MAPROOTTOENDPOINT
Definition: CompatOptionManager.h:50
OpenZWave::STATE_FLAG_DOORLOCKLOG_MAXRECORDS
@ STATE_FLAG_DOORLOCKLOG_MAXRECORDS
Definition: CompatOptionManager.h:73
OpenZWave::CompatOptionManager::GetFlagBool
bool GetFlagBool(CompatOptionFlags flag) const
Definition: CompatOptionManager.cpp:266
OpenZWave::CompatOptionFlagDefintions::name
string name
Definition: CompatOptionManager.h:104
OpenZWave::CompatOptionManager::ReadXML
void ReadXML(TiXmlElement const *_ccElement)
Definition: CompatOptionManager.cpp:155
OpenZWave::CompatOptionManager::SetNodeAndCC
void SetNodeAndCC(uint8_t node, uint8_t cc)
Defs.h
OpenZWave::STATE_FLAG_INNIF
@ STATE_FLAG_INNIF
Definition: CompatOptionManager.h:63
OpenZWave::CompatOptionManager
Definition: CompatOptionManager.h:110
OpenZWave::CompatOptionFlagStorage::valByte
uint8_t valByte
Definition: CompatOptionManager.h:97
OpenZWave::CompatOptionType_Compatibility
@ CompatOptionType_Compatibility
Definition: CompatOptionManager.h:87
OpenZWave
Definition: Bitfield.h:35
OpenZWave::STATE_FLAG_COLOR_CHANNELS
@ STATE_FLAG_COLOR_CHANNELS
Definition: CompatOptionManager.h:67
OpenZWave::CompatOptionFlagDefintions::type
CompatOptionFlagType type
Definition: CompatOptionManager.h:106
OpenZWave::COMPAT_FLAG_TYPE_BOOL
@ COMPAT_FLAG_TYPE_BOOL
Definition: CompatOptionManager.h:79