OpenZWave Library 1.6.1914
Loading...
Searching...
No Matches
ManufacturerSpecificDB.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// ManufacturerSpecificDB.h
4//
5// Interface for Handling Device Configuration Files.
6//
7// Copyright (c) 2016 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 _ManufacturerSpecificDB_H
29#define _ManufacturerSpecificDB_H
30
31#include <string>
32#include <map>
33#include <list>
34
35#include "Node.h"
36#include "platform/Ref.h"
37#include "Defs.h"
38
39namespace OpenZWave
40{
41 class Driver;
42 namespace Internal
43 {
44 namespace Platform
45 {
46 class Mutex;
47 }
48
50 {
51 public:
52 ProductDescriptor(uint16 _manufacturerId, uint16 _productType, uint16 _productId, string const& _productName, string const& _manufacturerName, string const& _configPath) :
53 m_manufacturerId(_manufacturerId), m_productType(_productType), m_productId(_productId), m_productName(_productName), m_manufacturerName(_manufacturerName), m_configPath(_configPath), m_configrevision(0)
54 {
55 }
57 {
58
59 }
60 int64 GetKey() const
61 {
62 return (GetKey(m_manufacturerId, m_productType, m_productId));
63 }
64
65 static int64 GetKey(uint16 _manufacturerId, uint16 _productType, uint16 _productId)
66 {
67 int64 key = (((int64) _manufacturerId) << 32) | (((int64) _productType) << 16) | (int64) _productId;
68 return key;
69 }
70
72 {
73 return m_manufacturerId;
74 }
75 string GetManufacturerName() const
76 {
77 return m_manufacturerName;
78 }
80 {
81 return m_productType;
82 }
84 {
85 return m_productId;
86 }
87 string GetProductName() const
88 {
89 return m_productName;
90 }
91 string GetConfigPath() const
92 {
93 return m_configPath;
94 }
96 {
97 m_configrevision = revision;
98 }
100 {
101 return m_configrevision;
102 }
103 private:
104 uint16 m_manufacturerId;
105 uint16 m_productType;
106 uint16 m_productId;
107 string m_productName;
108 string m_manufacturerName;
109 string m_configPath;
110 uint32 m_configrevision;
111 };
112
117 {
118 public:
119 static ManufacturerSpecificDB *Create();
121 {
122 return s_instance;
123 }
124 static void Destroy();
125
126 bool LoadProductXML();
127 void UnloadProductXML();
129 {
130 return m_revision;
131 }
133 {
134 return m_latestRevision;
135 }
136 ;
138 {
139 m_latestRevision = rev;
140 }
141 ;
142 void checkConfigFiles(Driver *);
143 void configDownloaded(Driver *, string file, uint8 node, bool success = true);
144 void mfsConfigDownloaded(Driver *, string file, bool success = true);
145 void fileDownloaded(Driver *, string file, bool success = true);
146 bool isReady();
147 bool updateConfigFile(Driver *, Node *);
148 bool updateMFSConfigFile(Driver *);
149 void checkInitialized();
150
151 private:
152 void LoadConfigFileRevision(ProductDescriptor *product);
155 void checkConfigFileContents(Driver *driver, string file);
156
157 Internal::Platform::Mutex* m_MfsMutex;
159 static ManufacturerSpecificDB *s_instance;
160 public:
161 std::shared_ptr<ProductDescriptor> getProduct(uint16 _manufacturerId, uint16 _productType, uint16 _productId);
162
163 private:
164 static map<uint16, string> s_manufacturerMap;
165 static map<int64, std::shared_ptr<ProductDescriptor> > s_productMap;
166 static bool s_bXmlLoaded;
167
168 list<string> m_downloading;
169 uint32 m_revision;
170 uint32 m_latestRevision;
171 bool m_initializing;
172
173 };
174
175 } // namespace Internal
176} // namespace OpenZWave
177
178#endif
unsigned short uint16
Definition Defs.h:88
unsigned int uint32
Definition Defs.h:91
#define OPENZWAVE_EXPORT
Definition Defs.h:52
unsigned char uint8
Definition Defs.h:85
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition Driver.h:85
The _ManufacturerSpecificDB class handles the Config File Database that we use to configure devices.
Definition ManufacturerSpecificDB.h:117
void setLatestRevision(uint32 rev)
Definition ManufacturerSpecificDB.h:137
uint32 getLatestRevision()
Definition ManufacturerSpecificDB.h:132
uint32 getRevision()
Definition ManufacturerSpecificDB.h:128
static ManufacturerSpecificDB * Get()
Definition ManufacturerSpecificDB.h:120
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition Mutex.h:45
Definition ManufacturerSpecificDB.h:50
ProductDescriptor(uint16 _manufacturerId, uint16 _productType, uint16 _productId, string const &_productName, string const &_manufacturerName, string const &_configPath)
Definition ManufacturerSpecificDB.h:52
static int64 GetKey(uint16 _manufacturerId, uint16 _productType, uint16 _productId)
Definition ManufacturerSpecificDB.h:65
~ProductDescriptor()
Definition ManufacturerSpecificDB.h:56
uint16 GetProductType() const
Definition ManufacturerSpecificDB.h:79
uint16 GetProductId() const
Definition ManufacturerSpecificDB.h:83
uint16 GetManufacturerId() const
Definition ManufacturerSpecificDB.h:71
string GetConfigPath() const
Definition ManufacturerSpecificDB.h:91
string GetProductName() const
Definition ManufacturerSpecificDB.h:87
int64 GetKey() const
Definition ManufacturerSpecificDB.h:60
uint32 GetConfigRevision() const
Definition ManufacturerSpecificDB.h:99
string GetManufacturerName() const
Definition ManufacturerSpecificDB.h:75
void SetConfigRevision(uint32 revision)
Definition ManufacturerSpecificDB.h:95
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition Node.h:82
Definition Bitfield.cpp:31