mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-02 05:46:22 +01:00
trunk/branch integration: observer::disable()
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/AbstractObserver.h"
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -91,19 +92,24 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void notify(Notification* pNf) const
|
||||
{
|
||||
N* pCastNf = dynamic_cast<N*>(pNf);
|
||||
if (pCastNf)
|
||||
{
|
||||
pCastNf->duplicate();
|
||||
(_pObject->*_method)(pCastNf);
|
||||
}
|
||||
}
|
||||
|
||||
bool equals(const AbstractObserver& abstractObserver) const
|
||||
{
|
||||
|
||||
void notify(Notification* pNf) const
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_pObject)
|
||||
{
|
||||
N* pCastNf = dynamic_cast<N*>(pNf);
|
||||
if (pCastNf)
|
||||
{
|
||||
pCastNf->duplicate();
|
||||
(_pObject->*_method)(pCastNf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool equals(const AbstractObserver& abstractObserver) const
|
||||
{
|
||||
const Observer* pObs = dynamic_cast<const Observer*>(&abstractObserver);
|
||||
return pObs && pObs->_pObject == _pObject && pObs->_method == _method;
|
||||
}
|
||||
@@ -115,14 +121,22 @@ public:
|
||||
|
||||
AbstractObserver* clone() const
|
||||
{
|
||||
return new Observer(*this);
|
||||
}
|
||||
|
||||
return new Observer(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
_pObject = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Observer();
|
||||
Observer();
|
||||
|
||||
C* _pObject;
|
||||
Callback _method;
|
||||
C* _pObject;
|
||||
Callback _method;
|
||||
mutable Poco::Mutex _mutex;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user