Commit 4a70df9516f62df3e832217be067dad0b2b68cf0
Committed by
Moritz Wirger
1 parent
c73b003c
Initialize strategies in initializer list and pass strings by reference
- initialize all strategies in Hue ctor - pass string of Hue::setIP by reference
Showing
2 changed files
with
9 additions
and
10 deletions
hueplusplus/Hue.cpp
| @@ -106,14 +106,13 @@ Hue::Hue(const std::string& ip, const std::string& username, std::shared_ptr<con | @@ -106,14 +106,13 @@ Hue::Hue(const std::string& ip, const std::string& username, std::shared_ptr<con | ||
| 106 | : ip(ip), | 106 | : ip(ip), |
| 107 | username(username), | 107 | username(username), |
| 108 | http_handler(std::move(handler)), | 108 | http_handler(std::move(handler)), |
| 109 | - commands(ip, username, http_handler) | ||
| 110 | -{ | ||
| 111 | - simpleBrightnessStrategy = std::make_shared<SimpleBrightnessStrategy>(); | ||
| 112 | - simpleColorHueStrategy = std::make_shared<SimpleColorHueStrategy>(); | ||
| 113 | - extendedColorHueStrategy = std::make_shared<ExtendedColorHueStrategy>(); | ||
| 114 | - simpleColorTemperatureStrategy = std::make_shared<SimpleColorTemperatureStrategy>(); | ||
| 115 | - extendedColorTemperatureStrategy = std::make_shared<ExtendedColorTemperatureStrategy>(); | ||
| 116 | -} | 109 | + commands(ip, username, http_handler), |
| 110 | + simpleBrightnessStrategy(std::make_shared<SimpleBrightnessStrategy>()), | ||
| 111 | + simpleColorHueStrategy(std::make_shared<SimpleColorHueStrategy>()), | ||
| 112 | + extendedColorHueStrategy(std::make_shared<ExtendedColorHueStrategy>()), | ||
| 113 | + simpleColorTemperatureStrategy(std::make_shared<SimpleColorTemperatureStrategy>()), | ||
| 114 | + extendedColorTemperatureStrategy(std::make_shared<ExtendedColorTemperatureStrategy>()) | ||
| 115 | +{} | ||
| 117 | 116 | ||
| 118 | std::string Hue::getBridgeIP() | 117 | std::string Hue::getBridgeIP() |
| 119 | { | 118 | { |
| @@ -162,7 +161,7 @@ std::string Hue::getUsername() | @@ -162,7 +161,7 @@ std::string Hue::getUsername() | ||
| 162 | return username; | 161 | return username; |
| 163 | } | 162 | } |
| 164 | 163 | ||
| 165 | -void Hue::setIP(const std::string ip) | 164 | +void Hue::setIP(const std::string& ip) |
| 166 | { | 165 | { |
| 167 | this->ip = ip; | 166 | this->ip = ip; |
| 168 | } | 167 | } |
hueplusplus/include/Hue.h
| @@ -121,7 +121,7 @@ public: | @@ -121,7 +121,7 @@ public: | ||
| 121 | //! \brief Function to set the ip address of this class representing a bridge | 121 | //! \brief Function to set the ip address of this class representing a bridge |
| 122 | //! | 122 | //! |
| 123 | //! \param ip String that specifies the ip in dotted decimal notation like "192.168.2.1" | 123 | //! \param ip String that specifies the ip in dotted decimal notation like "192.168.2.1" |
| 124 | - void setIP(const std::string ip); | 124 | + void setIP(const std::string& ip); |
| 125 | 125 | ||
| 126 | //! \brief Function that returns a \ref Hue::HueLight of specified id | 126 | //! \brief Function that returns a \ref Hue::HueLight of specified id |
| 127 | //! | 127 | //! |