add option to add bits to setDataHandlerState()

This commit is contained in:
John
2022-04-30 15:37:23 +02:00
parent 101d0fcdfb
commit ea5337fdaa
2 changed files with 5 additions and 4 deletions
+3 -3
View File
@@ -1027,11 +1027,11 @@ void Message::decodeJson(bool leadingSeparator, bool appendDirectionCondition, b
*output << "\n }";
}
bool Message::setDataHandlerState(int state) {
if (state == m_dataHandlerState) {
bool Message::setDataHandlerState(int state, bool addBits) {
if (addBits ? state == (m_dataHandlerState&state) : state == m_dataHandlerState) {
return false;
}
m_dataHandlerState = state;
m_dataHandlerState = addBits ? m_dataHandlerState|state : state;
return true;
}
+2 -1
View File
@@ -534,9 +534,10 @@ class Message : public AttributedItem {
/**
* Set the arbitrary state value for data handlers.
* @param state the new state value.
* @param addBits true to add the new state value bits to the existing state.
* @return true when the state was changed.
*/
bool setDataHandlerState(int state);
bool setDataHandlerState(int state, bool addBits = false);
/**
* Get the time when this message was last seen with reasonable data.