change SmartVariable Callback to std::function
This commit is contained in:
parent
1d977c5bdf
commit
919c28a9c7
|
@ -105,7 +105,7 @@ void SmartVariable::setValueAutoSave(bool autoSave)
|
||||||
this->autoSave = autoSave;
|
this->autoSave = autoSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t SmartVariable::registerCallback(void (*callback)(char *))
|
uint16_t SmartVariable::registerCallback(std::function<void(char *)> callback)
|
||||||
{
|
{
|
||||||
this->valueChangeCallbacks[this->currentHandlerId] = callback;
|
this->valueChangeCallbacks[this->currentHandlerId] = callback;
|
||||||
return this->currentHandlerId++;
|
return this->currentHandlerId++;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
void loadValue();
|
void loadValue();
|
||||||
void saveValue();
|
void saveValue();
|
||||||
void setValueAutoSave(bool autoSave);
|
void setValueAutoSave(bool autoSave);
|
||||||
uint16_t registerCallback(void (*callback)(char*));
|
uint16_t registerCallback(std::function<void(char*)> callback);
|
||||||
void unregisterCallback(uint16_t handlerId);
|
void unregisterCallback(uint16_t handlerId);
|
||||||
int32_t getIntValue();
|
int32_t getIntValue();
|
||||||
void setIntValue(int32_t value);
|
void setIntValue(int32_t value);
|
||||||
|
@ -46,5 +46,5 @@ protected:
|
||||||
void subscribeMqtt();
|
void subscribeMqtt();
|
||||||
// Value Change Callback
|
// Value Change Callback
|
||||||
uint16_t currentHandlerId;
|
uint16_t currentHandlerId;
|
||||||
std::map<uint16_t, void (*)(char*)> valueChangeCallbacks;
|
std::map<uint16_t, std::function<void(char*)>> valueChangeCallbacks;
|
||||||
};
|
};
|
Loading…
Reference in New Issue