21template <
typename A>
class QList;
22template <
typename A,
typename B>
class QMap;
23template <
typename A,
typename B>
struct QPair;
27 class CubeCachingAlgorithm;
111 CubeIoHandler(QFile * dataFile,
const QList<int> *virtualBandList,
112 const Pvl &label,
bool alreadyOnDisk);
119 void clearCache(
bool blockForWriteCache =
true)
const;
147 void setChunkSizes(
int numSamples,
int numLines,
int numBands);
185 class BufferToChunkWriter :
public QRunnable {
188 QList<Buffer *> buffersToWrite);
189 ~BufferToChunkWriter();
198 BufferToChunkWriter(
const BufferToChunkWriter & other);
204 BufferToChunkWriter & operator=(
const BufferToChunkWriter & rhs);
210 QList<Buffer * > * m_buffersToWrite;
212 QElapsedTimer *m_timer;
232 void blockUntilThreadPoolEmpty()
const;
234 static bool bufferLessThan(
Buffer *
const &lhs,
Buffer *
const &rhs);
236 QPair< QList<RawCubeChunk *>, QList<int> > findCubeChunks(
int startSample,
int numSamples,
237 int startLine,
int numLines,
238 int startBand,
int numBands)
const;
241 const Buffer &cube2,
int &startX,
int &startY,
int &startZ,
242 int &endX,
int &endY,
int &endZ)
const;
244 void flushWriteCache(
bool force =
false)
const;
248 RawCubeChunk *getChunk(
int chunkIndex,
bool allocateIfNecessary)
const;
250 int getChunkCount()
const;
252 void getChunkPlacement(
int chunkIndex,
253 int &startSample,
int &startLine,
int &startBand,
254 int &endSample,
int &endLine,
int &endBand)
const;
258 void minimizeCache(
const QList<RawCubeChunk *> &justUsed,
259 const Buffer &justRequested)
const;
261 void synchronousWrite(
const Buffer &bufferToWrite);
263 void writeIntoDouble(
const RawCubeChunk &chunk,
Buffer &output,
int startIndex)
const;
267 void writeNullDataToDisk()
const;
305 QList<CubeCachingAlgorithm *> * m_cachingAlgorithms;
308 mutable QMap<int, RawCubeChunk *> * m_rawData;
311 mutable QMap<int, bool> * m_dataIsOnDiskMap;
314 QList<int> * m_virtualBands;
317 int m_samplesInChunk;
329 mutable QList<RawCubeChunk *> *m_lastProcessByLineChunks;
332 mutable QByteArray *m_nullChunkData;
335 QPair< QMutex *, QList<Buffer *> > *m_writeCache;
342 mutable QThreadPool *m_ioThreadPool;
348 mutable bool m_lastOperationWasWrite;
353 bool m_useOptimizedCubeWrite;
356 QMutex *m_writeThreadMutex;
359 mutable volatile int m_idealFlushSize;
362 mutable int m_consecutiveOverflowCount;
Buffer for reading and writing cube data.
Definition Buffer.h:53
This is the parent of the caching algorithms.
Definition CubeCachingAlgorithm.h:31
Handles converting buffers to and from disk.
Definition CubeIoHandler.h:109
void clearCache(bool blockForWriteCache=true) const
Free all cube chunks (cached cube data) from memory and write them to disk.
Definition CubeIoHandler.cpp:379
int bandCount() const
Definition CubeIoHandler.cpp:462
virtual ~CubeIoHandler()
Cleans up all allocated memory.
Definition CubeIoHandler.cpp:155
void addCachingAlgorithm(CubeCachingAlgorithm *algorithm)
This will add the given caching algorithm to the list of attempted caching algorithms.
Definition CubeIoHandler.cpp:364
QMutex * dataFileMutex()
Get the mutex that this IO handler is using around I/Os on the given data file.
Definition CubeIoHandler.cpp:455
PixelType pixelType() const
Definition CubeIoHandler.cpp:580
QFile * getDataFile()
Definition CubeIoHandler.cpp:555
int getChunkCountInLineDimension() const
Definition CubeIoHandler.cpp:501
void setChunkSizes(int numSamples, int numLines, int numBands)
This should be called once from the child constructor.
Definition CubeIoHandler.cpp:614
int getLineCountInChunk() const
Definition CubeIoHandler.cpp:572
int getChunkCountInSampleDimension() const
Definition CubeIoHandler.cpp:510
virtual void readRaw(RawCubeChunk &chunkToFill)=0
This needs to populate the chunkToFill with unswapped raw bytes from the disk.
int getChunkCountInBandDimension() const
Definition CubeIoHandler.cpp:492
CubeIoHandler(QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk)
Creates a new CubeIoHandler using a RegionalCachingAlgorithm.
Definition CubeIoHandler.cpp:61
BigInt getBytesPerChunk() const
Definition CubeIoHandler.cpp:482
BigInt getDataStartByte() const
Definition CubeIoHandler.cpp:544
virtual void writeRaw(const RawCubeChunk &chunkToWrite)=0
This needs to write the chunkToWrite directly to disk with no modifications to the data itself.
int sampleCount() const
Definition CubeIoHandler.cpp:589
int lineCount() const
Definition CubeIoHandler.cpp:564
void read(Buffer &bufferToFill) const
Read cube data from disk into the buffer.
Definition CubeIoHandler.cpp:226
void write(const Buffer &bufferToWrite)
Write buffer data into the cube data on disk.
Definition CubeIoHandler.cpp:334
void setVirtualBands(const QList< int > *virtualBandList)
This changes the virtual band list.
Definition CubeIoHandler.cpp:438
virtual void updateLabels(Pvl &labels)=0
Function to update the labels with a Pvl object.
int getSampleCountInChunk() const
Definition CubeIoHandler.cpp:597
BigInt getDataSize() const
Definition CubeIoHandler.cpp:421
int getBandCountInChunk() const
Definition CubeIoHandler.cpp:470
int getChunkIndex(const RawCubeChunk &) const
Given a chunk, what's its index in the file.
Definition CubeIoHandler.cpp:526
Byte swapper.
Definition EndianSwapper.h:38
Container for cube-like labels.
Definition Pvl.h:119
A section of raw data on the disk.
Definition RawCubeChunk.h:27
This is free and unencumbered software released into the public domain.
Definition BoxcarCachingAlgorithm.h:13
This is free and unencumbered software released into the public domain.
Definition CubeIoHandler.h:22
ByteOrder
Tests the current architecture for byte order.
Definition Endian.h:42
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
long long int BigInt
Big int.
Definition Constants.h:49
PixelType
Enumerations for Isis Pixel Types.
Definition PixelType.h:27
This is free and unencumbered software released into the public domain.
Definition CubeIoHandler.h:23