AsyncProgressDialog
Public Types | Public Member Functions | Protected Member Functions | List of all members
APD::FunctionThread< ResultType > Class Template Reference

A thread class, which executes the function provided in the constructor of this class as soon as the thread is started. More...

#include <FunctionThread.h>

Inheritance diagram for APD::FunctionThread< ResultType >:
APD::TaskThread

Public Types

using Function = std::function< ResultType(TaskThread *)>
 Definition of a function to be passed to constructor of this class.
 

Public Member Functions

 FunctionThread (Function func, QObject *parent=nullptr)
 
std::optional< ResultType > result () const
 
- Public Member Functions inherited from APD::TaskThread
 TaskThread (QObject *parent=nullptr)
 
void setRange (int minimum, int maximum)
 
void setValue (int value, const QVariant &userValue=QVariant())
 
void setText (const QString &text)
 
bool isCanceled () const
 

Protected Member Functions

void run () override
 

Additional Inherited Members

- Public Slots inherited from APD::TaskThread
void cancel ()
 
- Signals inherited from APD::TaskThread
void valueChanged (int value, const QVariant &userValue, const TimeStamp &timeStamp)
 
void rangeChanged (int minimum, int maximum)
 
void textChanged (const QString &text)
 

Detailed Description

template<class ResultType>
class APD::FunctionThread< ResultType >

A thread class, which executes the function provided in the constructor of this class as soon as the thread is started.

Template Parameters
ResultTypeThe return value of the function can be accessed using result() method. Note that the result is not ready until the thread finishes.

Constructor & Destructor Documentation

◆ FunctionThread()

template<class ResultType >
APD::FunctionThread< ResultType >::FunctionThread ( Function  func,
QObject *  parent = nullptr 
)
inline

Construct a new function thread. Function func is expected to accept one parameter - a pointer to TaskThread object. It can be used to setup progress range as well as current range value.

Member Function Documentation

◆ result()

template<class ResultType >
std::optional<ResultType> APD::FunctionThread< ResultType >::result ( ) const
inline

Return an object, which has been previously returned by the function passed in the constructor, or std::nullopt if the thread has not finished yet.

◆ run()

template<class ResultType >
void APD::FunctionThread< ResultType >::run ( )
inlineoverrideprotected

Reimplementation of QThread::run()


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