OpenZWave Library  1.6.896
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 
39 namespace 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  }
95  void SetConfigRevision(uint32 revision)
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  bool isReady();
146  bool updateConfigFile(Driver *, Node *);
147  bool updateMFSConfigFile(Driver *);
148  void checkInitialized();
149 
150  private:
151  void LoadConfigFileRevision(ProductDescriptor *product);
154 
155  Internal::Platform::Mutex* m_MfsMutex;
157  static ManufacturerSpecificDB *s_instance;
158  public:
159  std::shared_ptr<ProductDescriptor> getProduct(uint16 _manufacturerId, uint16 _productType, uint16 _productId);
160 
161  private:
162  static map<uint16, string> s_manufacturerMap;
163  static map<int64, std::shared_ptr<ProductDescriptor> > s_productMap;
164  static bool s_bXmlLoaded;
165 
166  list<string> m_downloading;
167  uint32 m_revision;
168  uint32 m_latestRevision;
169  bool m_initializing;
170 
171  };
172 
173  } // namespace Internal
174 } // namespace OpenZWave
175 
176 #endif
uint16 GetProductId() const
Definition: ManufacturerSpecificDB.h:83
uint32 getLatestRevision()
Definition: ManufacturerSpecificDB.h:132
Definition: Bitfield.cpp:30
#define OPENZWAVE_EXPORT
Definition: Defs.h:51
Definition: ManufacturerSpecificDB.h:49
unsigned short uint16
Definition: Defs.h:89
string GetManufacturerName() const
Definition: ManufacturerSpecificDB.h:75
void SetConfigRevision(uint32 revision)
Definition: ManufacturerSpecificDB.h:95
~ProductDescriptor()
Definition: ManufacturerSpecificDB.h:56
string GetProductName() const
Definition: ManufacturerSpecificDB.h:87
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:81
static ManufacturerSpecificDB * Get()
Definition: ManufacturerSpecificDB.h:120
uint16 GetManufacturerId() const
Definition: ManufacturerSpecificDB.h:71
uint16 GetProductType() const
Definition: ManufacturerSpecificDB.h:79
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:84
unsigned int uint32
Definition: Defs.h:92
uint32 getRevision()
Definition: ManufacturerSpecificDB.h:128
void setLatestRevision(uint32 rev)
Definition: ManufacturerSpecificDB.h:137
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:44
static int64 GetKey(uint16 _manufacturerId, uint16 _productType, uint16 _productId)
Definition: ManufacturerSpecificDB.h:65
int64 GetKey() const
Definition: ManufacturerSpecificDB.h:60
ProductDescriptor(uint16 _manufacturerId, uint16 _productType, uint16 _productId, string const &_productName, string const &_manufacturerName, string const &_configPath)
Definition: ManufacturerSpecificDB.h:52
uint32 GetConfigRevision() const
Definition: ManufacturerSpecificDB.h:99
string GetConfigPath() const
Definition: ManufacturerSpecificDB.h:91
The _ManufacturerSpecificDB class handles the Config File Database that we use to configure devices...
Definition: ManufacturerSpecificDB.h:116
unsigned char uint8
Definition: Defs.h:86