- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions

# QFutureInterface< T > Class Template Reference

Search for all occurrences

## Detailed Description

### template<typename T>
class QFutureInterface< T >

Definition at line 148 of file qfutureinterface.h.

`#include <qfutureinterface.h>`

Inheritance diagram for QFutureInterface< T >:
[legend]

List of all members.

## Public Member Functions
| QFutureInterface (State initialState=NoState)
| QFutureInterface (const QFutureInterface &other)
| ~QFutureInterface ()
QFutureInterface & | operator= (const QFutureInterface &other)
QFuture< T > | future ()
void | reportResult (const T *result, int index=-1)
void | reportResult (const T &result, int index=-1)
void | reportResults (const QVector< T > &results, int beginIndex=-1, int count=-1)
void | reportFinished (const T *result=0)
const T & | resultReference (int index) const
const T * | resultPointer (int index) const
QList< T > | results ()
## Static Public Member Functions
static QFutureInterface | canceledResult ()

## Constructor & Destructor Documentation

QFutureInterface | ( | State | initialState = `NoState` | ) | `[inline]`

Definition at line 151 of file qfutureinterface.h.

            : QFutureInterfaceBase(initialState)
        { }

QFutureInterface | ( | const QFutureInterface< T > & | other | ) | `[inline]`

Definition at line 154 of file qfutureinterface.h.

            : QFutureInterfaceBase(other)
        { }

~QFutureInterface | ( |  | ) | `[inline]`

Definition at line 157 of file qfutureinterface.h.

        {
            if (referenceCountIsOne())
                resultStore().clear();
        }

## Member Function Documentation

static QFutureInterface canceledResult | ( |  | ) | `[inline, static]`

Search for all occurrences

Definition at line 163 of file qfutureinterface.h.

        { return QFutureInterface(State(Started | Finished | Canceled)); }

QFutureInterface& operator= | ( | const QFutureInterface< T > & | other | ) | `[inline]`

Definition at line 166 of file qfutureinterface.h.

        {
            if (referenceCountIsOne())
                resultStore().clear();
            QFutureInterfaceBase::operator=(other);
            return *this;
        }

QFuture< T > future | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 186 of file qfuture.h.

    {
        return QFuture<T>(this);
    }

void reportResult | ( | const T * | result,
|  | int | index = `-1`
| ) |  | `[inline]`

Search for all occurrences

Definition at line 192 of file qfutureinterface.h.

    {
        QMutexLocker locker(mutex());
        if (this->queryState(Canceled) || this->queryState(Finished)) {
            return;
        }

        QtConcurrent::ResultStore<T> &store = resultStore();

        if (store.filterMode()) {
            const int resultCountBefore = store.count();
            store.addResult(index, result);
            this->reportResultsReady(resultCountBefore, resultCountBefore + store.count());
        } else {
            const int insertIndex = store.addResult(index, result);
            this->reportResultsReady(insertIndex, insertIndex + 1);
        }
    }

void reportResult | ( | const T & | result,
|  | int | index = `-1`
| ) |  | `[inline]`

Search for all occurrences

Definition at line 213 of file qfutureinterface.h.

    {
        reportResult(&result, index);
    }

void reportResults | ( | const QVector< T > & | results,
|  | int | beginIndex = `-1`,
|  | int | count = `-1`
| ) |  | `[inline]`

Search for all occurrences

Definition at line 219 of file qfutureinterface.h.

    {
        QMutexLocker locker(mutex());
        if (this->queryState(Canceled) || this->queryState(Finished)) {
            return;
        }

        QtConcurrent::ResultStore<T> &store = resultStore();

        if (store.filterMode()) {
            const int resultCountBefore = store.count();
            store.addResults(beginIndex, &_results, count);
            this->reportResultsReady(resultCountBefore, store.count());
        } else {
            const int insertIndex = store.addResults(beginIndex, &_results, count);
            this->reportResultsReady(insertIndex, insertIndex + _results.count());
        }
    }

void reportFinished | ( | const T * | result = `0` | ) | `[inline]`

Search for all occurrences

Definition at line 239 of file qfutureinterface.h.

    {
        if (result)
            reportResult(result);
        QFutureInterfaceBase::reportFinished();
    }

const T & resultReference | ( | int | index | ) | const `[inline]`

Search for all occurrences

Definition at line 247 of file qfutureinterface.h.

    {
        QMutexLocker lock(mutex());
        return resultStore().resultAt(index).value();
    }

const T * resultPointer | ( | int | index | ) | const `[inline]`

Search for all occurrences

Definition at line 254 of file qfutureinterface.h.

    {
        QMutexLocker lock(mutex());
        return resultStore().resultAt(index).pointer();
    }

QList< T > results | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 261 of file qfutureinterface.h.

    {
        if (this->isCanceled()) {
            exceptionStore().throwPossibleException();
            return QList<T>();
        }
        QFutureInterfaceBase::waitForResult(-1);

        QList<T> res;
        QMutexLocker lock(mutex());

        QtConcurrent::ResultIterator<T> it = resultStore().begin();
        while (it != resultStore().end()) {
            res.append(it.value());
            ++it;
        }

        return res;
    }

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

- QtCore/qfutureinterface.h
- QtCore/qfuture.h