OpendTect-6_4  6.4
Public Member Functions | List of all members
Notifier< T > Class Template Reference

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
CallBackSetcbs_
 
CallBackercber_
 
- 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< CallBackershutdownsubscribers_
 
Threads::Lock shutdownsubscriberlock_
 

Detailed Description

template<class T>
class Notifier< T >

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:

Notifier<MyClass> buttonClicked;

Then users of the class can issue:

mAttachCB( myclass.buttonClicked, TheClassOfThis::theMethodToBeCalle );

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:

buttonClicked.trigger();

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.

Constructor & Destructor Documentation

template<class T>
Notifier< T >::Notifier ( T *  c)
inline

Member Function Documentation

template<class T>
void Notifier< T >::trigger ( T &  t)
inline
template<class T>
void Notifier< T >::trigger ( CallBacker c = 0,
CallBacker exclude = 0 
)
inline

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019