diff --git a/cpp/build/support.mk b/cpp/build/support.mk index 3ffd17e48c..13fe616d1c 100644 --- a/cpp/build/support.mk +++ b/cpp/build/support.mk @@ -81,6 +81,9 @@ endif ifeq ($(UNAME),Darwin) AR := libtool -static -o RANLIB := ranlib +CC := clang +CXX := clang++ +LD := clang++ else AR := $(CROSS_COMPILE)ar rc RANLIB := $(CROSS_COMPILE)ranlib diff --git a/cpp/src/Localization.cpp b/cpp/src/Localization.cpp index 13fcaba01d..a76e356aa7 100755 --- a/cpp/src/Localization.cpp +++ b/cpp/src/Localization.cpp @@ -43,9 +43,9 @@ namespace OpenZWave { Localization *Localization::m_instance = NULL; - std::map Localization::m_valueLocalizationMap; - std::map Localization::m_commandClassLocalizationMap; - std::map Localization::m_globalLabelLocalizationMap; + std::map > Localization::m_valueLocalizationMap; + std::map > Localization::m_commandClassLocalizationMap; + std::map > Localization::m_globalLabelLocalizationMap; std::string Localization::m_selectedLang = ""; uint32 Localization::m_revision = 0; @@ -318,6 +318,7 @@ namespace OpenZWave CCElement = CCElement->NextSiblingElement(); } Log::Write(LogLevel_Info, "Loaded %s With Revision %d", pDoc->GetUserData(), m_revision); + delete pDoc; } void Localization::ReadGlobalXMLLabel(const TiXmlElement *labelElement) @@ -334,7 +335,7 @@ namespace OpenZWave Language = labelElement->Attribute("lang"); if (m_globalLabelLocalizationMap.find(str) == m_globalLabelLocalizationMap.end()) { - m_globalLabelLocalizationMap[str] = new LabelLocalizationEntry(0); + m_globalLabelLocalizationMap[str] = std::shared_ptr(new LabelLocalizationEntry(0)); } else if (m_globalLabelLocalizationMap[str]->HasLabel(Language)) { @@ -362,7 +363,7 @@ namespace OpenZWave if (m_commandClassLocalizationMap.find(ccID) == m_commandClassLocalizationMap.end()) { - m_commandClassLocalizationMap[ccID] = new LabelLocalizationEntry(0); + m_commandClassLocalizationMap[ccID] = std::shared_ptr(new LabelLocalizationEntry(0)); } else if (m_commandClassLocalizationMap[ccID]->HasLabel(Language)) { @@ -434,7 +435,7 @@ namespace OpenZWave if (m_valueLocalizationMap.find(key) == m_valueLocalizationMap.end()) { - m_valueLocalizationMap[key] = new ValueLocalizationEntry(ccID, indexId, pos); + m_valueLocalizationMap[key] = std::shared_ptr (new ValueLocalizationEntry(ccID, indexId, pos)); } else if (m_valueLocalizationMap[key]->HasLabel(Language)) { @@ -472,7 +473,7 @@ namespace OpenZWave uint64 key = GetValueKey(node, ccID, indexId, pos); if (m_valueLocalizationMap.find(key) == m_valueLocalizationMap.end()) { - m_valueLocalizationMap[key] = new ValueLocalizationEntry(ccID, indexId, pos); + m_valueLocalizationMap[key] = std::shared_ptr (new ValueLocalizationEntry(ccID, indexId, pos)); } else if (m_valueLocalizationMap[key]->HasLabel(Language)) { @@ -572,7 +573,7 @@ namespace OpenZWave uint64 key = GetValueKey(_node, ccID, indexId, pos); if (m_valueLocalizationMap.find(key) == m_valueLocalizationMap.end()) { - m_valueLocalizationMap[key] = new ValueLocalizationEntry(ccID, indexId, pos); + m_valueLocalizationMap[key] = std::shared_ptr (new ValueLocalizationEntry(ccID, indexId, pos)); } else if (m_valueLocalizationMap[key]->HasHelp(lang)) { @@ -594,7 +595,7 @@ namespace OpenZWave uint64 key = GetValueKey(node, ccID, indexId, pos); if (m_valueLocalizationMap.find(key) == m_valueLocalizationMap.end()) { - m_valueLocalizationMap[key] = new ValueLocalizationEntry(ccID, indexId, pos); + m_valueLocalizationMap[key] = std::shared_ptr (new ValueLocalizationEntry(ccID, indexId, pos)); } else if (m_valueLocalizationMap[key]->HasLabel(lang)) { @@ -661,7 +662,7 @@ namespace OpenZWave uint64 key = GetValueKey(node, ccID, indexId, pos, unique); if (m_valueLocalizationMap.find(key) == m_valueLocalizationMap.end()) { - m_valueLocalizationMap[key] = new ValueLocalizationEntry(ccID, indexId, pos); + m_valueLocalizationMap[key] = std::shared_ptr (new ValueLocalizationEntry(ccID, indexId, pos)); } else if (m_valueLocalizationMap[key]->HasItemLabel(itemIndex, lang)) { @@ -699,7 +700,7 @@ namespace OpenZWave uint64 key = GetValueKey(node, ccID, indexId, pos, unique); if (m_valueLocalizationMap.find(key) == m_valueLocalizationMap.end()) { - m_valueLocalizationMap[key] = new ValueLocalizationEntry(ccID, indexId, pos); + m_valueLocalizationMap[key] = std::shared_ptr (new ValueLocalizationEntry(ccID, indexId, pos)); } else if (m_valueLocalizationMap[key]->HasItemHelp(itemIndex, lang)) { @@ -723,7 +724,7 @@ namespace OpenZWave { if (m_globalLabelLocalizationMap.find(index) == m_globalLabelLocalizationMap.end()) { - m_globalLabelLocalizationMap[index] = new LabelLocalizationEntry(0); + m_globalLabelLocalizationMap[index] = std::shared_ptr(new LabelLocalizationEntry(0)); } else if (m_globalLabelLocalizationMap[index]->HasLabel(lang)) { diff --git a/cpp/src/Localization.h b/cpp/src/Localization.h index be62f6f9e4..279f22ae03 100755 --- a/cpp/src/Localization.h +++ b/cpp/src/Localization.h @@ -136,9 +136,9 @@ namespace OpenZWave //----------------------------------------------------------------------------- private: static Localization* m_instance; - static map m_valueLocalizationMap; - static map m_commandClassLocalizationMap; - static map m_globalLabelLocalizationMap; + static map > m_valueLocalizationMap; + static map > m_commandClassLocalizationMap; + static map > m_globalLabelLocalizationMap; static string m_selectedLang; static uint32 m_revision; diff --git a/cpp/src/ManufacturerSpecificDB.cpp b/cpp/src/ManufacturerSpecificDB.cpp index 128a9b990e..bdc7d4417a 100644 --- a/cpp/src/ManufacturerSpecificDB.cpp +++ b/cpp/src/ManufacturerSpecificDB.cpp @@ -43,7 +43,7 @@ namespace OpenZWave ManufacturerSpecificDB *ManufacturerSpecificDB::s_instance = NULL; std::map ManufacturerSpecificDB::s_manufacturerMap; - std::map ManufacturerSpecificDB::s_productMap; + std::map > ManufacturerSpecificDB::s_productMap; bool ManufacturerSpecificDB::s_bXmlLoaded = false; ManufacturerSpecificDB *ManufacturerSpecificDB::Create() @@ -235,14 +235,14 @@ namespace OpenZWave ProductDescriptor* product = new ProductDescriptor(manufacturerId, productType, productId, productName, s_manufacturerMap[manufacturerId], dconfigPath); if (s_productMap[product->GetKey()] != NULL) { - ProductDescriptor *c = s_productMap[product->GetKey()]; + std::shared_ptr c = s_productMap[product->GetKey()]; Log::Write(LogLevel_Info, "Product name collision: %s type %x id %x manufacturerid %x, collides with %s, type %x id %x manufacturerid %x", productName.c_str(), productType, productId, manufacturerId, c->GetProductName().c_str(), c->GetProductType(), c->GetProductId(), c->GetManufacturerId()); delete product; } else { LoadConfigFileRevision(product); - s_productMap[product->GetKey()] = product; + s_productMap[product->GetKey()] = std::shared_ptr(product); } } @@ -269,7 +269,7 @@ namespace OpenZWave LockGuard LG(m_MfsMutex); if (s_bXmlLoaded) { - map::iterator pit = s_productMap.begin(); + map >::iterator pit = s_productMap.begin(); while (!s_productMap.empty()) { pit->second->Release(); @@ -297,10 +297,10 @@ namespace OpenZWave string configPath; Options::Get()->GetOptionAsString("ConfigPath", &configPath); - map::iterator pit; + map >::iterator pit; for (pit = s_productMap.begin(); pit != s_productMap.end(); pit++) { - ProductDescriptor *c = pit->second; + std::shared_ptr c = pit->second; if (c->GetConfigPath().size() > 0) { string path = configPath + c->GetConfigPath(); @@ -396,7 +396,7 @@ namespace OpenZWave } } - ProductDescriptor *ManufacturerSpecificDB::getProduct(uint16 _manufacturerId, uint16 _productType, uint16 _productId) + std::shared_ptr ManufacturerSpecificDB::getProduct(uint16 _manufacturerId, uint16 _productType, uint16 _productId) { if (!s_bXmlLoaded) @@ -407,7 +407,7 @@ namespace OpenZWave if (mit != s_manufacturerMap.end()) { // Get the product - map::iterator pit = s_productMap.find(ProductDescriptor::GetKey(_manufacturerId, _productType, _productId)); + map >::iterator pit = s_productMap.find(ProductDescriptor::GetKey(_manufacturerId, _productType, _productId)); if (pit != s_productMap.end()) { return pit->second; diff --git a/cpp/src/ManufacturerSpecificDB.h b/cpp/src/ManufacturerSpecificDB.h index 4d22d47a1e..aca8c50e89 100644 --- a/cpp/src/ManufacturerSpecificDB.h +++ b/cpp/src/ManufacturerSpecificDB.h @@ -156,11 +156,11 @@ namespace OpenZWave static ManufacturerSpecificDB *s_instance; public: - ProductDescriptor *getProduct(uint16 _manufacturerId, uint16 _productType, uint16 _productId); + std::shared_ptr getProduct(uint16 _manufacturerId, uint16 _productType, uint16 _productId); private: static map s_manufacturerMap; - static map s_productMap; + static map > s_productMap; static bool s_bXmlLoaded; list m_downloading; diff --git a/cpp/src/Node.cpp b/cpp/src/Node.cpp index 50e48b233e..2fe5fe3795 100644 --- a/cpp/src/Node.cpp +++ b/cpp/src/Node.cpp @@ -3569,7 +3569,7 @@ bool Node::IsNodeReset() // // Assign a ProductDetails class to this node //----------------------------------------------------------------------------- -void Node::SetProductDetails(Internal::ProductDescriptor *product) +void Node::SetProductDetails(std::shared_ptr product) { /* if there is a ProductDescriptor already assigned, remove the reference */ if (m_Product) diff --git a/cpp/src/Node.h b/cpp/src/Node.h index 186ac81947..6d39aea9dd 100644 --- a/cpp/src/Node.h +++ b/cpp/src/Node.h @@ -563,7 +563,7 @@ namespace OpenZWave // Configuration Revision Related Classes //----------------------------------------------------------------------------- public: - void SetProductDetails(Internal::ProductDescriptor *product); + void SetProductDetails(std::shared_ptr product); /** Get a path to the config file for this device * * @return a path relative to the config directory for the config file. returns a empty string if a config file is not present. @@ -618,7 +618,7 @@ namespace OpenZWave private: - Internal::ProductDescriptor *m_Product; + std::shared_ptr m_Product; uint32 m_fileConfigRevision; uint32 m_loadedConfigRevision; diff --git a/cpp/src/NotificationCCTypes.cpp b/cpp/src/NotificationCCTypes.cpp index d67b544b00..94c9807bef 100755 --- a/cpp/src/NotificationCCTypes.cpp +++ b/cpp/src/NotificationCCTypes.cpp @@ -39,7 +39,7 @@ namespace OpenZWave { NotificationCCTypes *NotificationCCTypes::m_instance = NULL; - std::map NotificationCCTypes::Notifications; + std::map > NotificationCCTypes::Notifications; uint32 NotificationCCTypes::m_revision(0); NotificationCCTypes::NotificationCCTypes() @@ -232,7 +232,7 @@ namespace OpenZWave aep->name = str; trim(aep->name); if (ne->EventParams.find(aep->id) == ne->EventParams.end()) - ne->EventParams[aep->id] = aep; + ne->EventParams[aep->id] = std::shared_ptr(aep); else { Log::Write(LogLevel_Warning, "NotificationCCTypes::ReadXML: Error in %s - A AlarmEventParam with id %d already exists. Skipping ", nextElement->GetDocument()->GetUserData(), aep->id); @@ -242,7 +242,7 @@ namespace OpenZWave nextElement = nextElement->NextSiblingElement(); } if (nt->Events.find(ne->id) == nt->Events.end()) - nt->Events[ne->id] = ne; + nt->Events[ne->id] = std::shared_ptr(ne); else { Log::Write(LogLevel_Warning, "NotificationCCTypes::ReadXML: Error in %s - A AlarmEventElement with id %d already exists. Skipping ", AlarmEventElement->GetDocument()->GetUserData(), ne->id); @@ -252,7 +252,7 @@ namespace OpenZWave AlarmEventElement = AlarmEventElement->NextSiblingElement(); } if (Notifications.find(nt->id) == Notifications.end()) - Notifications[nt->id] = nt; + Notifications[nt->id] = std::shared_ptr(nt); else { Log::Write(LogLevel_Warning, "NotificationCCTypes::ReadXML: Error in %s - A AlarmTypeElement with id %d already exists. Skipping ", AlarmTypeElement->GetDocument()->GetUserData(), nt->id); @@ -282,7 +282,7 @@ namespace OpenZWave } exit(0); #endif - + delete pDoc; } std::string NotificationCCTypes::GetEventParamNames(NotificationEventParamTypes type) @@ -323,7 +323,7 @@ namespace OpenZWave std::string NotificationCCTypes::GetEventForAlarmType(uint32 type, uint32 event) { - if (const NotificationCCTypes::NotificationEvents *ne = NotificationCCTypes::GetAlarmNotificationEvents(type, event)) + if (const std::shared_ptr ne = NotificationCCTypes::GetAlarmNotificationEvents(type, event)) { return ne->name; } @@ -331,7 +331,7 @@ namespace OpenZWave return "Unknown"; } - const NotificationCCTypes::NotificationTypes* NotificationCCTypes::GetAlarmNotificationTypes(uint32 type) + const std::shared_ptr NotificationCCTypes::GetAlarmNotificationTypes(uint32 type) { if (Notifications.find(type) != Notifications.end()) { @@ -344,9 +344,9 @@ namespace OpenZWave return NULL; } - const NotificationCCTypes::NotificationEvents* NotificationCCTypes::GetAlarmNotificationEvents(uint32 type, uint32 event) + const std::shared_ptr NotificationCCTypes::GetAlarmNotificationEvents(uint32 type, uint32 event) { - if (const NotificationCCTypes::NotificationTypes *nt = GetAlarmNotificationTypes(type)) + if (const std::shared_ptr nt = GetAlarmNotificationTypes(type)) { if (nt->Events.find(event) != nt->Events.end()) { @@ -357,9 +357,9 @@ namespace OpenZWave return NULL; } - const std::map NotificationCCTypes::GetAlarmNotificationEventParams(uint32 type, uint32 event) + const std::map > NotificationCCTypes::GetAlarmNotificationEventParams(uint32 type, uint32 event) { - if (const NotificationCCTypes::NotificationTypes *nt = GetAlarmNotificationTypes(type)) + if (const std::shared_ptr nt = GetAlarmNotificationTypes(type)) { if (nt->Events.find(event) != nt->Events.end()) { @@ -367,7 +367,7 @@ namespace OpenZWave } Log::Write(LogLevel_Warning, "NotificationCCTypes::GetAlarmNotificationEventParams - Unknown Alarm Event %d for Alarm Type %s (%d)", event, GetAlarmType(type).c_str(), type); } - return std::map(); + return std::map >(); } bool NotificationCCTypes::Create() diff --git a/cpp/src/NotificationCCTypes.h b/cpp/src/NotificationCCTypes.h index 6af9783cb8..5df7874c24 100755 --- a/cpp/src/NotificationCCTypes.h +++ b/cpp/src/NotificationCCTypes.h @@ -66,14 +66,14 @@ namespace OpenZWave public: uint32 id; string name; - std::map EventParams; + std::map > EventParams; }; class NotificationTypes { public: uint32 id; string name; - std::map Events; + std::map > Events; }; //----------------------------------------------------------------------------- @@ -89,16 +89,16 @@ namespace OpenZWave static string GetEventParamNames(NotificationEventParamTypes); string GetAlarmType(uint32); string GetEventForAlarmType(uint32, uint32); - const NotificationTypes *GetAlarmNotificationTypes(uint32); - const NotificationEvents *GetAlarmNotificationEvents(uint32, uint32); - const std::map GetAlarmNotificationEventParams(uint32, uint32); + const std::shared_ptr GetAlarmNotificationTypes(uint32); + const std::shared_ptr GetAlarmNotificationEvents(uint32, uint32); + const std::map> GetAlarmNotificationEventParams(uint32, uint32); //----------------------------------------------------------------------------- // Instance Functions //----------------------------------------------------------------------------- private: static NotificationCCTypes* m_instance; - static std::map Notifications; + static std::map > Notifications; static uint32 m_revision; }; } // namespace Internal diff --git a/cpp/src/SensorMultiLevelCCTypes.cpp b/cpp/src/SensorMultiLevelCCTypes.cpp index d057bbedbd..b533ca60cc 100755 --- a/cpp/src/SensorMultiLevelCCTypes.cpp +++ b/cpp/src/SensorMultiLevelCCTypes.cpp @@ -39,7 +39,7 @@ namespace OpenZWave { SensorMultiLevelCCTypes *SensorMultiLevelCCTypes::m_instance = NULL; - std::map SensorMultiLevelCCTypes::SensorTypes; + std::map > SensorMultiLevelCCTypes::SensorTypes; uint32 SensorMultiLevelCCTypes::m_revision(0); SensorMultiLevelCCTypes::SensorMultiLevelCCTypes() @@ -141,7 +141,7 @@ namespace OpenZWave } if (st->allSensorScales.find(ss->id) == st->allSensorScales.end()) - st->allSensorScales[ss->id] = ss; + st->allSensorScales[ss->id] = std::shared_ptr(ss); else { Log::Write(LogLevel_Warning, "SensorMultiLevelCCTypes::ReadXML: Error in %s at line %d - A SensorScale with id %d already exists. Skipping ", SensorScaleElement->GetDocument()->GetUserData(), SensorScaleElement->Row(), ss->id); @@ -151,7 +151,7 @@ namespace OpenZWave SensorScaleElement = SensorScaleElement->NextSiblingElement(); } if (SensorTypes.find(st->id) == SensorTypes.end()) - SensorTypes[st->id] = st; + SensorTypes[st->id] = std::shared_ptr(st); else { Log::Write(LogLevel_Warning, "SensorMultiLevelCCTypes::ReadXML: Error in %s at line %d - A SensorTypeElement with id %d already exists. Skipping ", SensorTypeElement->GetDocument()->GetUserData(), SensorTypeElement->Row(), st->id); @@ -173,7 +173,7 @@ namespace OpenZWave } exit(0); #endif - + delete pDoc; } std::string SensorMultiLevelCCTypes::GetSensorName(uint32 type) diff --git a/cpp/src/SensorMultiLevelCCTypes.h b/cpp/src/SensorMultiLevelCCTypes.h index ff22cef2c4..3e4bafe938 100755 --- a/cpp/src/SensorMultiLevelCCTypes.h +++ b/cpp/src/SensorMultiLevelCCTypes.h @@ -50,7 +50,7 @@ namespace OpenZWave string name; string unit; }; - typedef std::map SensorScales; + typedef std::map > SensorScales; class SensorMultiLevelTypes { public: @@ -79,7 +79,7 @@ namespace OpenZWave //----------------------------------------------------------------------------- private: static SensorMultiLevelCCTypes* m_instance; - static std::map SensorTypes; + static std::map > SensorTypes; static uint32 m_revision; }; } // namespace Internal diff --git a/cpp/src/command_classes/Alarm.cpp b/cpp/src/command_classes/Alarm.cpp index 0d846d75e6..1cd43dde5e 100644 --- a/cpp/src/command_classes/Alarm.cpp +++ b/cpp/src/command_classes/Alarm.cpp @@ -254,10 +254,10 @@ namespace OpenZWave /* do any Event Params that are sent over */ if (EventParamLength > 0) { - const std::map nep = NotificationCCTypes::Get()->GetAlarmNotificationEventParams(NotificationType, NotificationEvent); + const std::map > nep = NotificationCCTypes::Get()->GetAlarmNotificationEventParams(NotificationType, NotificationEvent); if (nep.size() > 0) { - for (std::map::const_iterator it = nep.begin(); it != nep.end(); it++) + for (std::map >::const_iterator it = nep.begin(); it != nep.end(); it++) { switch (it->second->type) { @@ -473,9 +473,9 @@ namespace OpenZWave { /* EventSupported is only compatible in Version 3 and above */ vector _items; - if (const NotificationCCTypes::NotificationTypes *nt = NotificationCCTypes::Get()->GetAlarmNotificationTypes(index)) + if (const std::shared_ptr nt = NotificationCCTypes::Get()->GetAlarmNotificationTypes(index)) { - for (std::map::const_iterator it = nt->Events.begin(); it != nt->Events.end(); it++) + for (std::map >::const_iterator it = nt->Events.begin(); it != nt->Events.end(); it++) { /* Create it */ SetupEvents(index, it->first, &_items, _instance); @@ -547,7 +547,7 @@ namespace OpenZWave } void Alarm::SetupEvents(uint32 type, uint32 index, vector *_items, uint32 const _instance) { - if (const NotificationCCTypes::NotificationEvents *ne = NotificationCCTypes::Get()->GetAlarmNotificationEvents(type, index)) + if (const std::shared_ptr ne = NotificationCCTypes::Get()->GetAlarmNotificationEvents(type, index)) { Log::Write(LogLevel_Info, GetNodeId(), "\tEvent Type %d: %s ", ne->id, ne->name.c_str()); Internal::VC::ValueList::Item item; @@ -557,7 +557,7 @@ namespace OpenZWave /* If there are Params - Lets create the correct types now */ if (Node* node = GetNodeUnsafe()) { - for (std::map::const_iterator it = ne->EventParams.begin(); it != ne->EventParams.end(); it++) + for (std::map >::const_iterator it = ne->EventParams.begin(); it != ne->EventParams.end(); it++) { switch (it->second->type) { diff --git a/cpp/src/command_classes/ManufacturerSpecific.cpp b/cpp/src/command_classes/ManufacturerSpecific.cpp index b122828bf1..e3117bb16a 100644 --- a/cpp/src/command_classes/ManufacturerSpecific.cpp +++ b/cpp/src/command_classes/ManufacturerSpecific.cpp @@ -156,7 +156,7 @@ namespace OpenZWave { string configPath = ""; - Internal::ProductDescriptor *product = GetDriver()->GetManufacturerSpecificDB()->getProduct(manufacturerId, productType, productId); + std::shared_ptr product = GetDriver()->GetManufacturerSpecificDB()->getProduct(manufacturerId, productType, productId); Node *node = GetNodeUnsafe(); if (!product) diff --git a/dist/openzwave.spec b/dist/openzwave.spec index e6a8ff686e..ceac53c95e 100644 --- a/dist/openzwave.spec +++ b/dist/openzwave.spec @@ -3,7 +3,7 @@ %endif Name: openzwave -Version: 1.6.768 +Version: 1.6.770 Release: 1.0%{?dist} Summary: Sample Executables for OpenZWave URL: http://www.openzwave.net @@ -135,7 +135,7 @@ getent group zwave >/dev/null || groupadd -f -r zwave %changelog -* Wed May 08 2019 Justin Hammond - 1.6.768 +* Wed May 08 2019 Justin Hammond - 1.6.770 - Update to new release of OpenZwave - 1.6 * Fri Feb 01 2019 Fedora Release Engineering - 1.5.0-0.20180624git1e36dcc.0