diff --git a/projects/Yadoms.sln.DotSettings b/projects/Yadoms.sln.DotSettings index 3b37330fb7..03a3747450 100644 --- a/projects/Yadoms.sln.DotSettings +++ b/projects/Yadoms.sln.DotSettings @@ -39,6 +39,7 @@ True True True + True True True diff --git a/sources/plugins/PhilipsHue/Entities/Hsv.cpp b/sources/plugins/PhilipsHue/Entities/Hsv.cpp index ab3b36e8de..3ada7d6dc0 100644 --- a/sources/plugins/PhilipsHue/Entities/Hsv.cpp +++ b/sources/plugins/PhilipsHue/Entities/Hsv.cpp @@ -1,6 +1,8 @@ #include "Hsv.h" -CHsv::CHsv(unsigned long& hue, unsigned long& saturation, unsigned long& value) +CHsv::CHsv(const unsigned long& hue, + const unsigned long& saturation, + const unsigned long& value) : m_hue(hue), m_saturation(saturation), m_value(value) diff --git a/sources/plugins/PhilipsHue/Entities/Hsv.h b/sources/plugins/PhilipsHue/Entities/Hsv.h index 002177eb7f..17c3cfcec1 100644 --- a/sources/plugins/PhilipsHue/Entities/Hsv.h +++ b/sources/plugins/PhilipsHue/Entities/Hsv.h @@ -2,7 +2,9 @@ class CHsv { public: - CHsv(unsigned long& hue, unsigned long& saturation, unsigned long& value); + CHsv(const unsigned long& hue, + const unsigned long& saturation, + const unsigned long& value); virtual ~CHsv() = default; const unsigned long& getHue() const; @@ -14,4 +16,3 @@ class CHsv unsigned long m_saturation; unsigned long m_value; }; - diff --git a/sources/plugins/PhilipsHue/Entities/HueCapabilities.cpp b/sources/plugins/PhilipsHue/Entities/HueCapabilities.cpp index 10aecf47bb..b9ca3e5b1e 100644 --- a/sources/plugins/PhilipsHue/Entities/HueCapabilities.cpp +++ b/sources/plugins/PhilipsHue/Entities/HueCapabilities.cpp @@ -1,6 +1,8 @@ #include "HueCapabilities.h" -CHueCapabilities::CHueCapabilities(bool& certified, const CHueControl& control, const CHueStreaming& streaming) +CHueCapabilities::CHueCapabilities(const bool& certified, + const CHueControl& control, + const CHueStreaming& streaming) : m_certified(certified), m_control(control), m_streaming(streaming) @@ -22,7 +24,7 @@ const CHueControl& CHueCapabilities::getControl() const return m_control; } -void CHueCapabilities::setControl(CHueControl control) +void CHueCapabilities::setControl(const CHueControl& control) { m_control = control; } @@ -32,7 +34,7 @@ const CHueStreaming& CHueCapabilities::getStreaming() const return m_streaming; } -void CHueCapabilities::setStreaming(CHueStreaming& streaming) +void CHueCapabilities::setStreaming(const CHueStreaming& streaming) { m_streaming = streaming; } diff --git a/sources/plugins/PhilipsHue/Entities/HueCapabilities.h b/sources/plugins/PhilipsHue/Entities/HueCapabilities.h index b62bebd2d5..a5e23210a6 100644 --- a/sources/plugins/PhilipsHue/Entities/HueCapabilities.h +++ b/sources/plugins/PhilipsHue/Entities/HueCapabilities.h @@ -5,20 +5,21 @@ class CHueCapabilities { public: - CHueCapabilities() = default; - CHueCapabilities(bool& certified, const CHueControl& control, const CHueStreaming& streaming); + CHueCapabilities(const bool& certified, + const CHueControl& control, + const CHueStreaming& streaming); virtual ~CHueCapabilities() = default; const bool& isCertified() const; void setCertified(bool certified); const CHueControl& getControl() const; - void setControl(CHueControl control); + void setControl(const CHueControl& control); const CHueStreaming& getStreaming() const; - void setStreaming(CHueStreaming& streaming); + void setStreaming(const CHueStreaming& streaming); private: - bool m_certified; + bool m_certified = false; CHueControl m_control; CHueStreaming m_streaming; }; diff --git a/sources/plugins/PhilipsHue/Entities/HueControl.cpp b/sources/plugins/PhilipsHue/Entities/HueControl.cpp index b7089019c1..4c0b5768b9 100644 --- a/sources/plugins/PhilipsHue/Entities/HueControl.cpp +++ b/sources/plugins/PhilipsHue/Entities/HueControl.cpp @@ -1,6 +1,8 @@ #include "HueControl.h" -CHueControl::CHueControl(int minDimLevel, int maxLumen, const std::string& colorGamutType, +CHueControl::CHueControl(int minDimLevel, + int maxLumen, + const std::string& colorGamutType, const CHueColorGamut& colorGamut, const CHueCt& ct) : m_minDimLevel(minDimLevel), @@ -36,7 +38,7 @@ const std::string& CHueControl::getColorGamutType() const return m_colorGamutType; } -void CHueControl::setColorGamutType(std::string colorGamutType) +void CHueControl::setColorGamutType(const std::string& colorGamutType) { m_colorGamutType = colorGamutType; } @@ -46,7 +48,7 @@ const CHueColorGamut& CHueControl::getColorGamut() const return m_colorGamut; } -void CHueControl::setColorGamut(CHueColorGamut& colorGamut) +void CHueControl::setColorGamut(const CHueColorGamut& colorGamut) { m_colorGamut = colorGamut; } @@ -56,7 +58,7 @@ const CHueCt& CHueControl::getCt() const return m_ct; } -void CHueControl::setCt(CHueCt& ct) +void CHueControl::setCt(const CHueCt& ct) { m_ct = ct; } diff --git a/sources/plugins/PhilipsHue/Entities/HueControl.h b/sources/plugins/PhilipsHue/Entities/HueControl.h index 9ce1e3073d..b0ec6ec0fc 100644 --- a/sources/plugins/PhilipsHue/Entities/HueControl.h +++ b/sources/plugins/PhilipsHue/Entities/HueControl.h @@ -5,10 +5,12 @@ class CHueControl { public: - CHueControl() = default; - CHueControl(int minDimLevel, int maxLumen, const std::string& colorGamutType, const CHueColorGamut& colorGamut, + CHueControl(int minDimLevel, + int maxLumen, + const std::string& colorGamutType, + const CHueColorGamut& colorGamut, const CHueCt& ct); virtual ~CHueControl() = default; @@ -17,16 +19,15 @@ class CHueControl const int& getMaxLumen() const; void setMaxLumen(int maxLumen); const std::string& getColorGamutType() const; - void setColorGamutType(std::string colorGamutType); + void setColorGamutType(const std::string& colorGamutType); const CHueColorGamut& getColorGamut() const; - void setColorGamut(CHueColorGamut& colorGamut); + void setColorGamut(const CHueColorGamut& colorGamut); const CHueCt& getCt() const; - void setCt(CHueCt& ct); + void setCt(const CHueCt& ct); private: - - int m_minDimLevel; - int m_maxLumen; + int m_minDimLevel = 0; + int m_maxLumen = 0; std::string m_colorGamutType; CHueColorGamut m_colorGamut; CHueCt m_ct; diff --git a/sources/plugins/PhilipsHue/Entities/HueCt.cpp b/sources/plugins/PhilipsHue/Entities/HueCt.cpp index b2ee9bc93c..456edd1924 100644 --- a/sources/plugins/PhilipsHue/Entities/HueCt.cpp +++ b/sources/plugins/PhilipsHue/Entities/HueCt.cpp @@ -1,6 +1,6 @@ #include "HueCt.h" -CHueCt::CHueCt(int& min, int& max) +CHueCt::CHueCt(const int& min, const int& max) : m_min(min), m_max(max) { diff --git a/sources/plugins/PhilipsHue/Entities/HueCt.h b/sources/plugins/PhilipsHue/Entities/HueCt.h index e01db6ebce..892790fd45 100644 --- a/sources/plugins/PhilipsHue/Entities/HueCt.h +++ b/sources/plugins/PhilipsHue/Entities/HueCt.h @@ -3,16 +3,16 @@ class CHueCt { public: - CHueCt() = default; - CHueCt(int& min, int& max); + CHueCt(const int& min, const int& max); virtual ~CHueCt() = default; const int& getMin() const; void setMin(int min); const int& getMax() const; void setMax(int max); + private: - int m_min; - int m_max; + int m_min = 0; + int m_max = 0; }; diff --git a/sources/plugins/PhilipsHue/Entities/HueInformations.cpp b/sources/plugins/PhilipsHue/Entities/HueInformations.cpp index 2b467b5b09..12b254604b 100644 --- a/sources/plugins/PhilipsHue/Entities/HueInformations.cpp +++ b/sources/plugins/PhilipsHue/Entities/HueInformations.cpp @@ -4,8 +4,10 @@ CHueInformations::CHueInformations() { } -CHueInformations::CHueInformations(std::string& ip, std::string& friendlyName, std::string& modelName, - std::string& modelNumber) +CHueInformations::CHueInformations(const std::string& ip, + const std::string& friendlyName, + const std::string& modelName, + const std::string& modelNumber) : m_ip(ip), m_friendlyName(friendlyName), m_modelName(modelName), diff --git a/sources/plugins/PhilipsHue/Entities/HueInformations.h b/sources/plugins/PhilipsHue/Entities/HueInformations.h index d5ddbf54cd..794cc72ff8 100644 --- a/sources/plugins/PhilipsHue/Entities/HueInformations.h +++ b/sources/plugins/PhilipsHue/Entities/HueInformations.h @@ -1,9 +1,13 @@ #pragma once + class CHueInformations final { public: CHueInformations(); - CHueInformations(std::string& ip, std::string& friendlyName, std::string& modelName, std::string& modelNumber); + CHueInformations(const std::string& ip, + const std::string& friendlyName, + const std::string& modelName, + const std::string& modelNumber); virtual ~CHueInformations() = default; const std::string& getIp() const; @@ -15,10 +19,10 @@ class CHueInformations final void setFriendlyName(const std::string& friendlyName); void setModelName(const std::string& modelName); void setModelNumber(const std::string& modelNumber); + private: std::string m_ip; std::string m_friendlyName; std::string m_modelName; std::string m_modelNumber; }; - diff --git a/sources/plugins/PhilipsHue/Entities/HueStartUp.cpp b/sources/plugins/PhilipsHue/Entities/HueStartUp.cpp index 33914693d3..16774746be 100644 --- a/sources/plugins/PhilipsHue/Entities/HueStartUp.cpp +++ b/sources/plugins/PhilipsHue/Entities/HueStartUp.cpp @@ -1,7 +1,7 @@ #include "HueStartUp.h" -CHueStartUp::CHueStartUp(const std::string& mode, bool& configured) - : m_mode(mode), +CHueStartUp::CHueStartUp(std::string mode, const bool& configured) + : m_mode(std::move(mode)), m_configured(configured) { } diff --git a/sources/plugins/PhilipsHue/Entities/HueStartUp.h b/sources/plugins/PhilipsHue/Entities/HueStartUp.h index 1a7f9bd4cd..bad6679e9c 100644 --- a/sources/plugins/PhilipsHue/Entities/HueStartUp.h +++ b/sources/plugins/PhilipsHue/Entities/HueStartUp.h @@ -3,16 +3,16 @@ class CHueStartUp final { public: - CHueStartUp() = default; - CHueStartUp(const std::string& mode, bool& configured); - virtual ~CHueStartUp() = default; + CHueStartUp(std::string mode, const bool& configured); + ~CHueStartUp() = default; const std::string& getMode() const; void setMode(const std::string& mode); bool isConfigured() const; void setConfigured(bool configured); + private: std::string m_mode; - bool m_configured; + bool m_configured = false; }; diff --git a/sources/plugins/PhilipsHue/Entities/HueState.h b/sources/plugins/PhilipsHue/Entities/HueState.h index cc615abcfb..950dcd594b 100644 --- a/sources/plugins/PhilipsHue/Entities/HueState.h +++ b/sources/plugins/PhilipsHue/Entities/HueState.h @@ -33,16 +33,15 @@ class CHueState void setReachable(bool reachable); private: - - bool m_on; - int m_bri; - int m_hue; - int m_sat; + bool m_on = false; + int m_bri = 0; + int m_hue = 0; + int m_sat = 0; std::string m_effect; CXy m_xy; - int m_ct; + int m_ct = 0; std::string m_alert; std::string m_colorMode; std::string m_mode; - bool m_reachable; + bool m_reachable = false; }; diff --git a/sources/plugins/PhilipsHue/Entities/HueStreaming.cpp b/sources/plugins/PhilipsHue/Entities/HueStreaming.cpp index be1ea76b2a..d7a4596180 100644 --- a/sources/plugins/PhilipsHue/Entities/HueStreaming.cpp +++ b/sources/plugins/PhilipsHue/Entities/HueStreaming.cpp @@ -1,6 +1,6 @@ #include "HueStreaming.h" -CHueStreaming::CHueStreaming(bool& renderer, bool& proxy) +CHueStreaming::CHueStreaming(const bool& renderer, const bool& proxy) : m_renderer(renderer), m_proxy(proxy) { diff --git a/sources/plugins/PhilipsHue/Entities/HueStreaming.h b/sources/plugins/PhilipsHue/Entities/HueStreaming.h index 591ff81f19..c855eacc1a 100644 --- a/sources/plugins/PhilipsHue/Entities/HueStreaming.h +++ b/sources/plugins/PhilipsHue/Entities/HueStreaming.h @@ -3,9 +3,8 @@ class CHueStreaming { public: - CHueStreaming() = default; - CHueStreaming(bool& renderer, bool& proxy); + CHueStreaming(const bool& renderer, const bool& proxy); virtual ~CHueStreaming() = default; bool isRenderer() const; @@ -14,7 +13,6 @@ class CHueStreaming void setProxy(bool proxy); private: - - bool m_renderer; - bool m_proxy; + bool m_renderer = false; + bool m_proxy = false; }; diff --git a/sources/plugins/PhilipsHue/Entities/HueSwUpdate.cpp b/sources/plugins/PhilipsHue/Entities/HueSwUpdate.cpp index 1aa4e3c886..5c327c52d6 100644 --- a/sources/plugins/PhilipsHue/Entities/HueSwUpdate.cpp +++ b/sources/plugins/PhilipsHue/Entities/HueSwUpdate.cpp @@ -11,7 +11,7 @@ const std::string& CHueSwUpdate::getState() const return m_state; } -void CHueSwUpdate::setState(std::string state) +void CHueSwUpdate::setState(const std::string& state) { m_state = state; } @@ -21,7 +21,7 @@ const std::string& CHueSwUpdate::getLastInstall() const return m_lastInstall; } -void CHueSwUpdate::setLastInstall(std::string lastInstall) +void CHueSwUpdate::setLastInstall(const std::string& lastInstall) { m_lastInstall = lastInstall; } diff --git a/sources/plugins/PhilipsHue/Entities/HueSwUpdate.h b/sources/plugins/PhilipsHue/Entities/HueSwUpdate.h index 9bd10903bd..7cbc3df0ff 100644 --- a/sources/plugins/PhilipsHue/Entities/HueSwUpdate.h +++ b/sources/plugins/PhilipsHue/Entities/HueSwUpdate.h @@ -3,16 +3,16 @@ class CHueSwUpdate { public: - CHueSwUpdate() = default; CHueSwUpdate(const std::string& state, const std::string& lastInstall); virtual ~CHueSwUpdate() = default; const std::string& getState() const; - void setState(std::string state); + void setState(const std::string& state); const std::string& getLastInstall() const; - void setLastInstall(std::string lastInstall); + void setLastInstall(const std::string& lastInstall); + private : std::string m_state; std::string m_lastInstall; diff --git a/sources/plugins/PhilipsHue/Entities/Rgb.cpp b/sources/plugins/PhilipsHue/Entities/Rgb.cpp index 7be38202c7..bd6010ae2d 100644 --- a/sources/plugins/PhilipsHue/Entities/Rgb.cpp +++ b/sources/plugins/PhilipsHue/Entities/Rgb.cpp @@ -1,6 +1,6 @@ #include "Rgb.h" -CRgb::CRgb(unsigned long& r, unsigned long& g, unsigned long& b) +CRgb::CRgb(const unsigned long& r, const unsigned long& g, const unsigned long& b) : m_r(r), m_g(g), m_b(b) diff --git a/sources/plugins/PhilipsHue/Entities/Rgb.h b/sources/plugins/PhilipsHue/Entities/Rgb.h index eedd70a9c2..a7335dcad3 100644 --- a/sources/plugins/PhilipsHue/Entities/Rgb.h +++ b/sources/plugins/PhilipsHue/Entities/Rgb.h @@ -2,7 +2,7 @@ class CRgb { public: - CRgb(unsigned long& r, unsigned long& g, unsigned long& b); + CRgb(const unsigned long& r, const unsigned long& g, const unsigned long& b); virtual ~CRgb() = default; const unsigned long& getR() const; @@ -14,4 +14,3 @@ class CRgb unsigned long m_g; unsigned long m_b; }; - diff --git a/sources/plugins/PhilipsHue/Entities/Xy.cpp b/sources/plugins/PhilipsHue/Entities/Xy.cpp index b563f6b7f0..0532f35500 100644 --- a/sources/plugins/PhilipsHue/Entities/Xy.cpp +++ b/sources/plugins/PhilipsHue/Entities/Xy.cpp @@ -6,7 +6,7 @@ CXy::CXy() { } -CXy::CXy(float& x, float& y) +CXy::CXy(const float& x, const float& y) : m_x(x), m_y(y) { diff --git a/sources/plugins/PhilipsHue/Entities/Xy.h b/sources/plugins/PhilipsHue/Entities/Xy.h index 7afc6d8e3e..aa80463fa0 100644 --- a/sources/plugins/PhilipsHue/Entities/Xy.h +++ b/sources/plugins/PhilipsHue/Entities/Xy.h @@ -1,9 +1,10 @@ #pragma once + class CXy { public: CXy(); - CXy(float& x, float& y); + CXy(const float& x, const float& y); virtual ~CXy() = default; const float& getX() const; @@ -11,6 +12,7 @@ class CXy void setX(float x); void setY(float y); + private: float m_x; float m_y; diff --git a/sources/plugins/PhilipsHue/PhilipsHue.cpp b/sources/plugins/PhilipsHue/PhilipsHue.cpp index ef2d4cbec5..af99b101fd 100644 --- a/sources/plugins/PhilipsHue/PhilipsHue.cpp +++ b/sources/plugins/PhilipsHue/PhilipsHue.cpp @@ -127,7 +127,7 @@ void CPhilipsHue::doWork(boost::shared_ptr api) if (!extraQuery) { - extraQuery->sendError("error content"); + YADOMS_LOG(error) << "error content"; } else { diff --git a/sources/plugins/RfPlayer/RfPlayer.cpp b/sources/plugins/RfPlayer/RfPlayer.cpp index 800e74f8db..68628f09a1 100644 --- a/sources/plugins/RfPlayer/RfPlayer.cpp +++ b/sources/plugins/RfPlayer/RfPlayer.cpp @@ -121,7 +121,7 @@ void CRfPlayer::doWork(boost::shared_ptr api) } else { - extraQuery->sendError("invalid paramerter"); + YADOMS_LOG(error) << "invalid extra query"; } break; } diff --git a/sources/plugins/Rfxcom/Rfxcom.cpp b/sources/plugins/Rfxcom/Rfxcom.cpp index c943340f4c..40b6675518 100644 --- a/sources/plugins/Rfxcom/Rfxcom.cpp +++ b/sources/plugins/Rfxcom/Rfxcom.cpp @@ -134,7 +134,6 @@ void CRfxcom::doWork(boost::shared_ptr api) else { YADOMS_LOG(error) << "Invalid query"; - extraQuery->sendError("customLabels.extraquery.ErrorInternal"); } break; } diff --git a/sources/plugins/Rfxcom/rfxcomMessages/Cartelectronic.cpp b/sources/plugins/Rfxcom/rfxcomMessages/Cartelectronic.cpp index d921614ead..acde932483 100644 --- a/sources/plugins/Rfxcom/rfxcomMessages/Cartelectronic.cpp +++ b/sources/plugins/Rfxcom/rfxcomMessages/Cartelectronic.cpp @@ -43,7 +43,7 @@ namespace rfxcomMessages newKeywords.push_back(m_batteryLevel); // Remove obsolete keywords - for (const auto existingKeyword : existingKeywords) + for (const auto& existingKeyword : existingKeywords) { if (std::find_if(newKeywords.begin(), newKeywords.end(), @@ -55,7 +55,7 @@ namespace rfxcomMessages } // Create new keywords - for (const auto newKeyword : newKeywords) + for (const auto& newKeyword : newKeywords) { if (std::find_if(existingKeywords.begin(), existingKeywords.end(), diff --git a/sources/plugins/SomfySituo/SomfySituo.cpp b/sources/plugins/SomfySituo/SomfySituo.cpp index f2a3b1ed45..825330cfc8 100644 --- a/sources/plugins/SomfySituo/SomfySituo.cpp +++ b/sources/plugins/SomfySituo/SomfySituo.cpp @@ -8,23 +8,23 @@ #include DECLARE_ENUM_IMPLEMENTATION(EChannel, - ((Channel1)) - ((Channel2)) - ((Channel3)) - ((Channel4)) - ((Channel5)) + ((Channel1)) + ((Channel2)) + ((Channel3)) + ((Channel4)) + ((Channel5)) ); IMPLEMENT_PLUGIN(CSomfySituo) #define STX 0x02 #define ETX 0x03 -inline int ctoi(const char c) +inline int Ctoi(const char c) { return c - 48; } -inline char itoc(const int i) +inline char Itoc(const int i) { return static_cast(i) + 48; } @@ -43,7 +43,7 @@ enum const std::string CSomfySituo::DeviceName("SituoAdapter"); -const std::map CSomfySituo::m_somfyModels = {{"Situo1", 1}, {"Situo5", 5}}; +const std::map CSomfySituo::SomfyModels = {{"Situo1", 1}, {"Situo5", 5}}; CSomfySituo::CSomfySituo() : m_logger(boost::make_shared("trace")), @@ -70,7 +70,7 @@ void CSomfySituo::doWork(boost::shared_ptr api) m_configuration.initializeWith(api->getConfiguration()); // Create the buffer handler - m_ReceiveBufferHandler = CSomfySituoFactory::GetBufferHandler(api->getEventHandler(), + m_receiveBufferHandler = CSomfySituoFactory::GetBufferHandler(api->getEventHandler(), kEvtPortDataReceived, false); @@ -89,7 +89,7 @@ void CSomfySituo::doWork(boost::shared_ptr api) } } -void CSomfySituo::manageEvents(boost::shared_ptr api) +void CSomfySituo::manageEvents(const boost::shared_ptr& api) { // Wait for an event switch (api->getEventHandler().waitForEvents()) @@ -103,7 +103,7 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) case yApi::IYPluginApi::kEventDeviceCommand: { // Command received from Yadoms - auto command(api->getEventHandler().getEventData>()); + const auto command(api->getEventHandler().getEventData>()); YADOMS_LOG(information) << "Command received : " << yApi::IDeviceCommand::toString(command); if (boost::iequals(command->getKeyword(), m_curtain->getKeyword())) { @@ -120,7 +120,7 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) { // Configuration was updated api->setPluginState(yApi::historization::EPluginState::kCustom, "updateConfiguration"); - auto newConfigurationData = api->getEventHandler().getEventData>(); + const auto newConfigurationData = api->getEventHandler().getEventData>(); YADOMS_LOG(information) << "Update configuration..."; BOOST_ASSERT(!newConfigurationData->empty()); // newConfigurationData shouldn't be empty, or kEventUpdateConfiguration shouldn't be generated @@ -130,7 +130,7 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) newConfiguration.initializeWith(newConfigurationData); // If port has changed, destroy and recreate connection (if any) - auto needToReconnect = !connectionsAreEqual(m_configuration, newConfiguration) && !!m_port; + const auto needToReconnect = !connectionsAreEqual(m_configuration, newConfiguration) && !!m_port; if (needToReconnect) destroyConnection(); @@ -148,11 +148,11 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) case yApi::IYPluginApi::kBindingQuery: { // Yadoms ask for a binding query - auto request = api->getEventHandler().getEventData>(); + const auto request = api->getEventHandler().getEventData>(); if (request->getData().getQuery() == "channels") { std::vector allDevices = api->getAllDevices(); - boost::shared_ptr ev = shared::CDataContainer::make(); + const boost::shared_ptr ev = shared::CDataContainer::make(); for (std::string& str : api->getAllDevices()) { if (str.find(DeviceName) != std::string::npos) @@ -164,7 +164,7 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) else { // Receive an unsupported query (is your package.json synchronized with the code ?) - auto errorMessage = (boost::format("unknown query : %1%") % request->getData().getQuery()).str(); + const auto errorMessage = (boost::format("unknown query : %1%") % request->getData().getQuery()).str(); request->sendError(errorMessage); YADOMS_LOG(error) << errorMessage; } @@ -173,7 +173,7 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) case yApi::IYPluginApi::kEventExtraQuery: { // Command was received from Yadoms - auto extraQuery = api->getEventHandler().getEventData>(); + const auto extraQuery = api->getEventHandler().getEventData>(); if (extraQuery) { if (extraQuery->getData()->query() == "progChannel") @@ -202,13 +202,12 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) else { YADOMS_LOG(error) << "Invalid extra-query"; - extraQuery->sendError("invalid paramerter"); } break; } case kEvtPortConnection: { - auto notif = api->getEventHandler().getEventDatagetEventHandler().getEventData>(); if (notif && notif->isConnected()) @@ -224,7 +223,7 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) m_logger->logReceived(buffer); // Message are in ASCII format - std::string message(reinterpret_cast(buffer.begin()), buffer.size()); + const std::string message(reinterpret_cast(buffer.begin()), buffer.size()); YADOMS_LOG(information) << "buffer received from controller : " << message; processDataReceived(api, message); break; @@ -248,14 +247,14 @@ void CSomfySituo::manageEvents(boost::shared_ptr api) } } -void CSomfySituo::createConnection(boost::shared_ptr api) +void CSomfySituo::createConnection(const boost::shared_ptr& api) { api->setPluginState(yApi::historization::EPluginState::kCustom, "connecting"); // Create the port instance m_port = CSomfySituoFactory::constructPort(m_configuration, api->getEventHandler(), - m_ReceiveBufferHandler, + m_receiveBufferHandler, kEvtPortConnection); m_port->start(); } @@ -281,7 +280,7 @@ void CSomfySituo::send(const std::string& message, for (unsigned int i = 0; i < message.size(); i++) messageToSend.push_back(message[i]); messageToSend.push_back(ETX); // footer - shared::communication::CByteBuffer buffer(messageToSend); + const shared::communication::CByteBuffer buffer(messageToSend); send(buffer, needAnswer); } @@ -309,7 +308,7 @@ void CSomfySituo::onCommand(boost::shared_ptr api, YADOMS_LOG(information) << "Command not send (Controler is not ready) : " << command; // Get Device number - int channelToActivate = ctoi(device[device.length() - 1]); + const int channelToActivate = Ctoi(device[device.length() - 1]); // Managet he command switch (m_curtain->get()) @@ -328,7 +327,7 @@ void CSomfySituo::onCommand(boost::shared_ptr api, } } -void CSomfySituo::processConnectionEvent(boost::shared_ptr api) +void CSomfySituo::processConnectionEvent(const boost::shared_ptr& api) { YADOMS_LOG(information) << "Controler port opened"; @@ -350,7 +349,7 @@ void CSomfySituo::processConnectionEvent(boost::shared_ptr ap } } -void CSomfySituo::protocolErrorProcess(boost::shared_ptr api) +void CSomfySituo::protocolErrorProcess(const boost::shared_ptr& api) { if (m_protocolErrorCounter <= 3) { @@ -366,9 +365,8 @@ void CSomfySituo::protocolErrorProcess(boost::shared_ptr api) boost::posix_time::seconds(30)); } -void CSomfySituo::processUnConnectionEvent(boost::shared_ptr api, - boost::shared_ptr - notification) +void CSomfySituo::processUnConnectionEvent(const boost::shared_ptr& api, + const boost::shared_ptr& notification) { YADOMS_LOG(information) << "Controler connection was lost"; if (notification) @@ -426,13 +424,13 @@ void CSomfySituo::processDataReceived(boost::shared_ptr api, } else { - if (ctoi(message[1]) > 0) + if (Ctoi(message[1]) > 0) { - m_activeChannel = ctoi(message[1]); + m_activeChannel = Ctoi(message[1]); m_channelSleep = false; YADOMS_LOG(information) << "Active channel : " << m_activeChannel; } - else //the Led's is off. We don't care. + else //the LED is off. We don't care. { m_channelSleep = true; } @@ -447,7 +445,7 @@ void CSomfySituo::processDataReceived(boost::shared_ptr api, YADOMS_LOG(information) << "Configuration : " << &message[1]; break; } - case 'u': // get a ack of the command + case 'u': // get ack of the command case 'U': case 'd': case 'D': @@ -456,7 +454,7 @@ void CSomfySituo::processDataReceived(boost::shared_ptr api, case 'p': case 'P': { - //do nothing, it was just a ack; + //do nothing, it was just ack; break; } default: @@ -488,7 +486,7 @@ void CSomfySituo::processDataReceived(boost::shared_ptr api, void CSomfySituo::sendConfigCmd(ConfigSituo conf, int value) { std::ostringstream cmd; - cmd << 'C' << conf << value; + cmd << 'C' << static_cast(conf) << value; m_protocolErrorCounter = 0; send(cmd.str(), true); } @@ -575,13 +573,13 @@ void CSomfySituo::sendQuickProgCmd(int chan) send(cmd.str(), true); } -void CSomfySituo::processReceivedInformation(boost::shared_ptr api, +void CSomfySituo::processReceivedInformation(const boost::shared_ptr& api, const boost::tokenizer>& tokens) const { auto itToken = tokens.begin(); - auto model(*itToken); + const auto model(*itToken); ++itToken; - auto version(*itToken); + const auto version(*itToken); YADOMS_LOG(information) << "Controler Informations :"; YADOMS_LOG(information) << " model : " << &model[1]; @@ -591,16 +589,17 @@ void CSomfySituo::processReceivedInformation(boost::shared_ptr api, - const std::string& model, const std::string& version) const +void CSomfySituo::declareDevice(const boost::shared_ptr& api, + const std::string& model, + const std::string& version) const { int numberOfChannel = 0; // Declare device/keywords if necessary - for (std::map::const_iterator it = m_somfyModels.begin(); it != m_somfyModels.end(); ++it) - if (boost::iequals(it->first, model)) - numberOfChannel = it->second; + for (const auto& knownModel : SomfyModels) + if (boost::iequals(knownModel.first, model)) + numberOfChannel = knownModel.second; - auto deviceModel = model + std::string(" ") + version; + const auto deviceModel = model + std::string(" ") + version; if (numberOfChannel > 0) { for (int i = 1; i <= numberOfChannel; i++) diff --git a/sources/plugins/SomfySituo/SomfySituo.h b/sources/plugins/SomfySituo/SomfySituo.h index 34a12ddde9..5fe71f6e69 100644 --- a/sources/plugins/SomfySituo/SomfySituo.h +++ b/sources/plugins/SomfySituo/SomfySituo.h @@ -10,32 +10,31 @@ namespace yApi = shared::plugin::yPluginApi; DECLARE_ENUM_HEADER(EChannel, - ((Channel1)(1)) - ((Channel2)(2)) - ((Channel3)(3)) - ((Channel4)(4)) - ((Channel5)(5)) + ((Channel1)(1)) + ((Channel2)(2)) + ((Channel3)(3)) + ((Channel4)(4)) + ((Channel5)(5)) ); //-------------------------------------------------------------- /// \brief This plugin supports adapter for Somfy IO Situo Remote Controls //-------------------------------------------------------------- -class CSomfySituo : public plugin_cpp_api::IPlugin +class CSomfySituo final : public plugin_cpp_api::IPlugin { public: - typedef enum + enum class ConfigSituo : char { - Debug = 'D', - } ConfigSituo; + kDebug = 'D', + }; CSomfySituo(); - virtual ~CSomfySituo(); + ~CSomfySituo() override; void doWork(boost::shared_ptr api) override; protected: - - void manageEvents(boost::shared_ptr api); + void manageEvents(const boost::shared_ptr& api); void send(const std::string& message, bool needAnswer = false); @@ -46,30 +45,30 @@ class CSomfySituo : public plugin_cpp_api::IPlugin void onCommand(boost::shared_ptr api, const std::string& device, const std::string& command); - void processConnectionEvent(boost::shared_ptr api); + void processConnectionEvent(const boost::shared_ptr& api); - void processUnConnectionEvent(boost::shared_ptr api, - boost::shared_ptr notification + void processUnConnectionEvent(const boost::shared_ptr& api, + const boost::shared_ptr& notification = boost::shared_ptr()); void processDataReceived(boost::shared_ptr api, const std::string& message); - void createConnection(boost::shared_ptr api); + void createConnection(const boost::shared_ptr& api); void destroyConnection(); - void protocolErrorProcess(boost::shared_ptr api); + void protocolErrorProcess(const boost::shared_ptr& api); static bool connectionsAreEqual(const CSomfySituoConfiguration& conf1, const CSomfySituoConfiguration& conf2); - void processReceivedInformation(boost::shared_ptr api, - const boost::tokenizer>& tokens) const; + void processReceivedInformation(const boost::shared_ptr& api, + const boost::tokenizer>& tokens) const; - void declareDevice(boost::shared_ptr api, - const std::string& model, const std::string& version) const; + void declareDevice(const boost::shared_ptr& api, + const std::string& model, const std::string& version) const; //-------------------------------------------------------------- /// \brief Send command to the remote control adapter @@ -86,7 +85,6 @@ class CSomfySituo : public plugin_cpp_api::IPlugin void sendProgCmd(); void sendQuickProgCmd(int chan); - private: CSomfySituoConfiguration m_configuration; boost::shared_ptr m_port; @@ -100,8 +98,8 @@ class CSomfySituo : public plugin_cpp_api::IPlugin int m_activeChannel; bool m_channelSleep; boost::shared_ptr m_curtain; - boost::shared_ptr m_ReceiveBufferHandler; + boost::shared_ptr m_receiveBufferHandler; std::vector> m_keywords; - static const std::map m_somfyModels; + static const std::map SomfyModels; }; diff --git a/sources/scriptInterpreters/yPython27/ScriptFile.cpp b/sources/scriptInterpreters/yPython27/ScriptFile.cpp index 2e40d3519d..e530c08bd9 100644 --- a/sources/scriptInterpreters/yPython27/ScriptFile.cpp +++ b/sources/scriptInterpreters/yPython27/ScriptFile.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "ScriptFile.h" +#include #include