MeVisLabToolboxReference
ml::MessagingBackgroundTask Class Reference

MessagingBackgroundTask extends the BackgroundTask with the functionality to call methods on DistantObject instances on the GUI thread to communicate with the GUI (e.g. More...

#include <mlMessagingBackgroundTask.h>

Inheritance diagram for ml::MessagingBackgroundTask:
ml::BackgroundTask ml::ImagingBackgroundTask ml::ModuleBackgroundTask ml::ProcessAllPagesBackgroundTask

List of all members.

Public Member Functions

 MessagingBackgroundTask (void *owner)
Calling methods on DistantObjects in the GUI thread
template<typename Object , typename Method >
void callMethodOnGUI (const DistantObject< Object > &target, Method method)
template<typename Object , typename Method , typename Arg1 >
void callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1)
template<typename Object , typename Method , typename Arg1 , typename Arg2 >
void callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1, const Arg2 &arg2)
template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 >
void callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 >
void callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 >
void callMethodOnGUI (const DistantObject< Object > &target, Method method, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)

Detailed Description

MessagingBackgroundTask extends the BackgroundTask with the functionality to call methods on DistantObject instances on the GUI thread to communicate with the GUI (e.g.

send some intermediate result to the GUI).

Definition at line 30 of file mlMessagingBackgroundTask.h.


Constructor & Destructor Documentation

ml::MessagingBackgroundTask::MessagingBackgroundTask ( void *  owner) [inline]

Definition at line 35 of file mlMessagingBackgroundTask.h.


Member Function Documentation

template<typename Object , typename Method >
void ml::MessagingBackgroundTask::callMethodOnGUI ( const DistantObject< Object > &  target,
Method  method 
) [inline]

callMethodOnGUI() can call any non-static member method on the instance of T that is stored in a DistantObject<T> with up to 5 arguments, the arguments are copies so that values that you pass need to be copyable. You should be very careful when you pass pointers since the ownership stays with the caller and you can not easily know when it is safe to delete the pointer. The call is send to the GUI thread and executed there.

The example shows how to send an intermediate Matrix4 result to a MatrixField in the GUI thread:

  class MyBackgroundTask {
    MyBackgroundTask(void* owner, MatrixField* field)
     :MessagingBackgroundTask(owner),
      _field(field) {}

    virtual void run() {
      ...
      Matrix4 someIntermediateResult;
      ...
      // Note the &MatrixField::setMat4Value syntax to get a pointer to the member function
      callMethodOnGUI(_field, &MatrixField::setMat4Value, someIntermediateResult);
      ...
    }

    private:
      DistantObject<MatrixField> _field;
  };

Typically you will either pass the pointer to your derived Module and store it as a DistantObject, or alternatively you can pass individual fields and store them in their own DistantObjects.

Definition at line 78 of file mlMessagingBackgroundTask.h.

References ml::NewBackgroundTaskMethodCall(), and ml::BackgroundTask::sendMessageToGUI().

template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 >
void ml::MessagingBackgroundTask::callMethodOnGUI ( const DistantObject< Object > &  target,
Method  method,
const Arg1 &  arg1,
const Arg2 &  arg2,
const Arg3 &  arg3,
const Arg4 &  arg4,
const Arg5 &  arg5 
) [inline]
template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 >
void ml::MessagingBackgroundTask::callMethodOnGUI ( const DistantObject< Object > &  target,
Method  method,
const Arg1 &  arg1,
const Arg2 &  arg2,
const Arg3 &  arg3,
const Arg4 &  arg4 
) [inline]
template<typename Object , typename Method , typename Arg1 , typename Arg2 , typename Arg3 >
void ml::MessagingBackgroundTask::callMethodOnGUI ( const DistantObject< Object > &  target,
Method  method,
const Arg1 &  arg1,
const Arg2 &  arg2,
const Arg3 &  arg3 
) [inline]
template<typename Object , typename Method , typename Arg1 , typename Arg2 >
void ml::MessagingBackgroundTask::callMethodOnGUI ( const DistantObject< Object > &  target,
Method  method,
const Arg1 &  arg1,
const Arg2 &  arg2 
) [inline]
template<typename Object , typename Method , typename Arg1 >
void ml::MessagingBackgroundTask::callMethodOnGUI ( const DistantObject< Object > &  target,
Method  method,
const Arg1 &  arg1 
) [inline]

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