Qt 4.8
Public Functions | Static Public Functions | Private Functions | List of all members
QFutureInterface< T > Class Template Reference

#include <qfutureinterface.h>

Inheritance diagram for QFutureInterface< T >:
QFutureInterfaceBase

Public Functions

QFuture< T > future ()
 
QFutureInterfaceoperator= (const QFutureInterface &other)
 
 QFutureInterface (State initialState=NoState)
 
 QFutureInterface (const QFutureInterface &other)
 
void reportFinished (const T *result=0)
 
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)
 
const T * resultPointer (int index) const
 
const T & resultReference (int index) const
 
QList< T > results ()
 
 ~QFutureInterface ()
 
- Public Functions inherited from QFutureInterfaceBase
void cancel ()
 
QtConcurrent::internal::ExceptionStoreexceptionStore ()
 
int expectedResultCount ()
 
bool isCanceled () const
 
bool isFinished () const
 
bool isPaused () const
 
bool isProgressUpdateNeeded () const
 
bool isResultReadyAt (int index) const
 
bool isRunning () const
 
bool isStarted () const
 
bool isThrottled () const
 
QMutexmutex () const
 
bool operator!= (const QFutureInterfaceBase &other) const
 
QFutureInterfaceBaseoperator= (const QFutureInterfaceBase &other)
 
bool operator== (const QFutureInterfaceBase &other) const
 
int progressMaximum () const
 
int progressMinimum () const
 
QString progressText () const
 
int progressValue () const
 
 QFutureInterfaceBase (State initialState=NoState)
 
 QFutureInterfaceBase (const QFutureInterfaceBase &other)
 
bool queryState (State state) const
 
void reportCanceled ()
 
void reportException (const QtConcurrent::Exception &e)
 
void reportFinished ()
 
void reportResultsReady (int beginIndex, int endIndex)
 
void reportStarted ()
 
int resultCount () const
 
QtConcurrent::ResultStoreBase & resultStoreBase ()
 
const QtConcurrent::ResultStoreBase & resultStoreBase () const
 
void setExpectedResultCount (int resultCount)
 
void setFilterMode (bool enable)
 
void setPaused (bool paused)
 
void setProgressRange (int minimum, int maximum)
 
void setProgressValue (int progressValue)
 
void setProgressValueAndText (int progressValue, const QString &progressText)
 
void setRunnable (QRunnable *runnable)
 
void setThrottled (bool enable)
 
void togglePaused ()
 
void waitForFinished ()
 
bool waitForNextResult ()
 
void waitForResult (int resultIndex)
 
void waitForResume ()
 
virtual ~QFutureInterfaceBase ()
 

Static Public Functions

static QFutureInterface canceledResult ()
 

Private Functions

QtConcurrent::ResultStore< T > & resultStore ()
 
const QtConcurrent::ResultStore< T > & resultStore () const
 

Additional Inherited Members

- Public Types inherited from QFutureInterfaceBase
enum  State {
  NoState = 0x00, Running = 0x01, Started = 0x02, Finished = 0x04,
  Canceled = 0x08, Paused = 0x10, Throttled = 0x20
}
 
- Protected Functions inherited from QFutureInterfaceBase
bool referenceCountIsOne () const
 

Detailed Description

template<typename T>
class QFutureInterface< T >

Definition at line 148 of file qfutureinterface.h.

Constructors and Destructors

◆ QFutureInterface() [1/2]

template<typename T>
QFutureInterface< T >::QFutureInterface ( State  initialState = NoState)
inline

Definition at line 151 of file qfutureinterface.h.

152  : QFutureInterfaceBase(initialState)
153  { }
QFutureInterfaceBase(State initialState=NoState)

◆ QFutureInterface() [2/2]

template<typename T>
QFutureInterface< T >::QFutureInterface ( const QFutureInterface< T > &  other)
inline

Definition at line 154 of file qfutureinterface.h.

155  : QFutureInterfaceBase(other)
156  { }
QFutureInterfaceBase(State initialState=NoState)

◆ ~QFutureInterface()

template<typename T>
QFutureInterface< T >::~QFutureInterface ( )
inline

Definition at line 157 of file qfutureinterface.h.

158  {
159  if (referenceCountIsOne())
160  resultStore().clear();
161  }
bool referenceCountIsOne() const
QtConcurrent::ResultStore< T > & resultStore()

Functions

◆ canceledResult()

template<typename T>
static QFutureInterface QFutureInterface< T >::canceledResult ( )
inlinestatic

◆ future()

template<typename T >
QFuture< T > QFutureInterface< T >::future ( )
inline

Definition at line 186 of file qfuture.h.

187 {
188  return QFuture<T>(this);
189 }
The QFuture class represents the result of an asynchronous computation.
Definition: qfuture.h:64

◆ operator=()

template<typename T>
QFutureInterface& QFutureInterface< T >::operator= ( const QFutureInterface< T > &  other)
inline

Definition at line 166 of file qfutureinterface.h.

167  {
168  if (referenceCountIsOne())
169  resultStore().clear();
171  return *this;
172  }
bool referenceCountIsOne() const
QtConcurrent::ResultStore< T > & resultStore()
QFutureInterfaceBase & operator=(const QFutureInterfaceBase &other)

◆ reportFinished()

template<typename T >
void QFutureInterface< T >::reportFinished ( const T *  result = 0)
inline

Definition at line 239 of file qfutureinterface.h.

240 {
241  if (result)
242  reportResult(result);
244 }
void reportResult(const T *result, int index=-1)

◆ reportResult() [1/2]

template<typename T >
void QFutureInterface< T >::reportResult ( const T *  result,
int  index = -1 
)
inline

Definition at line 192 of file qfutureinterface.h.

193 {
194  QMutexLocker locker(mutex());
195  if (this->queryState(Canceled) || this->queryState(Finished)) {
196  return;
197  }
198 
199  QtConcurrent::ResultStore<T> &store = resultStore();
200 
201 
202  if (store.filterMode()) {
203  const int resultCountBefore = store.count();
204  store.addResult(index, result);
205  this->reportResultsReady(resultCountBefore, resultCountBefore + store.count());
206  } else {
207  const int insertIndex = store.addResult(index, result);
208  this->reportResultsReady(insertIndex, insertIndex + 1);
209  }
210 }
bool queryState(State state) const
QMutex * mutex() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
#define store(x)
QtConcurrent::ResultStore< T > & resultStore()
quint16 index
void reportResultsReady(int beginIndex, int endIndex)

◆ reportResult() [2/2]

template<typename T >
void QFutureInterface< T >::reportResult ( const T &  result,
int  index = -1 
)
inline

Definition at line 213 of file qfutureinterface.h.

214 {
215  reportResult(&result, index);
216 }
void reportResult(const T *result, int index=-1)
quint16 index

◆ reportResults()

template<typename T >
void QFutureInterface< T >::reportResults ( const QVector< T > &  results,
int  beginIndex = -1,
int  count = -1 
)
inline

Definition at line 219 of file qfutureinterface.h.

220 {
221  QMutexLocker locker(mutex());
222  if (this->queryState(Canceled) || this->queryState(Finished)) {
223  return;
224  }
225 
226  QtConcurrent::ResultStore<T> &store = resultStore();
227 
228  if (store.filterMode()) {
229  const int resultCountBefore = store.count();
230  store.addResults(beginIndex, &_results, count);
231  this->reportResultsReady(resultCountBefore, store.count());
232  } else {
233  const int insertIndex = store.addResults(beginIndex, &_results, count);
234  this->reportResultsReady(insertIndex, insertIndex + _results.count());
235  }
236 }
bool queryState(State state) const
QMutex * mutex() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
#define store(x)
QtConcurrent::ResultStore< T > & resultStore()
void reportResultsReady(int beginIndex, int endIndex)

◆ resultPointer()

template<typename T >
const T * QFutureInterface< T >::resultPointer ( int  index) const
inline

Definition at line 254 of file qfutureinterface.h.

255 {
257  return resultStore().resultAt(index).pointer();
258 }
QMutex * mutex() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QtConcurrent::ResultStore< T > & resultStore()
static QReadWriteLock lock
Definition: proxyconf.cpp:399
quint16 index

◆ resultReference()

template<typename T >
const T & QFutureInterface< T >::resultReference ( int  index) const
inline

Definition at line 247 of file qfutureinterface.h.

248 {
250  return resultStore().resultAt(index).value();
251 }
QMutex * mutex() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QtConcurrent::ResultStore< T > & resultStore()
static QReadWriteLock lock
Definition: proxyconf.cpp:399
quint16 index

◆ results()

template<typename T >
QList< T > QFutureInterface< T >::results ( )
inline

Definition at line 261 of file qfutureinterface.h.

262 {
263  if (this->isCanceled()) {
265  return QList<T>();
266  }
268 
269  QList<T> res;
271 
272  QtConcurrent::ResultIterator<T> it = resultStore().begin();
273  while (it != resultStore().end()) {
274  res.append(it.value());
275  ++it;
276  }
277 
278  return res;
279 }
#define it(className, varName)
QtConcurrent::internal::ExceptionStore & exceptionStore()
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QMutex * mutex() const
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QtConcurrent::ResultStore< T > & resultStore()
static QReadWriteLock lock
Definition: proxyconf.cpp:399
void waitForResult(int resultIndex)
static const KeyPair *const end
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ resultStore() [1/2]

template<typename T>
QtConcurrent::ResultStore<T>& QFutureInterface< T >::resultStore ( )
inlineprivate

Definition at line 185 of file qfutureinterface.h.

186  { return static_cast<QtConcurrent::ResultStore<T> &>(resultStoreBase()); }
QtConcurrent::ResultStoreBase & resultStoreBase()

◆ resultStore() [2/2]

template<typename T>
const QtConcurrent::ResultStore<T>& QFutureInterface< T >::resultStore ( ) const
inlineprivate

Definition at line 187 of file qfutureinterface.h.

188  { return static_cast<const QtConcurrent::ResultStore<T> &>(resultStoreBase()); }
QtConcurrent::ResultStoreBase & resultStoreBase()

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