27 #ifndef PTLIB_NOTIFIER_EXT_H
28 #define PTLIB_NOTIFIER_EXT_H
82 template <
typename ParamType>
91 ,
m_targetID(notifierTarget->m_validatedNotifierId)
107 #define PDECLARE_VALIDATED_NOTIFIER_EXT(notifierType, notifierArg, notifiee, func, ParamType, ParamArg) \
108 PDECLARE_NOTIFIER_COMMON(notifierType, notifierArg, notifiee, func, ParamType, ParamArg, PValidatedNotifierFunction<ParamType>)
113 #define PDECLARE_VALIDATED_NOTIFIER2(notifierType, notifiee, func, ParamType ) \
114 PDECLARE_VALIDATED_NOTIFIER_EXT(notifierType, , notifiee, func, ParamType, )
117 #define PDECLARE_VALIDATED_NOTIFIER(notifierType, notifiee, func) \
118 PDECLARE_VALIDATED_NOTIFIER2(notifierType, notifiee, func, P_INT_PTR)
126 virtual void Call() = 0;
190 template <
typename ParamType>
199 ,
m_targetID(notifierTarget->m_asyncNotifierId)
205 template <
class Target>
209 const Target & m_target;
216 , m_notifier(notifier)
222 m_target.AsyncCall(m_notifier, m_extra);
231 #define PDECLARE_ASYNC_NOTIFIER_EXT(notifierType, notifierArg, notifiee, func, ParamType, ParamArg) \
232 PDECLARE_NOTIFIER_COMMON1(notifierType, notifiee, func, ParamType, PAsyncNotifierFunction<ParamType>) \
233 { PAsyncNotifierCallback::Queue(m_targetID, new TypedCallback<func##_PNotifier>(*this, note, extra)); } \
234 void AsyncCall(PObject & note, ParamType extra) const \
235 PDECLARE_NOTIFIER_COMMON2(notifierType, notifierArg, notifiee, func, ParamType, ParamArg, PAsyncNotifierFunction<ParamType>)
240 #define PDECLARE_ASYNC_NOTIFIER2(notifierType, notifiee, func, ParamType) \
241 PDECLARE_ASYNC_NOTIFIER_EXT(notifierType, , notifiee, func, ParamType, )
244 #define PDECLARE_ASYNC_NOTIFIER(notifierType, notifiee, func) \
245 PDECLARE_ASYNC_NOTIFIER2(notifierType, notifiee, func, P_INT_PTR)
252 template <
typename ParamType>
258 typedef std::list<Notifier> List;
263 PINDEX
GetSize()
const {
return this->m_list.size(); }
268 if (std::find(this->m_list.begin(), this->m_list.end(), handler) != this->m_list.end())
270 this->m_list.push_back(handler);
277 typename List::iterator it = std::find(this->m_list.begin(), this->m_list.end(), handler);
278 if (it == this->m_list.end())
280 this->m_list.erase(it);
287 return std::find(this->m_list.begin(), this->m_list.end(), handler) != this->m_list.end();
293 return this->m_list.empty();
296 struct IsTarget :
public std::unary_function<PObject, bool>
306 this->m_list.remove_if(IsTarget(obj));
312 if (this->m_list.empty())
314 for (
typename List::iterator it = this->m_list.begin(); it != this->m_list.end() ; ++it)
323 #endif // PTLIB_NOTIFIER_EXT_H
PINDEX GetSize() const
Indicate the number of notifiers in list.
Definition: notifier_ext.h:263
PAsyncNotifierFunction(void *voidTarget, PAsyncNotifierTarget *notifierTarget)
Definition: notifier_ext.h:197
TypedCallback(const Target &target, PObject ¬ifier, ParamType extra)
Definition: notifier_ext.h:214
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:51
Definition: notifier_ext.h:296
Validated PNotifier class.
Definition: notifier_ext.h:56
static bool Exists(PNotifierIdentifer id)
This is an abstract class for which a descendent is declared for every function that may be called...
Definition: notifier_ext.h:83
PNotifierIdentifer m_targetID
Definition: notifier_ext.h:100
PValidatedNotifierTarget()
PObject * m_obj
Definition: notifier_ext.h:298
bool Add(const Notifier &handler)
Add a notifier to the list.
Definition: notifier_ext.h:266
virtual void AsyncNotifierSignal()
Signal the target that there are notifications pending.
virtual void Call()
Definition: notifier_ext.h:220
void * m_target
Object instance to receive the notification function call.
Definition: notifier.h:84
This is an abstract class for which a descendent is declared for every function that may be called...
Definition: notifier_ext.h:191
void RemoveTarget(PObject *obj)
Remove all notifiers that use the specified target object.
Definition: notifier_ext.h:304
bool AsyncNotifierExecute(const PTimeInterval &wait=0)
Execute any notifications queued.
Definition: notifier_ext.h:206
virtual void * GetTarget() const
Definition: notifier_ext.h:94
bool IsEmpty() const
Indicate notifier list is empty.
Definition: notifier_ext.h:291
virtual ~PAsyncNotifierCallback()
Definition: notifier_ext.h:125
Maintain a list of notifiers to be called all at once.
Definition: notifier_ext.h:253
bool operator()(PObject &obj, ParamType param)
Execute all notifiers in the list.
Definition: notifier_ext.h:310
The PNotifier and PNotifierFunction classes build a completely type safe mechanism for calling arbitr...
Definition: notifier.h:109
bool Remove(const Notifier &handler)
Remove notifier from teh list.
Definition: notifier_ext.h:275
PValidatedNotifierFunction(void *voidTarget, PValidatedNotifierTarget *notifierTarget)
Definition: notifier_ext.h:89
Asynchronous PNotifier class.
Definition: notifier_ext.h:145
void * GetTarget() const
Definition: notifier.h:135
PNotifierListTemplate< P_INT_PTR > PNotifierList
Definition: notifier_ext.h:320
unsigned long PNotifierIdentifer
Definition: notifier_ext.h:39
static void Queue(PNotifierIdentifer id, PAsyncNotifierCallback *callback)
bool Contains(const Notifier &handler) const
Determine if notifier is in list.
Definition: notifier_ext.h:285
PNotifierIdentifer m_targetID
Definition: notifier_ext.h:203
Definition: notifier_ext.h:123
This is an abstract class for which a descendent is declared for every function that may be called...
Definition: notifier.h:59
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
virtual ~PValidatedNotifierTarget()
virtual ~PAsyncNotifierTarget()
void operator=(const PValidatedNotifierTarget &)
Definition: notifier_ext.h:64
IsTarget(PObject *obj)
Definition: notifier_ext.h:299
bool operator()(Notifier &test) const
Definition: notifier_ext.h:300