mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-21 14:42:51 +01:00
trunk/branch integration: observer::disable()
This commit is contained in:
parent
58064f8284
commit
275013ed5e
@ -62,6 +62,7 @@ public:
|
||||
virtual bool equals(const AbstractObserver& observer) const = 0;
|
||||
virtual bool accepts(Notification* pNf) const = 0;
|
||||
virtual AbstractObserver* clone() const = 0;
|
||||
virtual void disable() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// NObserver.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/NObserver.h#3 $
|
||||
// $Id: //poco/1.4/Foundation/include/Poco/NObserver.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Notifications
|
||||
@ -42,6 +42,7 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/AbstractObserver.h"
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -95,6 +96,10 @@ public:
|
||||
}
|
||||
|
||||
void notify(Notification* pNf) const
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_pObject)
|
||||
{
|
||||
N* pCastNf = dynamic_cast<N*>(pNf);
|
||||
if (pCastNf)
|
||||
@ -103,6 +108,7 @@ public:
|
||||
(_pObject->*_method)(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool equals(const AbstractObserver& abstractObserver) const
|
||||
{
|
||||
@ -120,11 +126,19 @@ public:
|
||||
return new NObserver(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
_pObject = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
NObserver();
|
||||
|
||||
C* _pObject;
|
||||
Callback _method;
|
||||
mutable Poco::Mutex _mutex;
|
||||
};
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/AbstractObserver.h"
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -93,6 +94,10 @@ public:
|
||||
}
|
||||
|
||||
void notify(Notification* pNf) const
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_pObject)
|
||||
{
|
||||
N* pCastNf = dynamic_cast<N*>(pNf);
|
||||
if (pCastNf)
|
||||
@ -101,6 +106,7 @@ public:
|
||||
(_pObject->*_method)(pCastNf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool equals(const AbstractObserver& abstractObserver) const
|
||||
{
|
||||
@ -118,11 +124,19 @@ public:
|
||||
return new Observer(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
_pObject = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Observer();
|
||||
|
||||
C* _pObject;
|
||||
Callback _method;
|
||||
mutable Poco::Mutex _mutex;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user