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>
struct QPair;
43 class CubeCachingAlgorithm;
122 const Pvl &label,
bool alreadyOnDisk);
129 void clearCache(
bool blockForWriteCache =
true)
const;
152 void setChunkSizes(
int numSamples,
int numLines,
int numBands);
190 class BufferToChunkWriter :
public QRunnable {
194 ~BufferToChunkWriter();
203 BufferToChunkWriter(
const BufferToChunkWriter & other);
209 BufferToChunkWriter & operator=(
const BufferToChunkWriter & rhs);
237 void blockUntilThreadPoolEmpty()
const;
239 static bool bufferLessThan(
Buffer *
const &lhs,
Buffer *
const &rhs);
242 int startLine,
int numLines,
243 int startBand,
int numBands)
const;
246 const Buffer &cube2,
int &startX,
int &startY,
int &startZ,
247 int &endX,
int &endY,
int &endZ)
const;
249 void flushWriteCache(
bool force =
false)
const;
253 RawCubeChunk *getChunk(
int chunkIndex,
bool allocateIfNecessary)
const;
255 int getChunkCount()
const;
257 void getChunkPlacement(
int chunkIndex,
258 int &startSample,
int &startLine,
int &startBand,
259 int &endSample,
int &endLine,
int &endBand)
const;
264 const Buffer &justRequested)
const;
266 void synchronousWrite(
const Buffer &bufferToWrite);
268 void writeIntoDouble(
const RawCubeChunk &chunk,
Buffer &output,
int startIndex)
const;
272 void writeNullDataToDisk()
const;
322 int m_samplesInChunk;
337 mutable QByteArray *m_nullChunkData;
347 mutable QThreadPool *m_ioThreadPool;
353 mutable bool m_lastOperationWasWrite;
358 bool m_useOptimizedCubeWrite;
361 QMutex *m_writeThreadMutex;
364 mutable volatile int m_idealFlushSize;
367 mutable int m_consecutiveOverflowCount;
Buffer for reading and writing cube data.
Definition: Buffer.h:68
long long int BigInt
Definition: Constants.h:63
void write(const Buffer &bufferToWrite)
Write buffer data into the cube data on disk.
Definition: CubeIoHandler.cpp:354
BigInt getDataStartByte() const
Definition: CubeIoHandler.cpp:567
void addCachingAlgorithm(CubeCachingAlgorithm *algorithm)
This will add the given caching algorithm to the list of attempted caching algorithms.
Definition: CubeIoHandler.cpp:384
void setChunkSizes(int numSamples, int numLines, int numBands)
This should be called once from the child constructor.
Definition: CubeIoHandler.cpp:637
BigInt getBytesPerChunk() const
Definition: CubeIoHandler.cpp:502
virtual void readRaw(RawCubeChunk &chunkToFill)=0
This needs to populate the chunkToFill with unswapped raw bytes from the disk.
int sampleCount() const
Definition: CubeIoHandler.cpp:612
QMutex * dataFileMutex()
Get the mutex that this IO handler is using around I/Os on the given data file.
Definition: CubeIoHandler.cpp:475
void read(Buffer &bufferToFill) const
Read cube data from disk into the buffer.
Definition: CubeIoHandler.cpp:246
virtual void writeRaw(const RawCubeChunk &chunkToWrite)=0
This needs to write the chunkToWrite directly to disk with no modifications to the data itself...
ByteOrder
Tests the current architecture for byte order.
Definition: Endian.h:59
int bandCount() const
Definition: CubeIoHandler.cpp:482
virtual ~CubeIoHandler()
Cleans up all allocated memory.
Definition: CubeIoHandler.cpp:173
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:43
Handles converting buffers to and from disk.
Definition: CubeIoHandler.h:119
CubeIoHandler(QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk)
Creates a new CubeIoHandler using a RegionalCachingAlgorithm.
Definition: CubeIoHandler.cpp:79
int getLineCountInChunk() const
Definition: CubeIoHandler.cpp:595
int getChunkIndex(const RawCubeChunk &) const
Given a chunk, what's its index in the file.
Definition: CubeIoHandler.cpp:546
int getChunkCountInBandDimension() const
Definition: CubeIoHandler.cpp:512
QFile * getDataFile()
Definition: CubeIoHandler.cpp:578
virtual void updateLabels(Pvl &labels)=0
BigInt getDataSize() const
Definition: CubeIoHandler.cpp:441
A section of raw data on the disk.
Definition: RawCubeChunk.h:42
Byte swapper.
Definition: EndianSwapper.h:54
void clearCache(bool blockForWriteCache=true) const
Free all cube chunks (cached cube data) from memory and write them to disk.
Definition: CubeIoHandler.cpp:399
void setVirtualBands(const QList< int > *virtualBandList)
This changes the virtual band list.
Definition: CubeIoHandler.cpp:458
Container for cube-like labels.
Definition: Pvl.h:135
int getChunkCountInSampleDimension() const
Definition: CubeIoHandler.cpp:530
int lineCount() const
Definition: CubeIoHandler.cpp:587
PixelType pixelType() const
Definition: CubeIoHandler.cpp:603
Definition: BoxcarCachingAlgorithm.h:29
int getChunkCountInLineDimension() const
Definition: CubeIoHandler.cpp:521
int getSampleCountInChunk() const
Definition: CubeIoHandler.cpp:620
int getBandCountInChunk() const
Definition: CubeIoHandler.cpp:490
Definition: CubeIoHandler.h:39
This is the parent of the caching algorithms.
Definition: CubeCachingAlgorithm.h:47
Definition: CubeIoHandler.h:38