OpenWalnut  1.5.0dev
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
WDeferredCallResultEvent< Result > Class Template Reference

Derived WDeferredCallEvent allowing result values in calls. More...

#include <WDeferredCallEvent.h>

+ Inheritance diagram for WDeferredCallResultEvent< Result >:
+ Collaboration diagram for WDeferredCallResultEvent< Result >:

Public Member Functions

 WDeferredCallResultEvent (boost::function< Result(void) > function, Result *result, WCondition::SPtr notify=WCondition::SPtr())
 Constructor. More...
 
virtual ~WDeferredCallResultEvent ()
 Destructor. More...
 
- Public Member Functions inherited from WDeferredCallEventBase
 WDeferredCallEventBase (WCondition::SPtr notify=WCondition::SPtr())
 Constructor. More...
 
virtual ~WDeferredCallEventBase ()
 Destructor. More...
 
void call ()
 Call the function. More...
 
WConditionOneShot::SPtr getDoneCondition () const
 Get the condition that notifies about the finished execution of the specified function. More...
 

Protected Member Functions

virtual void callImpl ()
 Call the function. More...
 

Private Attributes

Result * m_result
 The result. More...
 
boost::function< Result(void) > m_function
 the title of the widget to create More...
 

Additional Inherited Members

- Static Public Attributes inherited from WDeferredCallEventBase
static const QEvent::Type CUSTOM_TYPE = static_cast< QEvent::Type >( WQT_DEFERREDCALL )
 Constant which saves the number used to distinguish this event from other custom events. More...
 
- Protected Attributes inherited from WDeferredCallEventBase
WCondition::SPtr m_callCondition
 Fired whenever the function was called. More...
 

Detailed Description

template<typename Result>
class WDeferredCallResultEvent< Result >

Derived WDeferredCallEvent allowing result values in calls.

Template Parameters
Resultreturn type

Definition at line 108 of file WDeferredCallEvent.h.

Constructor & Destructor Documentation

◆ WDeferredCallResultEvent()

template<typename Result >
WDeferredCallResultEvent< Result >::WDeferredCallResultEvent ( boost::function< Result(void) >  function,
Result *  result,
WCondition::SPtr  notify = WCondition::SPtr() 
)
inline

Constructor.

Parameters
functionthe function to call
resulta pointer to store the result in. Can be NULL if you are not interested in the result. You need to alloc and free it. The reason for using an external pointer is that Qt doc tells us that you loose ownership on QEvents when using QCoreApplication::postEvent. The Event will be deleted after being processed, thus we cannot ensure safe access to members after posting the event.
notifyspecify your own condition to wait for. This is needed since the QApplication doc tells us that ownership of an event is handed over to QT and that it is not save to use the event after posting it. This means we cannot utilize an internal condition in the event as it might be deleted already when calling wait() on it. Do not specify this variable to get a fire-and-forget call.

Definition at line 122 of file WDeferredCallEvent.h.

◆ ~WDeferredCallResultEvent()

template<typename Result >
virtual WDeferredCallResultEvent< Result >::~WDeferredCallResultEvent ( )
inlinevirtual

Destructor.

Definition at line 132 of file WDeferredCallEvent.h.

Member Function Documentation

◆ callImpl()

template<typename Result >
virtual void WDeferredCallResultEvent< Result >::callImpl ( )
inlineprotectedvirtual

Member Data Documentation

◆ m_function

template<typename Result >
boost::function< Result( void ) > WDeferredCallResultEvent< Result >::m_function
private

the title of the widget to create

Definition at line 161 of file WDeferredCallEvent.h.

Referenced by WDeferredCallResultEvent< Result >::callImpl(), and WDeferredCallResultEvent< void >::callImpl().

◆ m_result

template<typename Result >
Result* WDeferredCallResultEvent< Result >::m_result
private

The result.

Definition at line 156 of file WDeferredCallEvent.h.

Referenced by WDeferredCallResultEvent< Result >::callImpl().


The documentation for this class was generated from the following file: