Skip to content

Commit

Permalink
Rename setAttributeReal to setAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
pennam committed Dec 1, 2022
1 parent de7e25c commit 7d5221c
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 50 deletions.
24 changes: 12 additions & 12 deletions src/property/Property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ void Property::setAttributesFromCloud(std::list<CborMapData> * map_data_list) {
setAttributesFromCloud();
}

void Property::setAttributeReal(bool& value, String attributeName) {
setAttributeReal(attributeName, [&value](CborMapData & md) {
void Property::setAttribute(bool& value, String attributeName) {
setAttribute(attributeName, [&value](CborMapData & md) {
// Manage the case to have boolean values received as integers 0/1
if (md.bool_val.isSet()) {
value = md.bool_val.get();
Expand All @@ -295,34 +295,34 @@ void Property::setAttributeReal(bool& value, String attributeName) {
});
}

void Property::setAttributeReal(int& value, String attributeName) {
setAttributeReal(attributeName, [&value](CborMapData & md) {
void Property::setAttribute(int& value, String attributeName) {
setAttribute(attributeName, [&value](CborMapData & md) {
value = md.val.get();
});
}

void Property::setAttributeReal(unsigned int& value, String attributeName) {
setAttributeReal(attributeName, [&value](CborMapData & md) {
void Property::setAttribute(unsigned int& value, String attributeName) {
setAttribute(attributeName, [&value](CborMapData & md) {
value = md.val.get();
});
}

void Property::setAttributeReal(float& value, String attributeName) {
setAttributeReal(attributeName, [&value](CborMapData & md) {
void Property::setAttribute(float& value, String attributeName) {
setAttribute(attributeName, [&value](CborMapData & md) {
value = md.val.get();
});
}

void Property::setAttributeReal(String& value, String attributeName) {
setAttributeReal(attributeName, [&value](CborMapData & md) {
void Property::setAttribute(String& value, String attributeName) {
setAttribute(attributeName, [&value](CborMapData & md) {
value = md.str_val.get();
});
}

#ifdef __AVR__
void Property::setAttributeReal(String attributeName, nonstd::function<void (CborMapData & md)>setValue)
void Property::setAttribute(String attributeName, nonstd::function<void (CborMapData & md)>setValue)
#else
void Property::setAttributeReal(String attributeName, std::function<void (CborMapData & md)>setValue)
void Property::setAttribute(String attributeName, std::function<void (CborMapData & md)>setValue)
#endif
{
if (attributeName != "") {
Expand Down
14 changes: 7 additions & 7 deletions src/property/Property.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,17 @@ class Property
CborError appendAttribute(String value, String attributeName = "", CborEncoder *encoder = nullptr);
#ifndef __AVR__
CborError appendAttributeName(String attributeName, std::function<CborError (CborEncoder& mapEncoder)>f, CborEncoder *encoder);
void setAttributeReal(String attributeName, std::function<void (CborMapData & md)>setValue);
void setAttribute(String attributeName, std::function<void (CborMapData & md)>setValue);
#else
CborError appendAttributeName(String attributeName, nonstd::function<CborError (CborEncoder& mapEncoder)>f, CborEncoder *encoder);
void setAttributeReal(String attributeName, nonstd::function<void (CborMapData & md)>setValue);
void setAttribute(String attributeName, nonstd::function<void (CborMapData & md)>setValue);
#endif
void setAttributesFromCloud(std::list<CborMapData> * map_data_list);
void setAttributeReal(bool& value, String attributeName = "");
void setAttributeReal(int& value, String attributeName = "");
void setAttributeReal(unsigned int& value, String attributeName = "");
void setAttributeReal(float& value, String attributeName = "");
void setAttributeReal(String& value, String attributeName = "");
void setAttribute(bool& value, String attributeName = "");
void setAttribute(int& value, String attributeName = "");
void setAttribute(unsigned int& value, String attributeName = "");
void setAttribute(float& value, String attributeName = "");
void setAttribute(String& value, String attributeName = "");

virtual bool isDifferentFromCloud() = 0;
virtual void fromCloudToLocal() = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudBool.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CloudBool : public Property {
return appendAttribute(_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
//modifiers
CloudBool& operator=(bool v) {
Expand Down
6 changes: 3 additions & 3 deletions src/property/types/CloudColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ class CloudColor : public Property {
return CborNoError;
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value.hue, "hue");
setAttributeReal(_cloud_value.sat, "sat");
setAttributeReal(_cloud_value.bri, "bri");
setAttribute(_cloud_value.hue, "hue");
setAttribute(_cloud_value.sat, "sat");
setAttribute(_cloud_value.bri, "bri");
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CloudFloat : public Property {
return appendAttribute(_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
//modifiers
CloudFloat& operator=(float v) {
Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CloudInt : public Property {
return appendAttribute(_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
//modifiers
CloudInt& operator=(int v) {
Expand Down
4 changes: 2 additions & 2 deletions src/property/types/CloudLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class CloudLocation : public Property {
return CborNoError;
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value.lat, "lat");
setAttributeReal(_cloud_value.lon, "lon");
setAttribute(_cloud_value.lat, "lat");
setAttribute(_cloud_value.lon, "lon");
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/property/types/CloudSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ class CloudSchedule : public Property {
return CborNoError;
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value.frm, "frm");
setAttributeReal(_cloud_value.to, "to");
setAttributeReal(_cloud_value.len, "len");
setAttributeReal(_cloud_value.msk, "msk");
setAttribute(_cloud_value.frm, "frm");
setAttribute(_cloud_value.to, "to");
setAttribute(_cloud_value.len, "len");
setAttribute(_cloud_value.msk, "msk");
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudString.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CloudString : public Property {
return appendAttribute(_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
//modifiers
CloudString& operator=(String v) {
Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudUnsignedInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CloudUnsignedInt : public Property {
return appendAttribute(_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
//modifiers
CloudUnsignedInt& operator=(unsigned int v) {
Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudWrapperBool.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CloudWrapperBool : public CloudWrapperBase {
return appendAttribute(_primitive_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
virtual bool isPrimitive() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudWrapperFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CloudWrapperFloat : public CloudWrapperBase {
return appendAttribute(_primitive_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
virtual bool isPrimitive() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudWrapperInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CloudWrapperInt : public CloudWrapperBase {
return appendAttribute(_primitive_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
virtual bool isPrimitive() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudWrapperString.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CloudWrapperString : public CloudWrapperBase {
return appendAttribute(_primitive_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
virtual bool isPrimitive() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/property/types/CloudWrapperUnsignedInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CloudWrapperUnsignedInt : public CloudWrapperBase {
return appendAttribute(_primitive_value, "", encoder);
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value, "");
setAttribute(_cloud_value, "");
}
virtual bool isPrimitive() {
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/property/types/automation/CloudColoredLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ class CloudColoredLight : public CloudColor {
return CborNoError;
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value.swi, "swi");
setAttributeReal(_cloud_value.hue, "hue");
setAttributeReal(_cloud_value.sat, "sat");
setAttributeReal(_cloud_value.bri, "bri");
setAttribute(_cloud_value.swi, "swi");
setAttribute(_cloud_value.hue, "hue");
setAttribute(_cloud_value.sat, "sat");
setAttribute(_cloud_value.bri, "bri");
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/property/types/automation/CloudDimmedLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class CloudDimmedLight : public Property {
}

virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value.swi, "swi");
setAttributeReal(_cloud_value.bri, "bri");
setAttribute(_cloud_value.swi, "swi");
setAttribute(_cloud_value.bri, "bri");
}
};

Expand Down
12 changes: 6 additions & 6 deletions src/property/types/automation/CloudTelevision.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ class CloudTelevision : public Property {
return CborNoError;
}
virtual void setAttributesFromCloud() {
setAttributeReal(_cloud_value.swi, "swi");
setAttributeReal(_cloud_value.vol, "vol");
setAttributeReal(_cloud_value.mut, "mut");
setAttributeReal((int&)_cloud_value.pbc, "pbc");
setAttributeReal((int&)_cloud_value.inp, "inp");
setAttributeReal(_cloud_value.cha, "cha");
setAttribute(_cloud_value.swi, "swi");
setAttribute(_cloud_value.vol, "vol");
setAttribute(_cloud_value.mut, "mut");
setAttribute((int&)_cloud_value.pbc, "pbc");
setAttribute((int&)_cloud_value.inp, "inp");
setAttribute(_cloud_value.cha, "cha");
}
};

Expand Down

0 comments on commit 7d5221c

Please sign in to comment.