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