Skip to content

Commit 4d74549

Browse files
committed
Cleaning up callback function which is called upon completion of synchronisation from the cloud
1 parent 5f6dd20 commit 4d74549

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/property/Property.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Property::Property()
3535
, _permission{Permission::Read}
3636
, _get_time_func{nullptr}
3737
, _update_callback_func{nullptr}
38-
, _sync_callback_func{nullptr}
38+
, _on_sync_callback_func{nullptr}
3939
, _update_policy{UpdatePolicy::OnChange}
4040
, _has_been_updated_once{false}
4141
, _has_been_modified_in_callback{false}
@@ -67,8 +67,8 @@ Property & Property::onUpdate(UpdateCallbackFunc func) {
6767
return (*this);
6868
}
6969

70-
Property & Property::onSync(SyncCallbackFunc func) {
71-
_sync_callback_func = func;
70+
Property & Property::onSync(OnSyncCallbackFunc func) {
71+
_on_sync_callback_func = func;
7272
return (*this);
7373
}
7474

@@ -128,7 +128,7 @@ void Property::requestUpdate()
128128
}
129129

130130
void Property::execCallbackOnChange() {
131-
if (_update_callback_func != NULL) {
131+
if (_update_callback_func != nullptr) {
132132
_update_callback_func();
133133
}
134134
if (!isDifferentFromCloud()) {
@@ -137,8 +137,8 @@ void Property::execCallbackOnChange() {
137137
}
138138

139139
void Property::execCallbackOnSync() {
140-
if (_sync_callback_func != NULL) {
141-
_sync_callback_func(*this);
140+
if (_on_sync_callback_func != nullptr) {
141+
_on_sync_callback_func(*this);
142142
}
143143
}
144144

src/property/Property.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,22 @@ enum class UpdatePolicy {
122122

123123
typedef void(*UpdateCallbackFunc)(void);
124124
typedef unsigned long(*GetTimeCallbackFunc)();
125+
class Property;
126+
typedef void(*OnSyncCallbackFunc)(Property &);
125127

126128
/******************************************************************************
127129
CLASS DECLARATION
128130
******************************************************************************/
129131

130-
class Property {
131-
typedef void(*SyncCallbackFunc)(Property &property);
132+
class Property
133+
{
132134
public:
133135
Property();
134136
void init(String const name, Permission const permission, GetTimeCallbackFunc func);
135137

136138
/* Composable configuration of the Property class */
137139
Property & onUpdate(UpdateCallbackFunc func);
138-
Property & onSync(SyncCallbackFunc func);
140+
Property & onSync(OnSyncCallbackFunc func);
139141
Property & publishOnChange(float const min_delta_property, unsigned long const min_time_between_updates_millis = 0);
140142
Property & publishEvery(unsigned long const seconds);
141143
Property & publishOnDemand();
@@ -201,7 +203,7 @@ class Property {
201203
Permission _permission;
202204
GetTimeCallbackFunc _get_time_func;
203205
UpdateCallbackFunc _update_callback_func;
204-
void (*_sync_callback_func)(Property &property);
206+
OnSyncCallbackFunc _on_sync_callback_func;
205207

206208
UpdatePolicy _update_policy;
207209
bool _has_been_updated_once,

0 commit comments

Comments
 (0)