notifier.h File Reference

#include <ptlib.h>
#include <ptlib/smartptr.h>

Go to the source code of this file.

Classes

class  PNotifierFunctionTemplate< ParmType >
 This is an abstract class for which a descendent is declared for every function that may be called. More...
class  PNotifierTemplate< ParmType >
 The PNotifier and PNotifierFunction classes build a completely type safe mechanism for calling arbitrary member functions on classes. More...

Defines

#define PDECLARE_NOTIFIER2(notifier, notifiee, func, type)
 Declare a notifier object class.
#define PDECLARE_NOTIFIER(notifier, notifiee, func)   PDECLARE_NOTIFIER2(notifier, notifiee, func, INT)
 Declare PNotifier derived class with INT parameter. Uses PDECLARE_NOTIFIER2 macro.
#define PCREATE_NOTIFIER2_EXT(obj, notifiee, func, type)   PNotifierTemplate<type>(new notifiee::func##_PNotifier(obj))
 Create a PNotifier object instance.
#define PCREATE_NOTIFIER_EXT(obj, notifiee, func)   PCREATE_NOTIFIER2_EXT(obj, notifiee, func, INT)
 Create PNotifier object instance with INT parameter. Uses PCREATE_NOTIFIER2_EXT macro.
#define PCREATE_NOTIFIER2(func, type)   PNotifierTemplate<type>(new func##_PNotifier(this))
 Create a PNotifier object instance.
#define PCREATE_NOTIFIER(func)   PCREATE_NOTIFIER2(func, INT)
 Create PNotifier object instance with INT parameter. Uses PCREATE_NOTIFIER2 macro.

Typedefs

typedef PNotifierFunctionTemplate<
INT > 
PNotifierFunction
typedef PNotifierTemplate<
INT > 
PNotifier


Define Documentation

#define PCREATE_NOTIFIER ( func   )     PCREATE_NOTIFIER2(func, INT)

Create PNotifier object instance with INT parameter. Uses PCREATE_NOTIFIER2 macro.

#define PCREATE_NOTIFIER2 ( func,
type   )     PNotifierTemplate<type>(new func##_PNotifier(this))

Create a PNotifier 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_NOTIFIER_EXT macro may be used if the instance to be called is not the current object instance.

#define PCREATE_NOTIFIER2_EXT ( obj,
notifiee,
func,
type   )     PNotifierTemplate<type>(new notifiee::func##_PNotifier(obj))

Create a PNotifier 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 if obj is this then the PCREATE_NOTIFIER macro should be used.

#define PCREATE_NOTIFIER_EXT ( obj,
notifiee,
func   )     PCREATE_NOTIFIER2_EXT(obj, notifiee, func, INT)

Create PNotifier object instance with INT parameter. Uses PCREATE_NOTIFIER2_EXT macro.

#define PDECLARE_NOTIFIER ( notifier,
notifiee,
func   )     PDECLARE_NOTIFIER2(notifier, notifiee, func, INT)

Declare PNotifier derived class with INT parameter. Uses PDECLARE_NOTIFIER2 macro.

#define PDECLARE_NOTIFIER2 ( notifier,
notifiee,
func,
type   ) 

Value:

class func##_PNotifier : public PNotifierFunctionTemplate<type> { \
    public: \
      func##_PNotifier(notifiee * obj) : PNotifierFunctionTemplate<type>(obj) { } \
      virtual void Call(PObject & note, type extra) const \
        { ((notifiee*)object)->func((notifier &)note, extra); } \
  }; \
  friend class func##_PNotifier; \
  virtual void func(notifier & note, type extra)
Declare a notifier object class.

This macro declares the descendent class of PNotifierFunction that will be used in instances of PNotifier created by the PCREATE_NOTIFIER or PCREATE_NOTIFIER2 macros.

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:


      void func(notifier & n, INT extra)     // for PNOTIFIER
      void func(notifier & n, void * extra)  // for PNOTIFIER2

The implementation of the function is left for the user.


Typedef Documentation

typedef PNotifierTemplate<INT> PNotifier

typedef PNotifierFunctionTemplate<INT> PNotifierFunction


Generated on Fri Oct 14 01:44:10 2011 for PTLib by  doxygen 1.4.7