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); + //----------------------------------------------------------------------------- /*!