From f0166f40dba9980d1151210187cd8255a6a1a732 Mon Sep 17 00:00:00 2001
From: Jojo-1000 <33495614+Jojo-1000@users.noreply.github.com>
Date: Sat, 27 Jun 2020 21:05:05 +0200
Subject: [PATCH] Rename classes to simplify names.
---
README.md | 20 ++++++++++----------
doc/markdown/Mainpage.md | 26 +++++++++++++-------------
include/hueplusplus/APIConfig.h | 75 ---------------------------------------------------------------------------
include/hueplusplus/Bridge.h | 263 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/BrightnessStrategy.h | 8 ++++----
include/hueplusplus/ColorHueStrategy.h | 24 ++++++++++++------------
include/hueplusplus/ColorTemperatureStrategy.h | 10 +++++-----
include/hueplusplus/ExtendedColorHueStrategy.h | 10 +++++-----
include/hueplusplus/ExtendedColorTemperatureStrategy.h | 6 +++---
include/hueplusplus/Hue.h | 262 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
include/hueplusplus/HueDeviceTypes.h | 14 +++++++-------
include/hueplusplus/HueLight.h | 666 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
include/hueplusplus/HueSensor.h | 97 -------------------------------------------------------------------------------------------------
include/hueplusplus/LibConfig.h | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/Light.h | 625 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/Sensor.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/SimpleBrightnessStrategy.h | 8 ++++----
include/hueplusplus/SimpleColorHueStrategy.h | 26 +++++++++++++-------------
include/hueplusplus/SimpleColorTemperatureStrategy.h | 12 ++++++------
include/hueplusplus/StateTransaction.h | 2 +-
src/Bridge.cpp | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/CMakeLists.txt | 6 +++---
src/ExtendedColorHueStrategy.cpp | 8 ++++----
src/ExtendedColorTemperatureStrategy.cpp | 6 +++---
src/Hue.cpp | 299 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
src/HueCommandAPI.cpp | 2 +-
src/HueDeviceTypes.cpp | 24 ++++++++++++------------
src/HueLight.cpp | 127 -------------------------------------------------------------------------------------------------------------------------------
src/HueSensor.cpp | 77 -----------------------------------------------------------------------------
src/Light.cpp | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/Sensor.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/SimpleBrightnessStrategy.cpp | 6 +++---
src/SimpleColorHueStrategy.cpp | 28 ++++++++++++++--------------
src/SimpleColorTemperatureStrategy.cpp | 10 +++++-----
src/UPnP.cpp | 2 +-
test/CMakeLists.txt | 6 +++---
test/mocks/mock_HueLight.h | 130 ----------------------------------------------------------------------------------------------------------------------------------
test/mocks/mock_Light.h | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/test_Bridge.cpp | 549 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/test_ExtendedColorHueStrategy.cpp | 6 +++---
test/test_ExtendedColorTemperatureStrategy.cpp | 4 ++--
test/test_Hue.cpp | 549 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test/test_HueCommandAPI.cpp | 2 +-
test/test_HueLight.cpp | 834 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test/test_HueLightFactory.cpp | 243 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test/test_Light.cpp | 834 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/test_LightFactory.cpp | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/test_Main.cpp | 2 +-
test/test_SimpleBrightnessStrategy.cpp | 8 ++++----
test/test_SimpleColorHueStrategy.cpp | 22 +++++++++++-----------
test/test_SimpleColorTemperatureStrategy.cpp | 10 +++++-----
test/test_UPnP.cpp | 2 +-
52 files changed, 3479 insertions(+), 3519 deletions(-)
delete mode 100644 include/hueplusplus/APIConfig.h
create mode 100644 include/hueplusplus/Bridge.h
delete mode 100644 include/hueplusplus/Hue.h
delete mode 100644 include/hueplusplus/HueLight.h
delete mode 100644 include/hueplusplus/HueSensor.h
create mode 100644 include/hueplusplus/LibConfig.h
create mode 100644 include/hueplusplus/Light.h
create mode 100644 include/hueplusplus/Sensor.h
create mode 100644 src/Bridge.cpp
delete mode 100644 src/Hue.cpp
delete mode 100644 src/HueLight.cpp
delete mode 100644 src/HueSensor.cpp
create mode 100644 src/Light.cpp
create mode 100644 src/Sensor.cpp
delete mode 100644 test/mocks/mock_HueLight.h
create mode 100644 test/mocks/mock_Light.h
create mode 100644 test/test_Bridge.cpp
delete mode 100644 test/test_Hue.cpp
delete mode 100644 test/test_HueLight.cpp
delete mode 100644 test/test_HueLightFactory.cpp
create mode 100644 test/test_Light.cpp
create mode 100644 test/test_LightFactory.cpp
diff --git a/README.md b/README.md
index 2b430e9..b7cd74b 100755
--- a/README.md
+++ b/README.md
@@ -23,14 +23,14 @@ A simple and easy to use library for Philips Hue Lights
## How to use
### Searching for Bridges
To start searching for a Hue Bridge you will need to choose an IHttpHandler and create one. The options are a "WinHttpHandler" (for windows) or a "LinHttpHandler" (for linux).
-Then create a HueFinder object with the handler.
+Then create a BridgeFinder object with the handler.
The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network.
After that you can call FindBridges(), which will return a vector containing the ip and mac address of all found Bridges.
```C++
// For windows use std::make_shared();
handler = std::make_shared();
-hueplusplus::HueFinder finder(handler);
-std::vector bridges = finder.FindBridges();
+hueplusplus::BridgeFinder finder(handler);
+std::vector bridges = finder.FindBridges();
if (bridges.empty())
{
std::cerr << "No bridges found\n";
@@ -44,32 +44,32 @@ If you have found the Bridge you were looking for, you can then move on with the
To get a new username from the Bridge (for now) you simply call GetBridge(bridges[\]),
where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges).
```C++
-hueplusplus::Hue bridge = finder.GetBridge(bridges[0]);
+hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]);
```
If you on the other hand already have a username you can add your bridge like so
```C++
finder.AddUsername(bridges[0].mac, "");
-hueplusplus::Hue bridge = finder.GetBridge(bridges[0]);
+hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]);
```
-If you do not want to use the HueFinder or you already know the ip and username of your bridge you have the option to create your own Hue object.
+If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object.
Here you will need to provide the ip address, the port number, a username and an HttpHandler
```C++
// For windows use std::make_shared();
handler = std::make_shared();
-hueplusplus::Hue bridge("192.168.2.102", 80, "", handler);
+hueplusplus::Bridge bridge("192.168.2.102", 80, "", handler);
```
### Controlling lights
If you have your Bridge all set up, you can now control its lights.
-For that create a new HueLight object and call lights().get(\) on your bridge object to get a reference to a specific light, where id
+For that create a new Light object and call lights().get(\) on your bridge object to get a reference to a specific light, where id
is the id of the light set internally by the Hue Bridge.
```C++
-hueplusplus::HueLight light1 = bridge.lights().get(1);
+hueplusplus::Light light1 = bridge.lights().get(1);
```
If you don't know the id of a specific light or want to get an overview over all lights that are controlled by your bridge,
you can get a vector containing them by calling getAll(). If no lights are found the vector will be empty.
```C++
-std::vector> lights = bridge.lights().getAll();
+std::vector> lights = bridge.lights().getAll();
```
If you now want to control a light, call a specific function of it.
```C++
diff --git a/doc/markdown/Mainpage.md b/doc/markdown/Mainpage.md
index 3907bb3..78d7aab 100644
--- a/doc/markdown/Mainpage.md
+++ b/doc/markdown/Mainpage.md
@@ -19,14 +19,14 @@ A simple and easy to use library for Philips Hue Lights.
### Searching for Bridges
To start searching for a Hue Bridge you will need to choose an IHttpHandler and create one. The options are a [WinHttpHandler](@ref hueplusplus::WinHttpHandler) (for windows) or a [LinHttpHandler](@ref hueplusplus::LinHttpHandler) (for linux or linux-like).
-Then create a [HueFinder](@ref hueplusplus::HueFinder) object with the handler.
+Then create a [BridgeFinder](@ref hueplusplus::BridgeFinder) object with the handler.
The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network.
-After that you can call [FindBridges()](@ref hueplusplus::HueFinder::FindBridges), which will return a vector containing the ip and mac address of all found Bridges.
+After that you can call [FindBridges()](@ref hueplusplus::BridgeFinder::FindBridges), which will return a vector containing the ip and mac address of all found Bridges.
```{.cpp}
// For windows use std::make_shared();
handler = std::make_shared();
-hueplusplus::HueFinder finder(handler);
-std::vector bridges = finder.FindBridges();
+hueplusplus::BridgeFinder finder(handler);
+std::vector bridges = finder.FindBridges();
if (bridges.empty())
{
std::cerr << "No bridges found\n";
@@ -37,35 +37,35 @@ if (bridges.empty())
### Authenticate Bridges
If you have found the Bridge you were looking for, you can then move on with the authentication process.
-To get a new username from the Bridge (for now) you simply call [GetBridge(bridges[\])](@ref hueplusplus::HueFinder::GetBridge),
+To get a new username from the Bridge (for now) you simply call [GetBridge(bridges[\])](@ref hueplusplus::BridgeFinder::GetBridge),
where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges). This requires the user to press the link button.
```{.cpp}
-hueplusplus::Hue bridge = finder.GetBridge(bridges[0]);
+hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]);
```
If you on the other hand already have a username you can add your bridge like so
```{.cpp}
finder.AddUsername(bridges[0].mac, "");
-hueplusplus::Hue bridge = finder.GetBridge(bridges[0]);
+hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]);
```
-If you do not want to use the HueFinder or you already know the ip and username of your bridge you have the option to create your own Hue object.
+If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object.
Here you will need to provide the ip address, the port number, a username and an HttpHandler
```{.cpp}
// For windows use std::make_shared();
handler = std::make_shared();
-hueplusplus::Hue bridge("192.168.2.102", 80, "", handler);
+hueplusplus::Bridge bridge("192.168.2.102", 80, "", handler);
```
### Controlling lights
If you have your Bridge all set up, you can now control its lights.
-For that create a new HueLight object and call [lights().get(\)](@ref hueplusplus::ResourceList::get) on your bridge object to get a reference to a specific light, where id
+For that create a new Light object and call [lights().get(\)](@ref hueplusplus::ResourceList::get) on your bridge object to get a reference to a specific light, where id
is the id of the light set internally by the Hue Bridge.
```{.cpp}
-hueplusplus::HueLight light1 = bridge.lights().get(1);
+hueplusplus::Light light1 = bridge.lights().get(1);
```
If you don't know the id of a specific light or want to get an overview over all lights that are controlled by your bridge,
you can get a vector containing them by calling [getAll()](@ref hueplusplus::ResourceList::getAll) on your bridge object. If no lights are found the vector will be empty.
```{.cpp}
-std::vector> lights = bridge.lights().getAll();
+std::vector> lights = bridge.lights().getAll();
```
If you now want to control a light, call a specific function of it.
```{.cpp}
@@ -79,7 +79,7 @@ lights.at(1).setColorHue(4562);
```
But keep in mind that some light types do not have all functions available. So you might call a
specific function, but nothing will happen. For that you might want to check what type
-of a light you are controlling. For that you can call the function [getColorType()](@ref hueplusplus::HueLight::getColorType()), which will return
+of a light you are controlling. For that you can call the function [getColorType()](@ref hueplusplus::Light::getColorType()), which will return
a ColorType.
```{.cpp}
hueplusplus::ColorType type1 = light1.getColorType();
diff --git a/include/hueplusplus/APIConfig.h b/include/hueplusplus/APIConfig.h
deleted file mode 100644
index 3b1b4fa..0000000
--- a/include/hueplusplus/APIConfig.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- \file APIConfig.h
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#ifndef INCLUDE_HUEPLUSPLUS_HUE_CONFIG_H
-#define INCLUDE_HUEPLUSPLUS_HUE_CONFIG_H
-
-#include
-
-namespace hueplusplus
-{
-//! \brief Configurable delays
-//!
-//! Used to set all delays to zero when running tests.
-class Config
-{
-private:
- using duration = std::chrono::steady_clock::duration;
-
-public:
- //! \brief Delay for advanced alerts before the actual alert
- duration getPreAlertDelay() const { return preAlertDelay; }
- //! \brief Delay for advanced alerts after the actual alert
- duration getPostAlertDelay() const { return postAlertDelay; }
-
- //! \brief Timeout for UPnP multicast request
- duration getUPnPTimeout() const { return upnpTimeout; }
-
- //! \brief Delay between bridge requests
- duration getBridgeRequestDelay() const { return bridgeRequestDelay; }
-
- //! \brief Timeout for Hue::requestUsername, waits until link button was pressed
- duration getRequestUsernameTimeout() const { return requestUsernameDelay; }
-
- //! \brief Interval in which username requests are attempted
- duration getRequestUsernameAttemptInterval() const { return requestUsernameAttemptInterval; }
-
- //! \brief Get config instance
- static Config& instance()
- {
- static Config c;
- return c;
- }
-protected:
- Config() = default;
-
-protected:
- duration preAlertDelay = std::chrono::milliseconds(120);
- duration postAlertDelay = std::chrono::milliseconds(1600);
- duration upnpTimeout = std::chrono::seconds(5);
- duration bridgeRequestDelay = std::chrono::milliseconds(100);
- duration requestUsernameDelay = std::chrono::seconds(35);
- duration requestUsernameAttemptInterval = std::chrono::seconds(1);
-};
-} // namespace hueplusplus
-
-#endif
diff --git a/include/hueplusplus/Bridge.h b/include/hueplusplus/Bridge.h
new file mode 100644
index 0000000..24deaa1
--- /dev/null
+++ b/include/hueplusplus/Bridge.h
@@ -0,0 +1,263 @@
+/**
+ \file Bridge.h
+ Copyright Notice\n
+ Copyright (C) 2017 Jan Rogall - developer\n
+ Copyright (C) 2017 Moritz Wirger - developer\n
+
+ This file is part of hueplusplus.
+
+ hueplusplus is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ hueplusplus is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with hueplusplus. If not, see .
+**/
+
+#ifndef INCLUDE_HUEPLUSPLUS_HUE_H
+#define INCLUDE_HUEPLUSPLUS_HUE_H
+
+#include