OpendTect  6.3
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
CallBack Class Reference

CallBacks object-oriented (object + method). More...

Public Member Functions

 CallBack ()
 
 CallBack (CallBacker *o, CallBackFunction f)
 
 CallBack (StaticCallBackFunction f)
 
bool operator== (const CallBack &) const
 
bool operator!= (const CallBack &cb) const
 
bool willCall () const
 
void doCall (CallBacker *) const
 
bool isDisabled () const
 
void disable (bool yn=true) const
 
void enable () const
 
CallBackercbObj ()
 
const CallBackercbObj () const
 
CallBackFunction cbFn () const
 
StaticCallBackFunction scbFn () const
 

Static Public Member Functions

static void initClass ()
 
static bool addToMainThread (const CallBack &, CallBacker *=0)
 
static bool addToThread (Threads::ThreadID, const CallBack &, CallBacker *=0)
 
static bool callInMainThread (const CallBack &, CallBacker *=0)
 
static void removeFromThreadCalls (const CallBacker *)
 
static bool queueIfNotInMainThread (CallBack, CallBacker *=0)
 
static void removeFromMainThread (const CallBacker *cber)
 

Private Attributes

CallBackercberobj_
 
CallBackFunction fn_
 
StaticCallBackFunction sfn_
 
Threads::Atomic< int > disablecount_
 

Static Private Attributes

static Threads::ThreadID mainthread_
 

Detailed Description

CallBacks object-oriented (object + method).

CallBack is nothing more than a function pointer + optionally an object to call it on. It may be null, in which case doCall() will simply do nothing. If you want to be able to send a CallBack, you must provide a 'sender' CallBacker* (usually 'this').

You can disable a CallBack, but if you do make sure you enable it again using disable(false), as it works with a counter (so that disabling can be nested).

Constructor & Destructor Documentation

CallBack::CallBack ( )
inline
CallBack::CallBack ( CallBacker o,
CallBackFunction  f 
)
inline
CallBack::CallBack ( StaticCallBackFunction  f)
inline

Member Function Documentation

static bool CallBack::addToMainThread ( const CallBack ,
CallBacker = 0 
)
static

Unconditionally add this to main event loop. For thread safety, the removeFromThreadCalls() must be called in the destructor.

static bool CallBack::addToThread ( Threads::ThreadID  ,
const CallBack ,
CallBacker = 0 
)
static

Unconditionally add this to event loop of the other thread. For thread safety, the removeFromThreadCalls() must be called in the destructor.

static bool CallBack::callInMainThread ( const CallBack ,
CallBacker = 0 
)
static

If in main thread or no event-loop is present, it will be called directly. Otherwise, it will be put on event loop. For thread safety, the removeFromThreadCalls() must be called in the destructor.

Returns
true if the callback was called directly.
CallBackFunction CallBack::cbFn ( ) const
inline
CallBacker* CallBack::cbObj ( )
inline
const CallBacker* CallBack::cbObj ( ) const
inline
void CallBack::disable ( bool  yn = true) const
void CallBack::doCall ( CallBacker ) const
void CallBack::enable ( ) const
inline
static void CallBack::initClass ( )
static
bool CallBack::isDisabled ( ) const
inline
bool CallBack::operator!= ( const CallBack cb) const
inline
bool CallBack::operator== ( const CallBack ) const
static bool CallBack::queueIfNotInMainThread ( CallBack  ,
CallBacker = 0 
)
static

If not in main thread, queue it. return whether CB was queued.

static void CallBack::removeFromMainThread ( const CallBacker cber)
inlinestatic
static void CallBack::removeFromThreadCalls ( const CallBacker )
static
StaticCallBackFunction CallBack::scbFn ( ) const
inline
bool CallBack::willCall ( ) const
inline

Member Data Documentation

CallBacker* CallBack::cberobj_
private
Threads::Atomic<int> CallBack::disablecount_
mutableprivate
CallBackFunction CallBack::fn_
private
Threads::ThreadID CallBack::mainthread_
staticprivate
StaticCallBackFunction CallBack::sfn_
private

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