27 #ifndef PTLIB_NOTIFIER_H
28 #define PTLIB_NOTIFIER_H
58 template <
typename ParamType>
108 template <
typename ParamType>
132 ptr->
Call(notifier, extra);
138 return ptr != NULL ? ptr->
GetTarget() : NULL;
148 #define PDECLARE_NOTIFIER_COMMON1(notifierType, notifiee, func, ParamType, BaseClass) \
149 class func##_PNotifier : public BaseClass { \
151 func##_PNotifier(notifiee * target) : BaseClass(target, target) { } \
152 virtual void Call(PObject & note, ParamType extra) const \
154 #define PDECLARE_NOTIFIER_COMMON2(notifierType, notifierArg, notifiee, func, ParamType, ParamArg, BaseClass) \
155 { notifiee * target = reinterpret_cast<notifiee *>(this->GetTarget()); \
156 if (target != NULL) \
157 target->func(reinterpret_cast<notifierType &>(note), extra); \
159 static PNotifierTemplate<ParamType> Create(notifiee * obj) { return new func##_PNotifier(obj); } \
160 static PNotifierTemplate<ParamType> Create(notifiee & obj) { return new func##_PNotifier(&obj); } \
162 friend class func##_PNotifier; \
163 virtual void func(notifierType & notifierArg, ParamType ParamArg) \
165 #define PDECLARE_NOTIFIER_COMMON(notifierType, notifierArg, notifiee, func, ParamType, ParamArg, BaseClass) \
166 PDECLARE_NOTIFIER_COMMON1(notifierType, notifiee, func, ParamType, BaseClass) \
167 PDECLARE_NOTIFIER_COMMON2(notifierType, notifierArg, notifiee, func, ParamType, ParamArg, BaseClass)
194 #define PDECLARE_NOTIFIER_EXT(notifierType, notifierArg, notifiee, func, ParamType, ParamArg) \
195 PDECLARE_NOTIFIER_COMMON(notifierType, notifierArg, notifiee, func, ParamType, ParamArg, PNotifierFunctionTemplate<ParamType>)
198 #define PDECLARE_NOTIFIER2(notifierType, notifiee, func, ParamType ) \
199 PDECLARE_NOTIFIER_EXT(notifierType, , notifiee, func, ParamType, )
202 #define PDECLARE_NOTIFIER(notifierType, notifiee, func) \
203 PDECLARE_NOTIFIER2(notifierType, notifiee, func, P_INT_PTR)
214 #define PCREATE_NOTIFIER2_EXT(obj, notifiee, func, type) notifiee::func##_PNotifier::Create(obj)
217 #define PCREATE_NOTIFIER_EXT( obj, notifiee, func) notifiee::func##_PNotifier::Create(obj)
228 #define PCREATE_NOTIFIER2(func, type) P_DISABLE_MSVC_WARNINGS(4355, func##_PNotifier::Create(this))
231 #define PCREATE_NOTIFIER(func) P_DISABLE_MSVC_WARNINGS(4355, func##_PNotifier::Create(this))
234 #endif // PTLIB_NOTIFIER_H
PNotifierTemplate(FunctionPtr func=NULL)
Create a new notification function smart pointer.
Definition: notifier.h:117
PNotifierFunctionTemplate(void *target, void *=NULL)
Create a notification function instance.
Definition: notifier.h:65
void * m_target
Object instance to receive the notification function call.
Definition: notifier.h:84
This is the class for pointers to objects that use the smart pointer system.
Definition: smartptr.h:111
virtual void operator()(PObject ¬ifier, ParamType extra) const
Execute the call to the actual notification function on the object instance contained in this object...
Definition: notifier.h:126
virtual void Call(PObject ¬ifier, ParamType extra) const =0
Execute the call to the actual notification function on the object instance contained in this object...
The PNotifier and PNotifierFunction classes build a completely type safe mechanism for calling arbitr...
Definition: notifier.h:109
#define PAssertNULL(ptr)
This macro is used to assert that a pointer must be non-null.
Definition: object.h:428
PNotifierFunctionTemplate< ParamType > * FunctionPtr
Definition: notifier.h:114
virtual void * GetTarget() const
Definition: notifier.h:79
PNotifierTemplate< P_INT_PTR > PNotifier
Definition: notifier.h:145
void * GetTarget() const
Definition: notifier.h:135
This is the base class for objects that use the smart pointer system.
Definition: smartptr.h:49
PNotifierFunctionTemplate< P_INT_PTR > PNotifierFunction
Definition: notifier.h:87
This is an abstract class for which a descendent is declared for every function that may be called...
Definition: notifier.h:59
PSmartObject * GetObject() const
Get the current value if the internal smart object pointer.
Definition: smartptr.h:185
Ultimate parent class for all objects in the class library.
Definition: object.h:2204