AbstractObserver::accepts() - add optional name parameter

This commit is contained in:
Günter Obiltschnig 2021-06-23 08:33:45 +02:00
parent 7cae9a1b6d
commit d66acced93
3 changed files with 5 additions and 5 deletions

View File

@ -38,7 +38,7 @@ public:
virtual void notify(Notification* pNf) const = 0; virtual void notify(Notification* pNf) const = 0;
virtual bool equals(const AbstractObserver& observer) 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 AbstractObserver* clone() const = 0;
virtual void disable() = 0; virtual void disable() = 0;
}; };

View File

@ -94,9 +94,9 @@ public:
return pObs && pObs->_pObject == _pObject && pObs->_method == _method; 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 AbstractObserver* clone() const

View File

@ -92,9 +92,9 @@ public:
return pObs && pObs->_pObject == _pObject && pObs->_method == _method; 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 AbstractObserver* clone() const