libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
ParameterGroup.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 PARAMETERGROUP_H_
32 #define PARAMETERGROUP_H_
33 
34 #include "Parameter.h"
35 #include "Scenario.h"
36 #include <string>
37 
38 using namespace rapidxml;
39 
40 namespace BaseLib
41 {
42 namespace DeviceDescription
43 {
44 
45 class Function;
46 class ParameterGroup;
47 class ConfigParameters;
48 class LinkParameters;
49 class Variables;
50 
51 typedef std::shared_ptr<ParameterGroup> PParameterGroup;
52 typedef std::shared_ptr<ConfigParameters> PConfigParameters;
53 typedef std::shared_ptr<LinkParameters> PLinkParameters;
54 typedef std::shared_ptr<Variables> PVariables;
55 typedef std::map<uint32_t, std::vector<PParameter>> Lists;
56 
57 
58 class ParameterGroup : public std::enable_shared_from_this<ParameterGroup>
59 {
60 public:
61  struct Type
62  {
63  enum Enum { none = 0, config = 1, variables = 2, link = 3 };
64  };
65 
66  explicit ParameterGroup(BaseLib::SharedObjects* baseLib);
67  virtual ~ParameterGroup();
68 
69  virtual void parseXml(xml_node* node);
70 
71  //Attributes
72  std::string id;
73  int32_t memoryAddressStart = -1;
74  int32_t memoryAddressStep = -1;
75 
76  //Elements
78  std::vector<PParameter> parametersOrdered; //Needed for saving as the ordering of the parameters matters on some systems (e. g. HomeMatic CCU)
80 
81  //Helpers
82  Lists lists;
84 
85  virtual Type::Enum type() const = 0;
86  static Type::Enum typeFromString(std::string type);
87  PParameter getParameter(std::string id);
88  void getIndices(uint32_t startIndex, uint32_t endIndex, int32_t list, std::vector<PParameter>& result);
89 protected:
90  BaseLib::SharedObjects* _bl = nullptr;
91 
92  void parseAttributes(xml_node* node);
93  void parseElements(xml_node* node);
94 };
95 
97 {
98 public:
99  explicit ConfigParameters(BaseLib::SharedObjects* baseLib);
100  ~ConfigParameters() override = default;
101 
102  //Helpers
103  Type::Enum type() const override { return Type::Enum::config; };
104 };
105 
106 class Variables : public ParameterGroup
107 {
108 public:
109  explicit Variables(BaseLib::SharedObjects* baseLib);
110  ~Variables() override = default;
111 
112  //Helpers
113  Type::Enum type() const override { return Type::Enum::variables; };
114 };
115 
117 {
118 public:
119  explicit LinkParameters(BaseLib::SharedObjects* baseLib);
120  ~LinkParameters() override = default;
121 
122  void parseXml(xml_node* node) override;
123 
124  //Helpers
125  Type::Enum type() const override { return Type::Enum::link; };
126 
127  //Attributes
128  int32_t peerChannelMemoryOffset = -1;
129  int32_t channelMemoryOffset = -1;
130  int32_t peerAddressMemoryOffset = -1;
131  int32_t maxLinkCount = -1;
132 };
133 
134 }
135 }
136 
137 #endif
Type::Enum type() const override
Definition: ParameterGroup.h:103
Scenarios scenarios
Definition: ParameterGroup.h:79
Definition: ParameterGroup.h:106
Parameters parameters
Definition: ParameterGroup.h:77
std::string id
Definition: ParameterGroup.h:72
This is the base library main class.
Definition: BaseLib.h:95
std::shared_ptr< ConfigParameters > PConfigParameters
Definition: ParameterGroup.h:52
Type::Enum type() const override
Definition: ParameterGroup.h:113
Lists lists
Definition: ParameterGroup.h:82
Definition: BaseLib.cpp:34
std::map< std::string, PScenario > Scenarios
Definition: Scenario.h:56
std::vector< PParameter > parametersOrdered
Definition: ParameterGroup.h:78
std::shared_ptr< ParameterGroup > PParameterGroup
Definition: Parameter.h:52
Definition: ParameterGroup.h:96
Definition: ParameterGroup.h:58
PParameter parameterGroupSelector
Definition: ParameterGroup.h:83
std::shared_ptr< LinkParameters > PLinkParameters
Definition: ParameterGroup.h:53
Class representing a node of XML document.
Definition: rapidxml.h:539
Definition: BinaryPayload.h:38
std::shared_ptr< Parameter > PParameter
Definition: Parameter.h:55
std::shared_ptr< Variables > PVariables
Definition: ParameterGroup.h:54
std::map< std::string, PParameter > Parameters
Definition: Parameter.h:56
std::map< uint32_t, std::vector< PParameter > > Lists
Definition: ParameterGroup.h:55