mrnotify__define.pro
mrNotify
Methods:
Constructor and init
mrNotify::init : constructor, no arguments
User part (public)
mrNotify::notify : register an external object for notification
mrNotify::enableNotify : switch on notification (default!)
mrNotify::disableNotify : switch off notification
Class part (protected)
mrNotify::setEvtTypes : set available event types (string array)
mrNotify::sendNotification : send the notification message
Private functions
mrNotify::evtBitmap : creates bitmap from event string array
mrNotify__define : the constructor
mrNotify::cleanup : the destructor
Description:
Implements a simple notification mechanism. Classes implementing this
mechanism should subclass from mrNotify.
Notifications send by mrNotify have either two or three arguments
of the form
pro some_other_class::notificationHandler, sender, event_type, evt
where sender is an object reference to the sending obejct, event_type
a string, e.g. 'add' or 'delete' in mrContainer, and the optional
argument evt a pointer to an event structure defined by the implementing
superclass.
mrNotify::init
Syntax:
obj = obj_new('mrNotify', evtTypes)
Arguments:
evtTypes
A string or array of strings holding the available event types
(e.g. ['add','remove','move'] for a container class.
Description:
s.a.
Notification is switched on by default.
mrNotify::cleanup
Description:
Free allocated memory
mrNotify::setEvtTypes
Syntax:
deprecated!
Description:
As setting the event types should be called only once, it is now
included in the constructor. The method is only kept for compatibility
reasons, but is deprecated and will be removed sooner or later.
mrNotify::notify
Syntax:
obj->notify, object, method, event, /remove, /all
Arguments:
object
The object to be notified
method
A string holding the object's method name to call
event
A string or string array specifying the events upon which to send
a notification event. The list of possible events is set via
will specify their specific event types - see the documentation of
the respective classes.
remove
If set, remove all instances of the specified object or object/method
combination from the notification list.
all
Only meaningful in combination with remove, in which case the
internal notification list is cleared.
Description:
Objects are notified in arbitrary order, there's no guarantee that
objects which register first are notified first. If an object
registers multiple times for notification, it will be notified
multiple times.
The registered method is called with two or three arguments: an
object reference of the calling object (i.e. self), a string denoting
the event type and optionally a pointer to a class specific event
structure. Again see the subclass documentation.
mrNotify::sendNotification
Syntax:
self->sendNotification, evtType, evt
Arguments:
evtType
Case insensitive string - one of the event types as set in
evt
Pointer to an individual event structure which is passed as third
argument. If not present, it is omitted.
Description:
Sends a notification event to objects which registered for the
specified event type. A notification call has the arguments
sender, event_type, evt
Where sender is the object that sends the notification (i.e. self),
event_type a string denoting the event and evt, if present, a user-
definable pointer to an event structure.
Known bugs:
If an object is removed from the internal list this is not considered
within the current call-back loop.
mrNotify::enableNotify
Syntax:
obj->enableNotify
Description:
Switches on notification
mrNotify::disableNotify
Syntax:
obj->disableNotify
Description:
Switches off notification
mrNotify::evtBitmap
Syntax:
obj->evtBitmap
Description:
Turns a string array into a bitmap for easier and faster storage/comparison
mrNotify__define
Description:
The constructor.