QFutureInterface< T > Class Template Reference

QFutureInterface< T > Class Template Reference

#include <qfutureinterface.h>

Class Description

template<typename T>
class QFutureInterface< T >

Definition at line 148 of file qfutureinterface.h.

+ Inheritance diagram for QFutureInterface< T >:

Public Member Functions

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

Static Public Member Functions

static QFutureInterface canceledResult ()
 

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 Member Functions inherited from QFutureInterfaceBase
bool referenceCountIsOne () const
 

Constructor & Destructor Documentation

QFutureInterface ( State  initialState = NoState)
inline

Definition at line 151 of file qfutureinterface.h.

152  : QFutureInterfaceBase(initialState)
153  { }
QFutureInterfaceBase(State initialState=NoState)
QFutureInterface ( const QFutureInterface< T > &  other)
inline

Definition at line 154 of file qfutureinterface.h.

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

Definition at line 157 of file qfutureinterface.h.

158  {
159  if (referenceCountIsOne())
160  resultStore().clear();
161  }
bool referenceCountIsOne() const

Member Function Documentation

QFutureInterface& 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  }
QFutureInterfaceBase & operator=(const QFutureInterfaceBase &other)
bool referenceCountIsOne() const
QFuture< T > future ( )
inline

Definition at line 186 of file qfuture.h.

187 {
188  return QFuture<T>(this);
189 }
void 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 }
int addResult(int index, const T *result)
void reportResultsReady(int beginIndex, int endIndex)
QMutex * mutex() const
bool queryState(State state) const
GLuint index
Definition: GLee.h:1704
void 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)
GLuint index
Definition: GLee.h:1704
void 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 }
void reportResultsReady(int beginIndex, int endIndex)
QMutex * mutex() const
int addResults(int index, const QVector< T > *results)
GLuint GLuint GLsizei count
Definition: GLee.h:872
bool queryState(State state) const
void 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)
const T & resultReference ( int  index) const
inline

Definition at line 247 of file qfutureinterface.h.

248 {
249  QMutexLocker lock(mutex());
250  return resultStore().resultAt(index).value();
251 }
QMutex * mutex() const
GLuint index
Definition: GLee.h:1704
const T * resultPointer ( int  index) const
inline

Definition at line 254 of file qfutureinterface.h.

255 {
256  QMutexLocker lock(mutex());
257  return resultStore().resultAt(index).pointer();
258 }
QMutex * mutex() const
GLuint index
Definition: GLee.h:1704
QList< 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;
270  QMutexLocker lock(mutex());
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 }
bool isCanceled() const
void waitForResult(int resultIndex)
GLuint res
Definition: GLee.h:7185
QtConcurrent::internal::ExceptionStore & exceptionStore()
QMutex * mutex() const
GLuint GLuint end
Definition: GLee.h:872
void append(const T &t)
Definition: qlist.h:507

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