8#include "CubeBsqHandler.h" 
   14#include "IException.h" 
   16#include "PvlKeyword.h" 
   18#include "RawCubeChunk.h" 
   35      const QList<int> *virtualBandList, 
const Pvl &labels, 
bool alreadyOnDisk)
 
   36    : 
CubeIoHandler(dataFile, virtualBandList, labels, alreadyOnDisk) {
 
   38    int numLinesInChunk = 1;
 
   39    QList<int> primeFactors;
 
   42    int sizeLimit = 1024 * 1024 * 1024;
 
   43    int maxNumLines = (sizeLimit) / (
SizeOf(
pixelType()) * numSamplesInChunk);
 
 
   70    core.addKeyword(
PvlKeyword(
"Format", 
"BandSequential"),
 
   71                    PvlContainer::Replace);
 
 
   81    if(dataFile->seek(startByte)) {
 
   82      QByteArray binaryData = dataFile->read(chunkToFill.getByteCount());
 
   84      if(binaryData.size() == chunkToFill.getByteCount()) {
 
   85        chunkToFill.setRawData(binaryData);
 
   91      IString msg = 
"Reading from the file [" + dataFile->fileName() + 
"] " 
   92          "failed with reading [" +
 
   93          QString::number(chunkToFill.getByteCount()) +
 
   94          "] bytes at position [" + QString::number(startByte) + 
"]";
 
 
  103    bool success = 
false;
 
  106    if(dataFile->seek(startByte)) {
 
  107      BigInt dataWritten = dataFile->write(chunkToWrite.getRawData());
 
  109      if(dataWritten == chunkToWrite.getByteCount()) {
 
  115      IString msg = 
"Writing to the file [" + dataFile->fileName() + 
"] " 
  116          "failed with writing [" +
 
  117          QString::number(chunkToWrite.getByteCount()) +
 
  118          "] bytes at position [" + QString::number(startByte) + 
"]";
 
 
  134    int chunkDimensionSize;
 
  136    if (dimensionSize <= maxSize) {
 
  137      chunkDimensionSize = dimensionSize;
 
  141      int greatestDivisor = maxSize;
 
  142      while (dimensionSize % greatestDivisor > 0) {
 
  145      chunkDimensionSize = greatestDivisor;
 
  147    return chunkDimensionSize;
 
 
CubeBsqHandler(QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk)
Construct a BSQ IO handler.
 
virtual void readRaw(RawCubeChunk &chunkToFill)
This needs to populate the chunkToFill with unswapped raw bytes from the disk.
 
virtual void writeRaw(const RawCubeChunk &chunkToWrite)
This needs to write the chunkToWrite directly to disk with no modifications to the data itself.
 
int findGoodSize(int maxSize, int dimensionSize) const
This method attempts to compute a good chunk line size.
 
BigInt getChunkStartByte(const RawCubeChunk &chunk) const
This is a helper method that goes from chunk to file position.
 
void updateLabels(Pvl &labels)
Function to update the labels with a Pvl object.
 
~CubeBsqHandler()
The destructor writes all cached data to disk.
 
Handles converting buffers to and from disk.
 
void clearCache(bool blockForWriteCache=true) const
Free all cube chunks (cached cube data) from memory and write them to disk.
 
PixelType pixelType() const
 
void setChunkSizes(int numSamples, int numLines, int numBands)
This should be called once from the child constructor.
 
BigInt getBytesPerChunk() const
 
BigInt getDataStartByte() const
 
int getChunkIndex(const RawCubeChunk &) const
Given a chunk, what's its index in the file.
 
@ Io
A type of error that occurred when performing an actual I/O operation.
 
Adds specific functionality to C++ strings.
 
Container for cube-like labels.
 
A single keyword-value pair.
 
Contains Pvl Groups and Pvl Objects.
 
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
 
A section of raw data on the disk.
 
This is free and unencumbered software released into the public domain.
 
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
 
long long int BigInt
Big int.
 
Namespace for the standard library.