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;
128 const Pvl &label,
bool alreadyOnDisk);
135 void clearCache(
bool blockForWriteCache =
true)
const;
163 void setChunkSizes(
int numSamples,
int numLines,
int numBands);
201 class BufferToChunkWriter :
public QRunnable {
205 ~BufferToChunkWriter();
214 BufferToChunkWriter(
const BufferToChunkWriter & other);
220 BufferToChunkWriter & operator=(
const BufferToChunkWriter & rhs);
248 void blockUntilThreadPoolEmpty()
const;
250 static bool bufferLessThan(
Buffer *
const &lhs,
Buffer *
const &rhs);
253 int startLine,
int numLines,
254 int startBand,
int numBands)
const;
257 const Buffer &cube2,
int &startX,
int &startY,
int &startZ,
258 int &endX,
int &endY,
int &endZ)
const;
260 void flushWriteCache(
bool force =
false)
const;
264 RawCubeChunk *getChunk(
int chunkIndex,
bool allocateIfNecessary)
const;
266 int getChunkCount()
const;
268 void getChunkPlacement(
int chunkIndex,
269 int &startSample,
int &startLine,
int &startBand,
270 int &endSample,
int &endLine,
int &endBand)
const;
275 const Buffer &justRequested)
const;
277 void synchronousWrite(
const Buffer &bufferToWrite);
279 void writeIntoDouble(
const RawCubeChunk &chunk,
Buffer &output,
int startIndex)
const;
283 void writeNullDataToDisk()
const;
333 int m_samplesInChunk;
348 mutable QByteArray *m_nullChunkData;
358 mutable QThreadPool *m_ioThreadPool;
364 mutable bool m_lastOperationWasWrite;
369 bool m_useOptimizedCubeWrite;
372 QMutex *m_writeThreadMutex;
375 mutable volatile int m_idealFlushSize;
378 mutable int m_consecutiveOverflowCount;
Buffer for reading and writing cube data.
Definition: Buffer.h:69
long long int BigInt
Big int.
Definition: Constants.h:65
void clearCache(bool blockForWriteCache=true) const
Free all cube chunks (cached cube data) from memory and write them to disk.
Definition: CubeIoHandler.cpp:399
int getChunkIndex(const RawCubeChunk &) const
Given a chunk, what's its index in the file.
Definition: CubeIoHandler.cpp:546
void write(const Buffer &bufferToWrite)
Write buffer data into the cube data on disk.
Definition: CubeIoHandler.cpp:354
int getChunkCountInLineDimension() const
Definition: CubeIoHandler.cpp:521
int bandCount() const
Definition: CubeIoHandler.cpp:482
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
int getSampleCountInChunk() const
Definition: CubeIoHandler.cpp:620
virtual void readRaw(RawCubeChunk &chunkToFill)=0
This needs to populate the chunkToFill with unswapped raw bytes from the disk.
int getBandCountInChunk() const
Definition: CubeIoHandler.cpp:490
QMutex * dataFileMutex()
Get the mutex that this IO handler is using around I/Os on the given data file.
Definition: CubeIoHandler.cpp:475
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
BigInt getDataStartByte() const
Definition: CubeIoHandler.cpp:567
int sampleCount() const
Definition: CubeIoHandler.cpp:612
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:125
CubeIoHandler(QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk)
Creates a new CubeIoHandler using a RegionalCachingAlgorithm.
Definition: CubeIoHandler.cpp:79
int lineCount() const
Definition: CubeIoHandler.cpp:587
int getChunkCountInBandDimension() const
Definition: CubeIoHandler.cpp:512
QFile * getDataFile()
Definition: CubeIoHandler.cpp:578
virtual void updateLabels(Pvl &labels)=0
Function to update the labels with a Pvl object.
BigInt getDataSize() const
Definition: CubeIoHandler.cpp:441
A section of raw data on the disk.
Definition: RawCubeChunk.h:42
Byte swapper.
Definition: EndianSwapper.h:55
BigInt getBytesPerChunk() const
Definition: CubeIoHandler.cpp:502
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
Definition: BoxcarCachingAlgorithm.h:29
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void read(Buffer &bufferToFill) const
Read cube data from disk into the buffer.
Definition: CubeIoHandler.cpp:246
Definition: CubeIoHandler.h:39
int getLineCountInChunk() const
Definition: CubeIoHandler.cpp:595
This is the parent of the caching algorithms
Definition: CubeCachingAlgorithm.h:47
Definition: CubeIoHandler.h:38
PixelType pixelType() const
Definition: CubeIoHandler.cpp:603