libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
HmLogicalParameter.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef HMLOGICALPARAMETER_H_
32 #define HMLOGICALPARAMETER_H_
33 
34 #include "../../Variable.h"
35 
36 #include <string>
37 #include <vector>
38 #include <memory>
39 #include <unordered_map>
40 #include <limits>
41 
42 namespace BaseLib
43 {
44 
45 class SharedObjects;
46 
47 namespace HmDeviceDescription
48 {
49 
51 {
52 public:
53  std::string id;
54  bool isDefault = false;
55  int32_t index = -1;
56 
59  virtual ~ParameterOption() {}
60 };
61 
63 {
64 public:
65  struct Type
66  {
67  enum Enum { none = 0x00, typeInteger = 0x01, typeBoolean = 0x02, typeString = 0x03, typeFloat = 0x04, typeEnum = 0x20, typeAction = 0x30 };
68  };
69  std::string unit;
70  bool defaultValueExists = false;
71  bool enforce = false;
72  Type::Enum type = Type::none;
73 
75  virtual ~LogicalParameter() {}
76  static std::shared_ptr<LogicalParameter> fromXML(BaseLib::SharedObjects* baseLib, xml_node* node);
77  virtual std::shared_ptr<Variable> getEnforceValue();
78  virtual std::shared_ptr<Variable> getDefaultValue();
79 protected:
81 };
82 
84 {
85 public:
86  int32_t min = -2147483648;
87  int32_t max = 2147483647;
88  int32_t defaultValue = 0;
89  int32_t enforceValue = 0;
90  std::unordered_map<std::string, int32_t> specialValues;
91 
95  virtual std::shared_ptr<Variable> getEnforceValue();
96  virtual std::shared_ptr<Variable> getDefaultValue();
97 };
98 
100 {
101 public:
102  double min = 1.175494351e-38f;
103  double max = 3.40282347e+38f;
104  double defaultValue = 0;
105  double enforceValue = 0;
106  std::unordered_map<std::string, double> specialValues;
107 
111  virtual std::shared_ptr<Variable> getEnforceValue();
112  virtual std::shared_ptr<Variable> getDefaultValue();
113 };
114 
116 {
117 public:
118  int32_t min = 0;
119  int32_t max = 0;
120  int32_t defaultValue = 0;
121  int32_t enforceValue = 0;
122 
126  std::vector<ParameterOption> options;
127  virtual std::shared_ptr<Variable> getEnforceValue();
128  virtual std::shared_ptr<Variable> getDefaultValue();
129 };
130 
132 {
133 public:
134  bool min = false;
135  bool max = true;
136  bool defaultValue = false;
137  bool enforceValue = false;
138 
142  virtual std::shared_ptr<Variable> getEnforceValue();
143  virtual std::shared_ptr<Variable> getDefaultValue();
144 };
145 
147 {
148 public:
149  std::string min;
150  std::string max;
151  std::string defaultValue;
152  std::string enforceValue;
153 
157  virtual std::shared_ptr<Variable> getEnforceValue();
158  virtual std::shared_ptr<Variable> getDefaultValue();
159 };
160 
162 {
163 public:
164  bool min = false;
165  bool max = true;
166  bool defaultValue = false;
167  bool enforceValue = false;
168 
172  virtual std::shared_ptr<Variable> getEnforceValue();
173  virtual std::shared_ptr<Variable> getDefaultValue();
174 };
175 
176 }
177 }
178 #endif /* LOGICALPARAMETER_H_ */
virtual ~LogicalParameterBoolean()
Definition: HmLogicalParameter.h:141
std::string enforceValue
Definition: HmLogicalParameter.h:152
Enum
Definition: HmLogicalParameter.h:67
int32_t index
Definition: HmLogicalParameter.h:55
BaseLib::SharedObjects * _bl
Definition: HmLogicalParameter.h:80
This is the base library main class.
Definition: BaseLib.h:95
Definition: HmLogicalParameter.h:131
std::unordered_map< std::string, int32_t > specialValues
Definition: HmLogicalParameter.h:90
Definition: BaseLib.cpp:34
virtual ~LogicalParameterInteger()
Definition: HmLogicalParameter.h:94
virtual ~LogicalParameterEnum()
Definition: HmLogicalParameter.h:125
Definition: HmLogicalParameter.h:50
Definition: HmLogicalParameter.h:161
virtual ~LogicalParameterAction()
Definition: HmLogicalParameter.h:171
std::vector< ParameterOption > options
Definition: HmLogicalParameter.h:126
virtual ~LogicalParameter()
Definition: HmLogicalParameter.h:75
std::unordered_map< std::string, double > specialValues
Definition: HmLogicalParameter.h:106
Definition: HmLogicalParameter.h:62
std::string unit
Definition: HmLogicalParameter.h:69
std::string min
Definition: HmLogicalParameter.h:149
Definition: HmLogicalParameter.h:65
virtual ~LogicalParameterFloat()
Definition: HmLogicalParameter.h:110
ParameterOption()
Definition: HmLogicalParameter.h:57
virtual ~ParameterOption()
Definition: HmLogicalParameter.h:59
bool isDefault
Definition: HmLogicalParameter.h:54
Definition: HmLogicalParameter.h:99
std::string id
Definition: HmLogicalParameter.h:53
Definition: HmLogicalParameter.h:146
Class representing a node of XML document.
Definition: rapidxml.h:539
Definition: HmLogicalParameter.h:115
virtual ~LogicalParameterString()
Definition: HmLogicalParameter.h:156
std::string max
Definition: HmLogicalParameter.h:150
std::string defaultValue
Definition: HmLogicalParameter.h:151