#include <ptlib.h>
#include <ptlib/smartptr.h>
Go to the source code of this file.
Classes | |
class | PNotifierFunction |
class | PNotifier |
Defines | |
#define | PDECLARE_NOTIFIER(notifier, notifiee, func) |
#define | PCREATE_NOTIFIER2(obj, func) PNotifier(new func##_PNotifier(obj)) |
#define | PCREATE_NOTIFIER(func) PCREATE_NOTIFIER2(this, func) |
#define PCREATE_NOTIFIER | ( | func | ) | PCREATE_NOTIFIER2(this, func) |
Create a notifier object instance. This macro creates an instance of the particular PNotifier# class using the func# parameter as the member function to call.
The this# object is used as the instance to call the function against. The PCREATE_NOTIFIER2# macro may be used if the instance to be called is not the current object instance.
#define PCREATE_NOTIFIER2 | ( | obj, | |||
func | ) | PNotifier(new func##_PNotifier(obj)) |
Create a notifier object instance. This macro creates an instance of the particular PNotifier# class using the func# parameter as the member function to call.
The obj# parameter is the instance to call the function against. If the instance to be called is the current instance, ie obj# is to this# the the PCREATE_NOTIFIER# macro should be used.
#define PDECLARE_NOTIFIER | ( | notifier, | |||
notifiee, | |||||
func | ) |
Value:
class func##_PNotifier : public PNotifierFunction { \ public: \ func##_PNotifier(notifiee * obj) : PNotifierFunction(obj) { } \ virtual void Call(PObject & note, INT extra) const \ { ((notifiee*)object)->func((notifier &)note, extra); } \ }; \ friend class func##_PNotifier; \ virtual void func(notifier & note, INT extra)
The macro is expected to be used inside a class declaration. The class it declares will therefore be a nested class within the class being declared. The name of the new nested class is derived from the member function name which should guarentee the class names are unique.
The notifier# parameter is the class of the function that will be calling the notification function. The notifiee# parameter is the class to which the called member function belongs. Finally the func# parameter is the name of the member function to be declared.
This macro will also declare the member function itself. This will be: {verbatim} void func(notifier & n, INT extra) {verbatim}
The implementation of the function is left for the user.