OpenZWave Library  1.6.784
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 
39  namespace Internal
40  {
41  namespace CC
42  {
43  class CommandClass;
44  }
45 
47  {
85  };
86 
88  {
97  };
98 
100  {
103  };
104 
106  {
109  bool changed;
110  /* when a single Value (not a FLAG_TYPE_*_ARRAY) this union holds the actual value
111  * but when its a FLAG_*_ARRAY, this union holds the default value
112  */
113  union
114  {
115  bool valBool;
116  uint8_t valByte;
117  uint16_t valShort;
118  uint32_t valInt;
119  };
120  /* Only when FLAG_TYPE_*_ARRAY is this union used, and holds
121  * individual values for each key. Default Value is taken from
122  * the above Union
123  */
124  /* oh - And we can't use a Union here with a non-POD type */
125  std::map<uint32_t, bool> valBoolArray;
126  std::map<uint32_t, uint8_t> valByteArray;
127  std::map<uint32_t, uint16_t> valShortArray;
128  std::map<uint32_t, uint32_t> valIntArray;
129  };
130 
132  {
133  string name;
136  };
137 
139  {
140  public:
142  virtual ~CompatOptionManager();
143 
144  void SetNodeAndCC(uint8_t node, uint8_t cc);
145  void EnableFlag(CompatOptionFlags flag, uint32_t defaultval);
146 
147  void ReadXML(TiXmlElement const* _ccElement);
148  void WriteXML(TiXmlElement* _ccElement);
149  bool GetFlagBool(CompatOptionFlags flag, uint32_t index = -1) const;
150  uint8_t GetFlagByte(CompatOptionFlags flag, uint32_t index = -1) const;
151  uint16_t GetFlagShort(CompatOptionFlags flag, uint32_t index = -1) const;
152  uint32_t GetFlagInt(CompatOptionFlags flag, uint32_t index = -1) const;
153  bool SetFlagBool(CompatOptionFlags flag, bool value, uint32_t index = -1);
154  bool SetFlagByte(CompatOptionFlags flag, uint8_t value, uint32_t index = -1);
155  bool SetFlagShort(CompatOptionFlags flag, uint16_t value, uint32_t index = -1);
156  bool SetFlagInt(CompatOptionFlags flag, uint32_t value, uint32_t index = -1);
157  private:
158  string GetFlagName(CompatOptionFlags flag) const;
159  string GetXMLTagName();
160  map<CompatOptionFlags, CompatOptionFlagStorage> m_CompatVals;
161  map<string, CompatOptionFlags> m_enabledCompatFlags;
163  CompatOptionType m_comtype;
164  CompatOptionFlagDefintions *m_availableFlags;
165  uint32_t m_availableFlagsCount;
166  };
167  } // namespace Internal
168 } /* namespace OpenZWave */
169 
170 #endif /* CPP_SRC_COMPATOPTIONMANAGER_H_ */
Definition: CompatOptionManager.h:93
Definition: CompatOptionManager.h:76
Definition: CompatOptionManager.h:77
Definition: CompatOptionManager.h:81
Definition: CompatOptionManager.h:72
void SetNodeAndCC(uint8_t node, uint8_t cc)
Definition: CompatOptionManager.h:105
Definition: CompatOptionManager.h:101
Definition: Bitfield.cpp:30
Definition: CompatOptionManager.h:70
uint32_t GetFlagInt(CompatOptionFlags flag, uint32_t index=-1) const
Definition: CompatOptionManager.cpp:520
bool changed
Definition: CompatOptionManager.h:109
Definition: CompatOptionManager.h:55
Definition: CompatOptionManager.h:48
bool SetFlagInt(CompatOptionFlags flag, uint32_t value, uint32_t index=-1)
Definition: CompatOptionManager.cpp:644
Definition: CompatOptionManager.h:82
void EnableFlag(CompatOptionFlags flag, uint32_t defaultval)
Definition: CompatOptionManager.cpp:105
Definition: CompatOptionManager.h:61
bool SetFlagBool(CompatOptionFlags flag, bool value, uint32_t index=-1)
Definition: CompatOptionManager.cpp:548
Definition: CompatOptionManager.h:62
CompatOptionType
Definition: CompatOptionManager.h:99
bool SetFlagByte(CompatOptionFlags flag, uint8_t value, uint32_t index=-1)
Definition: CompatOptionManager.cpp:580
void ReadXML(TiXmlElement const *_ccElement)
Definition: CompatOptionManager.cpp:157
Definition: CompatOptionManager.h:51
CompatOptionManager(CompatOptionType type, Internal::CC::CommandClass *cc)
Definition: CompatOptionManager.cpp:85
Definition: CompatOptionManager.h:94
Definition: CompatOptionManager.h:91
Base class for all Z-Wave command classes.
Definition: CommandClass.h:60
Definition: CompatOptionManager.h:68
virtual ~CompatOptionManager()
Definition: CompatOptionManager.cpp:101
Definition: CompatOptionManager.h:102
CompatOptionFlagType type
Definition: CompatOptionManager.h:108
CompatOptionFlagType
Definition: CompatOptionManager.h:87
Definition: CompatOptionManager.h:69
Definition: CompatOptionManager.h:67
CompatOptionFlags flag
Definition: CompatOptionManager.h:107
CompatOptionFlags
Definition: CompatOptionManager.h:46
std::map< uint32_t, uint32_t > valIntArray
Definition: CompatOptionManager.h:128
std::map< uint32_t, bool > valBoolArray
Definition: CompatOptionManager.h:125
Definition: CompatOptionManager.h:56
Definition: CompatOptionManager.h:73
Definition: CompatOptionManager.h:49
std::map< uint32_t, uint16_t > valShortArray
Definition: CompatOptionManager.h:127
void WriteXML(TiXmlElement *_ccElement)
Definition: CompatOptionManager.cpp:326
Definition: CompatOptionManager.h:78
uint16_t GetFlagShort(CompatOptionFlags flag, uint32_t index=-1) const
Definition: CompatOptionManager.cpp:492
bool GetFlagBool(CompatOptionFlags flag, uint32_t index=-1) const
Definition: CompatOptionManager.cpp:437
uint8_t valByte
Definition: CompatOptionManager.h:116
Definition: CompatOptionManager.h:54
Definition: CompatOptionManager.h:71
Definition: CompatOptionManager.h:131
bool valBool
Definition: CompatOptionManager.h:115
Definition: CompatOptionManager.h:75
Definition: CompatOptionManager.h:52
string name
Definition: CompatOptionManager.h:133
Definition: CompatOptionManager.h:79
Definition: CompatOptionManager.h:60
CompatOptionFlagType type
Definition: CompatOptionManager.h:135
Definition: CompatOptionManager.h:138
uint16_t valShort
Definition: CompatOptionManager.h:117
Definition: CompatOptionManager.h:90
Definition: CompatOptionManager.h:84
Definition: CompatOptionManager.h:50
Definition: CompatOptionManager.h:83
Definition: CompatOptionManager.h:80
bool SetFlagShort(CompatOptionFlags flag, uint16_t value, uint32_t index=-1)
Definition: CompatOptionManager.cpp:612
Definition: CompatOptionManager.h:95
uint8_t GetFlagByte(CompatOptionFlags flag, uint32_t index=-1) const
Definition: CompatOptionManager.cpp:464
std::map< uint32_t, uint8_t > valByteArray
Definition: CompatOptionManager.h:126
Definition: CompatOptionManager.h:89
Definition: CompatOptionManager.h:64
Definition: CompatOptionManager.h:96
Definition: CompatOptionManager.h:92
Definition: CompatOptionManager.h:74
Definition: CompatOptionManager.h:53
CompatOptionFlags flag
Definition: CompatOptionManager.h:134
Definition: CompatOptionManager.h:57
Definition: CompatOptionManager.h:66
Definition: CompatOptionManager.h:58
uint32_t valInt
Definition: CompatOptionManager.h:118