24 #ifndef CubeIoHandler_h
25 #define CubeIoHandler_h
28 #include <QThreadPool>
37 template <
typename A>
class QList;
38 template <
typename A,
typename B>
class QMap;
39 template <
typename A,
typename B>
class QPair;
43 class CubeCachingAlgorithm;
118 const Pvl &label,
bool alreadyOnDisk);
125 void clearCache(
bool blockForWriteCache =
true)
const;
148 void setChunkSizes(
int numSamples,
int numLines,
int numBands);
186 class BufferToChunkWriter :
public QRunnable {
190 ~BufferToChunkWriter();
199 BufferToChunkWriter(
const BufferToChunkWriter & other);
205 BufferToChunkWriter & operator=(
const BufferToChunkWriter & rhs);
233 void blockUntilThreadPoolEmpty()
const;
235 static bool bufferLessThan(
Buffer *
const &lhs,
Buffer *
const &rhs);
238 int startLine,
int numLines,
239 int startBand,
int numBands)
const;
242 const Buffer &cube2,
int &startX,
int &startY,
int &startZ,
243 int &endX,
int &endY,
int &endZ)
const;
245 void flushWriteCache(
bool force =
false)
const;
249 RawCubeChunk *getChunk(
int chunkIndex,
bool allocateIfNecessary)
const;
251 int getChunkCount()
const;
253 void getChunkPlacement(
int chunkIndex,
254 int &startSample,
int &startLine,
int &startBand,
255 int &endSample,
int &endLine,
int &endBand)
const;
260 const Buffer &justRequested)
const;
262 void synchronousWrite(
const Buffer &bufferToWrite);
264 void writeIntoDouble(
const RawCubeChunk &chunk,
Buffer &output,
int startIndex)
const;
268 void writeNullDataToDisk()
const;
318 int m_samplesInChunk;
333 mutable QByteArray *m_nullChunkData;
343 mutable QThreadPool *m_ioThreadPool;
349 mutable bool m_lastOperationWasWrite;
354 bool m_useOptimizedCubeWrite;
357 QMutex *m_writeThreadMutex;
360 mutable volatile int m_idealFlushSize;
363 mutable int m_consecutiveOverflowCount;