From d078c8c4db3e1ec878b95c0cadca087d73cd2dda Mon Sep 17 00:00:00 2001 From: Ake Hedman Date: Tue, 2 Jan 2024 22:18:53 +0100 Subject: [PATCH] Added remote variable handler methods --- src/vscp/common/mdf.cpp | 24 +++++++++++++++++++++++- src/vscp/common/mdf.h | 7 +++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/vscp/common/mdf.cpp b/src/vscp/common/mdf.cpp index 63ee02ab0..b1faf9d63 100644 --- a/src/vscp/common/mdf.cpp +++ b/src/vscp/common/mdf.cpp @@ -7730,7 +7730,7 @@ CMDF::getRemoteVariable(uint32_t offset, uint16_t page) std::deque::iterator iter; for (iter = m_list_remotevar.begin(); iter != m_list_remotevar.end(); ++iter) { CMDF_RemoteVariable *pvar = *iter; - if ((nullptr == pvar) && (page == pvar->getPage()) && (offset == pvar->getOffset()) ) { + if ((nullptr != pvar) && (page == pvar->getPage()) && (offset == pvar->getOffset()) ) { return pvar; } } @@ -7785,6 +7785,28 @@ CMDF::deleteRegister(CMDF_Register *preg) return false; } +/////////////////////////////////////////////////////////////////////////////// +// deleteRemoteVariable +// + +bool +CMDF::deleteRemoteVariable(CMDF_RemoteVariable *pvar) +{ + // Check pointer + if (nullptr == pvar) { + return false; + } + + for (auto it = m_list_remotevar.cbegin(); it != m_list_remotevar.cend(); ++it) { + if (pvar == *it) { + m_list_remotevar.erase(it); + return true; + } + } + + return false; +} + /////////////////////////////////////////////////////////////////////////////// // createRegisterStortedSet // diff --git a/src/vscp/common/mdf.h b/src/vscp/common/mdf.h index dd9c12fd3..c2e915d13 100644 --- a/src/vscp/common/mdf.h +++ b/src/vscp/common/mdf.h @@ -3840,6 +3840,13 @@ class CMDF : public CMDF_Object { */ std::deque *getRemoteVariableList(void) { return &m_list_remotevar; }; + /*! + Delete a defined remote variable + @param pvar Pointer to remote variable + @return True on success, false otherwise + */ + bool deleteRemoteVariable(CMDF_RemoteVariable *pvar); + //----------------------------------------------------------------------------- /*!