From 4a70df9516f62df3e832217be067dad0b2b68cf0 Mon Sep 17 00:00:00 2001 From: Moritz W Date: Wed, 23 May 2018 22:41:58 +0200 Subject: [PATCH] Initialize strategies in initializer list and pass strings by reference - initialize all strategies in Hue ctor - pass string of Hue::setIP by reference --- hueplusplus/Hue.cpp | 17 ++++++++--------- hueplusplus/include/Hue.h | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/hueplusplus/Hue.cpp b/hueplusplus/Hue.cpp index 853ff99..227728c 100644 --- a/hueplusplus/Hue.cpp +++ b/hueplusplus/Hue.cpp @@ -106,14 +106,13 @@ Hue::Hue(const std::string& ip, const std::string& username, std::shared_ptr(); - simpleColorHueStrategy = std::make_shared(); - extendedColorHueStrategy = std::make_shared(); - simpleColorTemperatureStrategy = std::make_shared(); - extendedColorTemperatureStrategy = std::make_shared(); -} + commands(ip, username, http_handler), + simpleBrightnessStrategy(std::make_shared()), + simpleColorHueStrategy(std::make_shared()), + extendedColorHueStrategy(std::make_shared()), + simpleColorTemperatureStrategy(std::make_shared()), + extendedColorTemperatureStrategy(std::make_shared()) +{} std::string Hue::getBridgeIP() { @@ -162,7 +161,7 @@ std::string Hue::getUsername() return username; } -void Hue::setIP(const std::string ip) +void Hue::setIP(const std::string& ip) { this->ip = ip; } diff --git a/hueplusplus/include/Hue.h b/hueplusplus/include/Hue.h index 4a02c1a..20b3598 100644 --- a/hueplusplus/include/Hue.h +++ b/hueplusplus/include/Hue.h @@ -121,7 +121,7 @@ public: //! \brief Function to set the ip address of this class representing a bridge //! //! \param ip String that specifies the ip in dotted decimal notation like "192.168.2.1" - void setIP(const std::string ip); + void setIP(const std::string& ip); //! \brief Function that returns a \ref Hue::HueLight of specified id //! -- libgit2 0.21.4