accept notifications by name (if they have one)

This commit is contained in:
Alex Fabijanic 2020-01-15 20:58:09 +01:00
parent 7be832bac2
commit a2227c3bfd
3 changed files with 5 additions and 5 deletions

2
Foundation/include/Poco/AbstractObserver.h Normal file → Executable file
View File

@ -38,7 +38,7 @@ public:
virtual void notify(Notification* pNf) const = 0;
virtual bool equals(const AbstractObserver& observer) const = 0;
virtual bool accepts(Notification* pNf) const = 0;
virtual bool accepts(Notification* pNf, const char* pName = 0) const = 0;
virtual AbstractObserver* clone() const = 0;
virtual void disable() = 0;
};

4
Foundation/include/Poco/NObserver.h Normal file → Executable file
View File

@ -94,9 +94,9 @@ public:
return pObs && pObs->_pObject == _pObject && pObs->_method == _method;
}
bool accepts(Notification* pNf) const
bool accepts(Notification* pNf, const char* pName = 0) const
{
return dynamic_cast<N*>(pNf) != 0;
return dynamic_cast<N*>(pNf) && (!pName || pNf->name() == pName);
}
AbstractObserver* clone() const

4
Foundation/include/Poco/Observer.h Normal file → Executable file
View File

@ -92,9 +92,9 @@ public:
return pObs && pObs->_pObject == _pObject && pObs->_method == _method;
}
bool accepts(Notification* pNf) const
bool accepts(Notification* pNf, const char* pName = 0) const
{
return dynamic_cast<N*>(pNf) != 0;
return dynamic_cast<N*>(pNf) && (!pName || pNf->name() == pName);
}
AbstractObserver* clone() const