notifier.h
Go to the documentation of this file.00001
#ifndef _PNOTIFIER_H
00002
#define _PNOTIFIER_H
00003
00004
#include <ptlib.h>
00005
#include <ptlib/smartptr.h>
00006
00008
00009
00034 class PNotifierFunction :
public PSmartObject
00035 {
00036
PCLASSINFO(
PNotifierFunction,
PSmartObject);
00037
00038
public:
00040 PNotifierFunction(
00041
void * obj
00042 ) {
object =
PAssertNULL(obj); }
00043
00047
virtual void Call(
00048
PObject & notifier,
00049 INT extra
00050 )
const = 0;
00051
00052
protected:
00053
00055 void *
object;
00056 };
00057
00058
00079 class PNotifier :
public PSmartPointer
00080 {
00081
PCLASSINFO(
PNotifier,
PSmartPointer);
00082
00083
public:
00085 PNotifier(
00086
PNotifierFunction * func = NULL
00087 ) :
PSmartPointer(func) { }
00088
00094 virtual void operator()(
00095
PObject & notifier,
00096 INT extra
00097 )
const {((
PNotifierFunction*)
PAssertNULL(object))->Call(notifier,extra);}
00098 };
00099
00100
00124 #define PDECLARE_NOTIFIER(notifier, notifiee, func) \
00125
class func##_PNotifier : public PNotifierFunction { \
00126
public: \
00127
func##_PNotifier(notifiee * obj) : PNotifierFunction(obj) { } \
00128
virtual void Call(PObject & note, INT extra) const \
00129
{ ((notifiee*)object)->func((notifier &)note, extra); } \
00130
}; \
00131
friend class func##_PNotifier; \
00132
virtual void func(notifier & note, INT extra)
00133
00142 #define PCREATE_NOTIFIER2(obj, func) PNotifier(new func##_PNotifier(obj))
00143
00152 #define PCREATE_NOTIFIER(func) PCREATE_NOTIFIER2(this, func)
00153
00154
#endif
00155
Generated on Sat Jul 24 15:35:56 2004 for PWLib by
1.3.7