OpendTect-6_4
6.4
|
Inherits NotifierAccess.
Public Member Functions | |
void | trigger (T &t) |
Notifier (T *c) | |
void | trigger (CallBacker *c=0, CallBacker *exclude=0) |
Public Member Functions inherited from NotifierAccess | |
NotifierAccess (const NotifierAccess &) | |
NotifierAccess () | |
virtual | ~NotifierAccess () |
void | notify (const CallBack &, bool first=false) |
bool | notifyIfNotNotified (const CallBack &) |
void | remove (const CallBack &) |
bool | removeWith (CallBacker *, bool wait=true) |
bool | isEnabled () const |
bool | enable (bool yn=true) |
bool | disable () |
bool | isEmpty () const |
bool | willCall (CallBacker *) const |
bool | isShutdownSubscribed (CallBacker *) const |
Only for debugging purposes, don't use. More... | |
Additional Inherited Members | |
Public Attributes inherited from NotifierAccess | |
CallBackSet & | cbs_ |
CallBacker * | cber_ |
Protected Member Functions inherited from NotifierAccess | |
void | addShutdownSubscription (CallBacker *) |
bool | removeShutdownSubscription (CallBacker *, bool wait) |
Static Protected Member Functions inherited from NotifierAccess | |
static void | doTrigger (CallBackSet &, CallBacker *c, CallBacker *exclude) |
Protected Attributes inherited from NotifierAccess | |
ObjectSet< CallBacker > | shutdownsubscribers_ |
Threads::Lock | shutdownsubscriberlock_ |
Class to help setup a callback handling.
What we have discovered is that the two things:
Simply declare a Notifier<T> in the interface, like:
Then users of the class can issue:
The notifier is then attached, the connection will be remove when either the notifier or the called object is deleted.
The callback is issued when you call the trigger() method, like:
The notification can be temporary stopped using disable()/enable() pair, or by use of a NotifyStopper, which automatically restores the callback when going out of scope.
The best practice is to remove the callbacks in the destructor, as otherwise, you may get random crashes. Either, remove them one by one in the destructor, or call detachAllNotifiers(), which will remove notifiers that are attached using the mAttachCB macro.
|
inline |
|
inline |
Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019