diff --git a/extras/test/CMakeLists.txt b/extras/test/CMakeLists.txt index dfe322324..1cebda19a 100644 --- a/extras/test/CMakeLists.txt +++ b/extras/test/CMakeLists.txt @@ -95,6 +95,7 @@ set(TEST_UTIL_SRCS set(TEST_DUT_SRCS ../../src/property/Property.cpp + ../../src/property/types/PropertyPrimitive.cpp ../../src/property/PropertyContainer.cpp ../../src/cbor/CBORDecoder.cpp ../../src/cbor/CBOREncoder.cpp diff --git a/extras/test/src/test_CloudFloat.cpp b/extras/test/src/test_CloudFloat.cpp index 7f6437c40..7af0a9d32 100644 --- a/extras/test/src/test_CloudFloat.cpp +++ b/extras/test/src/test_CloudFloat.cpp @@ -10,7 +10,7 @@ #include -#include +#include /************************************************************************************** TEST CODE diff --git a/extras/test/src/test_addPropertyReal.cpp b/extras/test/src/test_addPropertyReal.cpp index 27f647da5..8c5959104 100644 --- a/extras/test/src/test_addPropertyReal.cpp +++ b/extras/test/src/test_addPropertyReal.cpp @@ -10,11 +10,6 @@ #include -#include -#include -#include -#include - /************************************************************************************** TEST CODE **************************************************************************************/ diff --git a/extras/test/src/test_decode.cpp b/extras/test/src/test_decode.cpp index 63306af87..72a7d495f 100644 --- a/extras/test/src/test_decode.cpp +++ b/extras/test/src/test_decode.cpp @@ -19,13 +19,7 @@ #include "types/CloudWrapperInt.h" #include "types/CloudWrapperString.h" #include "types/automation/CloudColoredLight.h" -#include "types/automation/CloudContactSensor.h" #include "types/automation/CloudDimmedLight.h" -#include "types/automation/CloudLight.h" -#include "types/automation/CloudMotionSensor.h" -#include "types/automation/CloudSmartPlug.h" -#include "types/automation/CloudSwitch.h" -#include "types/automation/CloudTemperatureSensor.h" #include "types/automation/CloudTelevision.h" using namespace Catch; diff --git a/src/property/PropertyContainer.h b/src/property/PropertyContainer.h index 9dc3c86cd..4ec590af1 100644 --- a/src/property/PropertyContainer.h +++ b/src/property/PropertyContainer.h @@ -30,10 +30,8 @@ #undef min #include -#include "types/CloudBool.h" -#include "types/CloudFloat.h" -#include "types/CloudInt.h" -#include "types/CloudUnsignedInt.h" +#include "types/PropertyPrimitive.h" + #include "types/CloudString.h" #include "types/CloudLocation.h" #include "types/CloudSchedule.h" @@ -41,13 +39,7 @@ #include "types/CloudWrapperBase.h" #include "types/automation/CloudColoredLight.h" -#include "types/automation/CloudContactSensor.h" #include "types/automation/CloudDimmedLight.h" -#include "types/automation/CloudLight.h" -#include "types/automation/CloudMotionSensor.h" -#include "types/automation/CloudSmartPlug.h" -#include "types/automation/CloudSwitch.h" -#include "types/automation/CloudTemperatureSensor.h" #include "types/automation/CloudTelevision.h" /****************************************************************************** @@ -62,6 +54,11 @@ extern "C" unsigned long getTime(); typedef std::list PropertyContainer; +typedef PropertyPrimitive CloudBool; +typedef PropertyPrimitive CloudFloat; +typedef PropertyPrimitive CloudInt; +typedef PropertyPrimitive CloudUnsignedInt; + typedef CloudFloat CloudEnergy; typedef CloudFloat CloudForce; typedef CloudFloat CloudTemperature; @@ -93,6 +90,13 @@ typedef CloudInt CloudInformationContent; typedef CloudFloat CloudPercentage; typedef CloudFloat CloudRelativeHumidity; +typedef CloudBool CloudContactSensor; +typedef CloudBool CloudLight; +typedef CloudBool CloudMotionSensor; +typedef CloudBool CloudSmartPlug; +typedef CloudBool CloudSwitch; +typedef CloudFloat CloudTemperatureSensor; + /****************************************************************************** FUNCTION DECLARATION ******************************************************************************/ diff --git a/src/property/types/CloudBool.h b/src/property/types/CloudBool.h deleted file mode 100644 index 3434656fc..000000000 --- a/src/property/types/CloudBool.h +++ /dev/null @@ -1,78 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUDBOOL_H_ -#define CLOUDBOOL_H_ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include -#include "../Property.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - - - -class CloudBool : public Property { - protected: - bool _value, - _cloud_value; - public: - CloudBool() { - CloudBool(false); - } - CloudBool(bool v) : _value(v), _cloud_value(v) {} - operator bool() const { - return _value; - } - virtual bool isDifferentFromCloud() { - return _value != _cloud_value; - } - virtual void fromCloudToLocal() { - _value = _cloud_value; - } - virtual void fromLocalToCloud() { - _cloud_value = _value; - } - virtual CborError appendAttributesToCloud(CborEncoder *encoder) { - return appendAttribute(_value, "", encoder); - } - virtual void setAttributesFromCloud() { - setAttribute(_cloud_value, ""); - } - //modifiers - CloudBool& operator=(bool v) { - _value = v; - updateLocalTimestamp(); - return *this; - } - CloudBool& operator=(CloudBool v) { - return operator=((bool)v); - } - //accessors - CloudBool operator!() const { - return CloudBool(!_value); - } - //friends -}; - - -#endif /* CLOUDBOOL_H_ */ diff --git a/src/property/types/CloudFloat.h b/src/property/types/CloudFloat.h deleted file mode 100644 index 1918f9669..000000000 --- a/src/property/types/CloudFloat.h +++ /dev/null @@ -1,188 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUDFLOAT_H_ -#define CLOUDFLOAT_H_ - -#include -#include "../math_utils.h" - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include -#include "../Property.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - - - -class CloudFloat : public Property { - protected: - float _value, - _cloud_value; - public: - CloudFloat() { - CloudFloat(0.0f); - } - CloudFloat(float v) : _value(v), _cloud_value(v) {} - operator float() const { - return _value; - } - virtual bool isDifferentFromCloud() { - return arduino::math::ieee754_different(_value, _cloud_value, Property::_min_delta_property); - } - virtual void fromCloudToLocal() { - _value = _cloud_value; - } - virtual void fromLocalToCloud() { - _cloud_value = _value; - } - virtual CborError appendAttributesToCloud(CborEncoder *encoder) { - return appendAttribute(_value, "", encoder); - } - virtual void setAttributesFromCloud() { - setAttribute(_cloud_value, ""); - } - //modifiers - CloudFloat& operator=(float v) { - _value = v; - updateLocalTimestamp(); - return *this; - } - CloudFloat& operator=(CloudFloat v) { - return operator=((float)v); - } - CloudFloat& operator+=(float v) { - return operator=(_value += v); - } - CloudFloat& operator-=(float v) { - return operator=(_value -= v); - } - CloudFloat& operator*=(float v) { - return operator=(_value *= v); - } - CloudFloat& operator/=(float v) { - return operator=(_value /= v); - } - CloudFloat& operator++() { - return operator=(_value + 1.0f); - } - CloudFloat& operator--() { - return operator=(_value - 1.0f); - } - CloudFloat operator++(int) { - operator=(_value + 1.0f); - return CloudFloat(_value); - } - CloudFloat operator--(int) { - operator=(_value - 1.0f); - return CloudFloat(_value); - } - - //friends - friend CloudFloat operator+(CloudFloat iw, CloudFloat v) { - return iw += v; - } - friend CloudFloat operator+(CloudFloat iw, float v) { - return iw += v; - } - friend CloudFloat operator+(CloudFloat iw, int v) { - return iw += (float)v; - } - friend CloudFloat operator+(CloudFloat iw, double v) { - return iw += (float)v; - } - friend CloudFloat operator+(float v, CloudFloat iw) { - return CloudFloat(v) += iw; - } - friend CloudFloat operator+(int v, CloudFloat iw) { - return CloudFloat(v) += iw; - } - friend CloudFloat operator+(double v, CloudFloat iw) { - return CloudFloat(v) += iw; - } - friend CloudFloat operator-(CloudFloat iw, CloudFloat v) { - return iw -= v; - } - friend CloudFloat operator-(CloudFloat iw, float v) { - return iw -= v; - } - friend CloudFloat operator-(CloudFloat iw, int v) { - return iw -= (float)v; - } - friend CloudFloat operator-(CloudFloat iw, double v) { - return iw -= (float)v; - } - friend CloudFloat operator-(float v, CloudFloat iw) { - return CloudFloat(v) -= iw; - } - friend CloudFloat operator-(int v, CloudFloat iw) { - return CloudFloat(v) -= iw; - } - friend CloudFloat operator-(double v, CloudFloat iw) { - return CloudFloat(v) -= iw; - } - friend CloudFloat operator*(CloudFloat iw, CloudFloat v) { - return iw *= v; - } - friend CloudFloat operator*(CloudFloat iw, float v) { - return iw *= v; - } - friend CloudFloat operator*(CloudFloat iw, int v) { - return iw *= (float)v; - } - friend CloudFloat operator*(CloudFloat iw, double v) { - return iw *= (float)v; - } - friend CloudFloat operator*(float v, CloudFloat iw) { - return CloudFloat(v) *= iw; - } - friend CloudFloat operator*(int v, CloudFloat iw) { - return CloudFloat(v) *= iw; - } - friend CloudFloat operator*(double v, CloudFloat iw) { - return CloudFloat(v) *= iw; - } - friend CloudFloat operator/(CloudFloat iw, CloudFloat v) { - return iw /= v; - } - friend CloudFloat operator/(CloudFloat iw, float v) { - return iw /= v; - } - friend CloudFloat operator/(CloudFloat iw, int v) { - return iw /= (float)v; - } - friend CloudFloat operator/(CloudFloat iw, double v) { - return iw /= (float)v; - } - friend CloudFloat operator/(float v, CloudFloat iw) { - return CloudFloat(v) /= iw; - } - friend CloudFloat operator/(int v, CloudFloat iw) { - return CloudFloat(v) /= iw; - } - friend CloudFloat operator/(double v, CloudFloat iw) { - return CloudFloat(v) /= iw; - } -}; - - -#endif /* CLOUDFLOAT_H_ */ diff --git a/src/property/types/CloudInt.h b/src/property/types/CloudInt.h deleted file mode 100644 index 37e4d3cae..000000000 --- a/src/property/types/CloudInt.h +++ /dev/null @@ -1,222 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUDINT_H_ -#define CLOUDINT_H_ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include -#include "../Property.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - - - -class CloudInt : public Property { - private: - int _value, - _cloud_value; - public: - CloudInt() { - CloudInt(0); - } - CloudInt(int v) : _value(v), _cloud_value(v) {} - operator int() const { - return _value; - } - virtual bool isDifferentFromCloud() { - return _value != _cloud_value && (abs(_value - _cloud_value) >= Property::_min_delta_property); - } - virtual void fromCloudToLocal() { - _value = _cloud_value; - } - virtual void fromLocalToCloud() { - _cloud_value = _value; - } - virtual CborError appendAttributesToCloud(CborEncoder *encoder) { - return appendAttribute(_value, "", encoder); - } - virtual void setAttributesFromCloud() { - setAttribute(_cloud_value, ""); - } - //modifiers - CloudInt& operator=(int v) { - _value = v; - updateLocalTimestamp(); - return *this; - } - CloudInt& operator=(CloudInt v) { - return operator=((int)v); - } - CloudInt& operator+=(int v) { - return operator=(_value += v); - } - CloudInt& operator-=(int v) { - return operator=(_value -= v); - } - CloudInt& operator*=(int v) { - return operator=(_value *= v); - } - CloudInt& operator/=(int v) { - return operator=(_value /= v); - } - CloudInt& operator%=(int v) { - return operator=(_value %= v); - } - CloudInt& operator++() { - return operator=(++_value); - } - CloudInt& operator--() { - return operator=(--_value); - } - CloudInt operator++(int) { - operator=(_value + 1); - return CloudInt(_value); - } - CloudInt operator--(int) { - operator=(_value - 1); - return CloudInt(_value); - } - CloudInt& operator&=(int v) { - return operator=(_value &= v); - } - CloudInt& operator|=(int v) { - return operator=(_value |= v); - } - CloudInt& operator^=(int v) { - return operator=(_value ^= v); - } - CloudInt& operator<<=(int v) { - return operator=(_value <<= v); - } - CloudInt& operator>>=(int v) { - return operator=(_value >>= v); - } - //accessors - CloudInt operator+() const { - return CloudInt(+_value); - } - CloudInt operator-() const { - return CloudInt(-_value); - } - CloudInt operator!() const { - return CloudInt(!_value); - } - CloudInt operator~() const { - return CloudInt(~_value); - } - //friends - friend CloudInt operator+(CloudInt iw, CloudInt v) { - return iw += v; - } - friend CloudInt operator+(CloudInt iw, int v) { - return iw += v; - } - friend CloudInt operator+(int v, CloudInt iw) { - return CloudInt(v) += iw; - } - friend CloudInt operator-(CloudInt iw, CloudInt v) { - return iw -= v; - } - friend CloudInt operator-(CloudInt iw, int v) { - return iw -= v; - } - friend CloudInt operator-(int v, CloudInt iw) { - return CloudInt(v) -= iw; - } - friend CloudInt operator*(CloudInt iw, CloudInt v) { - return iw *= v; - } - friend CloudInt operator*(CloudInt iw, int v) { - return iw *= v; - } - friend CloudInt operator*(int v, CloudInt iw) { - return CloudInt(v) *= iw; - } - friend CloudInt operator/(CloudInt iw, CloudInt v) { - return iw /= v; - } - friend CloudInt operator/(CloudInt iw, int v) { - return iw /= v; - } - friend CloudInt operator/(int v, CloudInt iw) { - return CloudInt(v) /= iw; - } - friend CloudInt operator%(CloudInt iw, CloudInt v) { - return iw %= v; - } - friend CloudInt operator%(CloudInt iw, int v) { - return iw %= v; - } - friend CloudInt operator%(int v, CloudInt iw) { - return CloudInt(v) %= iw; - } - friend CloudInt operator&(CloudInt iw, CloudInt v) { - return iw &= v; - } - friend CloudInt operator&(CloudInt iw, int v) { - return iw &= v; - } - friend CloudInt operator&(int v, CloudInt iw) { - return CloudInt(v) &= iw; - } - friend CloudInt operator|(CloudInt iw, CloudInt v) { - return iw |= v; - } - friend CloudInt operator|(CloudInt iw, int v) { - return iw |= v; - } - friend CloudInt operator|(int v, CloudInt iw) { - return CloudInt(v) |= iw; - } - friend CloudInt operator^(CloudInt iw, CloudInt v) { - return iw ^= v; - } - friend CloudInt operator^(CloudInt iw, int v) { - return iw ^= v; - } - friend CloudInt operator^(int v, CloudInt iw) { - return CloudInt(v) ^= iw; - } - friend CloudInt operator<<(CloudInt iw, CloudInt v) { - return iw <<= v; - } - friend CloudInt operator<<(CloudInt iw, int v) { - return iw <<= v; - } - friend CloudInt operator<<(int v, CloudInt iw) { - return CloudInt(v) <<= iw; - } - friend CloudInt operator>>(CloudInt iw, CloudInt v) { - return iw >>= v; - } - friend CloudInt operator>>(CloudInt iw, int v) { - return iw >>= v; - } - friend CloudInt operator>>(int v, CloudInt iw) { - return CloudInt(v) >>= iw; - } - -}; - - -#endif /* CLOUDINT_H_ */ diff --git a/src/property/types/PropertyPrimitive.cpp b/src/property/types/PropertyPrimitive.cpp new file mode 100644 index 000000000..21925459f --- /dev/null +++ b/src/property/types/PropertyPrimitive.cpp @@ -0,0 +1,10 @@ +#include "PropertyPrimitive.h" + +#include "../math_utils.h" + + +// template specialization for float Properties to handle nan values +template<> +bool PropertyPrimitive::isDifferentFromCloud() { + return arduino::math::ieee754_different(_value, _cloud_value, Property::_min_delta_property); +} diff --git a/src/property/types/PropertyPrimitive.h b/src/property/types/PropertyPrimitive.h new file mode 100644 index 000000000..8424d2c4c --- /dev/null +++ b/src/property/types/PropertyPrimitive.h @@ -0,0 +1,193 @@ +#include "../Property.h" + +template +class PropertyPrimitive: public Property { +public: + PropertyPrimitive() { + PropertyPrimitive(0); + } + PropertyPrimitive(T v) : _value(v), _cloud_value(v) {} + operator T() const { + return _value; + } + virtual bool isDifferentFromCloud() { + return _value != _cloud_value && (abs(float(_value - _cloud_value)) >= Property::_min_delta_property); + } + virtual void fromCloudToLocal() { + _value = _cloud_value; + } + virtual void fromLocalToCloud() { + _cloud_value = _value; + } + virtual CborError appendAttributesToCloud(CborEncoder *encoder) { + return appendAttribute(_value, "", encoder); + } + virtual void setAttributesFromCloud() { + setAttribute(_cloud_value, ""); + } + + //modifiers + PropertyPrimitive& operator=(T v) { + _value = v; + updateLocalTimestamp(); + return *this; + } + PropertyPrimitive& operator=(PropertyPrimitive v) { + return operator=((T)v); + } + PropertyPrimitive& operator+=(T v) { + return operator=(_value += v); + } + PropertyPrimitive& operator-=(T v) { + return operator=(_value -= v); + } + PropertyPrimitive& operator*=(T v) { + return operator=(_value *= v); + } + PropertyPrimitive& operator/=(T v) { + return operator=(_value /= v); + } + PropertyPrimitive& operator%=(T v) { + return operator=(_value %= v); + } + PropertyPrimitive& operator++() { + return operator=(++_value); + } + PropertyPrimitive& operator--() { + return operator=(--_value); + } + PropertyPrimitive operator++(int) { + operator=(_value + 1); + return PropertyPrimitive(_value); + } + PropertyPrimitive operator--(int) { + operator=(_value - 1); + return PropertyPrimitive(_value); + } + PropertyPrimitive& operator&=(T v) { + return operator=(_value &= v); + } + PropertyPrimitive& operator|=(T v) { + return operator=(_value |= v); + } + PropertyPrimitive& operator^=(T v) { + return operator=(_value ^= v); + } + PropertyPrimitive& operator<<=(T v) { + return operator=(_value <<= v); + } + PropertyPrimitive& operator>>=(T v) { + return operator=(_value >>= v); + } + + //accessors + PropertyPrimitive operator+() const { + return PropertyPrimitive(+_value); + } + PropertyPrimitive operator-() const { + return PropertyPrimitive(-_value); + } + PropertyPrimitive operator!() const { + return PropertyPrimitive(!_value); + } + PropertyPrimitive operator~() const { + return PropertyPrimitive(~_value); + } + + //friends + // TODO second parameter should not be T, but another template? + friend PropertyPrimitive operator+(PropertyPrimitive iw, PropertyPrimitive v) { + return iw += v; // FIXME this should return a new property primitive + } + friend PropertyPrimitive operator+(PropertyPrimitive iw, T v) { // TODO may not be required -> T can become property primitive + return iw += v; + } + friend PropertyPrimitive operator+(T v, PropertyPrimitive iw) { // TODO may not be required -> T can become property primitive + return PropertyPrimitive(v) += iw; // FIXME this doesn't seem to make sense + } + friend PropertyPrimitive operator-(PropertyPrimitive iw, PropertyPrimitive v) { + return iw -= v; + } + friend PropertyPrimitive operator-(PropertyPrimitive iw, T v) { + return iw -= v; + } + friend PropertyPrimitive operator-(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) -= iw; + } + friend PropertyPrimitive operator*(PropertyPrimitive iw, PropertyPrimitive v) { + return iw *= v; + } + friend PropertyPrimitive operator*(PropertyPrimitive iw, T v) { + return iw *= v; + } + friend PropertyPrimitive operator*(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) *= iw; + } + friend PropertyPrimitive operator/(PropertyPrimitive iw, PropertyPrimitive v) { + return iw /= v; + } + friend PropertyPrimitive operator/(PropertyPrimitive iw, T v) { + return iw /= v; + } + friend PropertyPrimitive operator/(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) /= iw; + } + friend PropertyPrimitive operator%(PropertyPrimitive iw, PropertyPrimitive v) { + return iw %= v; + } + friend PropertyPrimitive operator%(PropertyPrimitive iw, T v) { + return iw %= v; + } + friend PropertyPrimitive operator%(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) %= iw; + } + friend PropertyPrimitive operator&(PropertyPrimitive iw, PropertyPrimitive v) { + return iw &= v; + } + friend PropertyPrimitive operator&(PropertyPrimitive iw, T v) { + return iw &= v; + } + friend PropertyPrimitive operator&(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) &= iw; + } + friend PropertyPrimitive operator|(PropertyPrimitive iw, PropertyPrimitive v) { + return iw |= v; + } + friend PropertyPrimitive operator|(PropertyPrimitive iw, T v) { + return iw |= v; + } + friend PropertyPrimitive operator|(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) |= iw; + } + friend PropertyPrimitive operator^(PropertyPrimitive iw, PropertyPrimitive v) { + return iw ^= v; + } + friend PropertyPrimitive operator^(PropertyPrimitive iw, T v) { + return iw ^= v; + } + friend PropertyPrimitive operator^(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) ^= iw; + } + friend PropertyPrimitive operator<<(PropertyPrimitive iw, PropertyPrimitive v) { + return iw <<= v; + } + friend PropertyPrimitive operator<<(PropertyPrimitive iw, T v) { + return iw <<= v; + } + friend PropertyPrimitive operator<<(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) <<= iw; + } + friend PropertyPrimitive operator>>(PropertyPrimitive iw, PropertyPrimitive v) { + return iw >>= v; + } + friend PropertyPrimitive operator>>(PropertyPrimitive iw, T v) { + return iw >>= v; + } + friend PropertyPrimitive operator>>(T v, PropertyPrimitive iw) { + return PropertyPrimitive(v) >>= iw; + } + +private: + T _value, + _cloud_value; +}; diff --git a/src/property/types/automation/CloudContactSensor.h b/src/property/types/automation/CloudContactSensor.h deleted file mode 100644 index 351eaed73..000000000 --- a/src/property/types/automation/CloudContactSensor.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUDCONTACTSENSOR_H_ -#define CLOUDCONTACTSENSOR_H_ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include -#include "../CloudBool.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - - - -class CloudContactSensor : public CloudBool { - private: - public: - operator bool() const { - return _value; - } - CloudContactSensor& operator=(bool v) { - CloudBool::operator=(v); - return *this; - } -}; - - -#endif /* CLOUDCONTACTSENSOR_H_ */ diff --git a/src/property/types/automation/CloudLight.h b/src/property/types/automation/CloudLight.h deleted file mode 100644 index 358527b37..000000000 --- a/src/property/types/automation/CloudLight.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUDLIGHT_H_ -#define CLOUDLIGHT_H_ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include -#include "../CloudBool.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - - - -class CloudLight : public CloudBool { - private: - public: - operator bool() const { - return _value; - } - CloudLight& operator=(bool v) { - CloudBool::operator=(v); - return *this; - } -}; - - -#endif /* CLOUDLIGHT_H_ */ diff --git a/src/property/types/automation/CloudMotionSensor.h b/src/property/types/automation/CloudMotionSensor.h deleted file mode 100644 index 3831d3d27..000000000 --- a/src/property/types/automation/CloudMotionSensor.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUDMOTIONSENSOR_H_ -#define CLOUDMOTIONSENSOR_H_ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include -#include "../CloudBool.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - - - -class CloudMotionSensor : public CloudBool { - private: - public: - operator bool() const { - return _value; - } - CloudMotionSensor& operator=(bool v) { - CloudBool::operator=(v); - return *this; - } -}; - - -#endif /* CLOUDMOTIONSENSOR_H_ */ diff --git a/src/property/types/automation/CloudSmartPlug.h b/src/property/types/automation/CloudSmartPlug.h deleted file mode 100644 index 99c7886fb..000000000 --- a/src/property/types/automation/CloudSmartPlug.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUDSMARTPLUG_H_ -#define CLOUDSMARTPLUG_H_ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include -#include "../CloudBool.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - - - -class CloudSmartPlug : public CloudBool { - private: - public: - operator bool() const { - return _value; - } - CloudSmartPlug& operator=(bool v) { - CloudBool::operator=(v); - return *this; - } -}; - - -#endif /* CLOUDSMARTPLUG_H_ */ diff --git a/src/property/types/automation/CloudSwitch.h b/src/property/types/automation/CloudSwitch.h deleted file mode 100644 index d22345d88..000000000 --- a/src/property/types/automation/CloudSwitch.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUDSWITCH_H_ -#define CLOUDSWITCH_H_ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include -#include "../CloudBool.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - - - -class CloudSwitch : public CloudBool { - private: - public: - operator bool() const { - return _value; - } - CloudSwitch& operator=(bool v) { - CloudBool::operator=(v); - return *this; - } -}; - - -#endif /* CLOUDSWITCH_H_ */ diff --git a/src/property/types/automation/CloudTemperatureSensor.h b/src/property/types/automation/CloudTemperatureSensor.h deleted file mode 100644 index 69ce33eb8..000000000 --- a/src/property/types/automation/CloudTemperatureSensor.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// This file is part of ArduinoCloudThing -// -// Copyright 2019 ARDUINO SA (http://www.arduino.cc/) -// -// This software is released under the GNU General Public License version 3, -// which covers the main part of ArduinoCloudThing. -// The terms of this license can be found at: -// https://www.gnu.org/licenses/gpl-3.0.en.html -// -// You can be released from the requirements of the above licenses by purchasing -// a commercial license. Buying such a license is mandatory if you want to modify or -// otherwise use the software for commercial activities involving the Arduino -// software without disclosing the source code of your own applications. To purchase -// a commercial license, send an email to license@arduino.cc. -// - -#ifndef CLOUD_TEMPERATURE_SENSOR_H_ -#define CLOUD_TEMPERATURE_SENSOR_H_ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include "../CloudFloat.h" - -/****************************************************************************** - CLASS DECLARATION - ******************************************************************************/ - -class CloudTemperatureSensor : public CloudFloat -{ - public: - - CloudTemperatureSensor & operator = (float v) - { - CloudFloat::operator=(v); - return *this; - } -}; - -#endif /* CLOUD_TEMPERATURE_SENSOR_H_ */