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