Isis 3 Programmer Reference
|
IO Handler for Isis Cubes using the BSQ format. More...
#include <CubeBsqHandler.h>
Public Member Functions | |
CubeBsqHandler (QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk) | |
Construct a BSQ IO handler. More... | |
~CubeBsqHandler () | |
The destructor writes all cached data to disk. More... | |
void | updateLabels (Pvl &labels) |
Function to update the labels with a Pvl object. More... | |
void | read (Buffer &bufferToFill) const |
Read cube data from disk into the buffer. More... | |
void | write (const Buffer &bufferToWrite) |
Write buffer data into the cube data on disk. More... | |
void | addCachingAlgorithm (CubeCachingAlgorithm *algorithm) |
This will add the given caching algorithm to the list of attempted caching algorithms. More... | |
void | clearCache (bool blockForWriteCache=true) const |
Free all cube chunks (cached cube data) from memory and write them to disk. More... | |
BigInt | getDataSize () const |
void | setVirtualBands (const QList< int > *virtualBandList) |
This changes the virtual band list. More... | |
QMutex * | dataFileMutex () |
Get the mutex that this IO handler is using around I/Os on the given data file. More... | |
Protected Member Functions | |
virtual void | readRaw (RawCubeChunk &chunkToFill) |
This needs to populate the chunkToFill with unswapped raw bytes from the disk. More... | |
virtual void | writeRaw (const RawCubeChunk &chunkToWrite) |
This needs to write the chunkToWrite directly to disk with no modifications to the data itself. More... | |
int | bandCount () const |
int | getBandCountInChunk () const |
BigInt | getBytesPerChunk () const |
int | getChunkCountInBandDimension () const |
int | getChunkCountInLineDimension () const |
int | getChunkCountInSampleDimension () const |
int | getChunkIndex (const RawCubeChunk &) const |
Given a chunk, what's its index in the file. More... | |
BigInt | getDataStartByte () const |
QFile * | getDataFile () |
int | lineCount () const |
int | getLineCountInChunk () const |
PixelType | pixelType () const |
int | sampleCount () const |
int | getSampleCountInChunk () const |
void | setChunkSizes (int numSamples, int numLines, int numBands) |
This should be called once from the child constructor. More... | |
Private Member Functions | |
CubeBsqHandler (const CubeBsqHandler &other) | |
Disallow copying of this object. More... | |
CubeBsqHandler & | operator= (const CubeBsqHandler &other) |
Disallow assignments of this object. More... | |
int | findGoodSize (int maxSize, int dimensionSize) const |
This method attempts to compute a good chunk line size. More... | |
BigInt | getChunkStartByte (const RawCubeChunk &chunk) const |
This is a helper method that goes from chunk to file position. More... | |
IO Handler for Isis Cubes using the BSQ format.
This class is used to open, create, read, and write data from Isis cube files.
2007-09-14 Stuart Sides - Fixed bug where pixels from a buffer outside the ns/nl were being transfered to the right most and bottom most tiles
2007-10-11 Stuart Sides - Fixed bug introduced with previous bug fix.
2008-09-03 Steven Lambright - Fixed MSB/LSB problem with the Move() method
2011-06-16 Jai Rideout and Steven Lambright - Refactored to work with the new parent.
2011-07-18 Jai Rideout and Steven Lambright - Added unimplemented copy constructor and assignment operator.
2014-09-16 Ian Humphrey - Increased size limit for determining chunk sizes. Added findGoodSize method to better calculate number of lines in chunks for bsq cubes. References #1689.
2017-09-22 Cole Neubauer - Fixed documentation. References #4807
Definition at line 57 of file CubeBsqHandler.h.
Isis::CubeBsqHandler::CubeBsqHandler | ( | QFile * | dataFile, |
const QList< int > * | virtualBandList, | ||
const Pvl & | labels, | ||
bool | alreadyOnDisk | ||
) |
Construct a BSQ IO handler.
This will determine a good chunk size to use that does not result in the cube being enlarged or misordered.
dataFile | The file with cube DN data in it |
virtualBandList | The mapping from virtual band to physical band, see CubeIoHandler's description. |
labels | The Pvl labels for the cube |
alreadyOnDisk | True if the cube is allocated on the disk, false otherwise |
Definition at line 50 of file CubeBsqHandler.cpp.
References findGoodSize(), Isis::CubeIoHandler::lineCount(), Isis::CubeIoHandler::pixelType(), Isis::CubeIoHandler::sampleCount(), Isis::CubeIoHandler::setChunkSizes(), and Isis::SizeOf().
Isis::CubeBsqHandler::~CubeBsqHandler | ( | ) |
The destructor writes all cached data to disk.
Definition at line 74 of file CubeBsqHandler.cpp.
References Isis::CubeIoHandler::clearCache().
|
private |
Disallow copying of this object.
other | The object to copy. |
|
inherited |
This will add the given caching algorithm to the list of attempted caching algorithms.
The algorithms are tried in the opposite order that they were added - the first algorithm added is the last algorithm tried.
This method takes ownership of algorithm.
algorithm | The caching algorithm to add to the Cube for I/O |
Definition at line 384 of file CubeIoHandler.cpp.
|
protectedinherited |
Definition at line 482 of file CubeIoHandler.cpp.
|
inherited |
Free all cube chunks (cached cube data) from memory and write them to disk.
Child destructors need to call this method.
This method should only be called otherwise when lots of cubes are in memory and the many caches cause problems with system RAM limitations.
blockForWriteCache | This should be true unless this method is called from the write thread. |
Definition at line 399 of file CubeIoHandler.cpp.
Referenced by ~CubeBsqHandler(), and Isis::CubeTileHandler::~CubeTileHandler().
|
inherited |
Get the mutex that this IO handler is using around I/Os on the given data file.
A lock should be acquired before doing any reads/writes on the data file externally.
Definition at line 475 of file CubeIoHandler.cpp.
|
private |
This method attempts to compute a good chunk line size.
Chunk band size is always 1 and chunk sample size is always number of samples in the cube for this format.
maxSize | The largest allowed size of a chunk dimension |
dimensionSize | The cube's size for the chunk size we are trying to calculate (number of lines) |
Definition at line 149 of file CubeBsqHandler.cpp.
Referenced by CubeBsqHandler().
|
protectedinherited |
Definition at line 490 of file CubeIoHandler.cpp.
|
protectedinherited |
Definition at line 502 of file CubeIoHandler.cpp.
References Isis::SizeOf().
Referenced by getChunkStartByte(), and Isis::CubeTileHandler::getTileStartByte().
|
protectedinherited |
Definition at line 512 of file CubeIoHandler.cpp.
|
protectedinherited |
Definition at line 521 of file CubeIoHandler.cpp.
|
protectedinherited |
Definition at line 530 of file CubeIoHandler.cpp.
|
protectedinherited |
Given a chunk, what's its index in the file.
Chunks are ordered from left to right, then top to bottom, then front to back (BSQ). The first chunk is at the top left of band 1 and is index 0, for example. In other words, this is going from the value of m_rawData to the key.
Chunks which sit outside of the cube entirely must not be passed into this method; the results will be wrong.
Definition at line 546 of file CubeIoHandler.cpp.
References Isis::RawCubeChunk::getStartBand(), Isis::RawCubeChunk::getStartLine(), and Isis::RawCubeChunk::getStartSample().
Referenced by getChunkStartByte(), and Isis::CubeTileHandler::getTileStartByte().
|
private |
This is a helper method that goes from chunk to file position.
chunk | The chunk to locate in the file. |
Definition at line 173 of file CubeBsqHandler.cpp.
References Isis::CubeIoHandler::getBytesPerChunk(), Isis::CubeIoHandler::getChunkIndex(), and Isis::CubeIoHandler::getDataStartByte().
Referenced by readRaw(), and writeRaw().
|
protectedinherited |
Definition at line 578 of file CubeIoHandler.cpp.
Referenced by Isis::CubeTileHandler::readRaw(), readRaw(), Isis::CubeTileHandler::writeRaw(), and writeRaw().
|
inherited |
Definition at line 441 of file CubeIoHandler.cpp.
|
protectedinherited |
Definition at line 567 of file CubeIoHandler.cpp.
Referenced by getChunkStartByte(), and Isis::CubeTileHandler::getTileStartByte().
|
protectedinherited |
Definition at line 595 of file CubeIoHandler.cpp.
Referenced by Isis::CubeTileHandler::updateLabels().
|
protectedinherited |
Definition at line 620 of file CubeIoHandler.cpp.
Referenced by Isis::CubeTileHandler::updateLabels().
|
protectedinherited |
Definition at line 587 of file CubeIoHandler.cpp.
Referenced by CubeBsqHandler(), and Isis::CubeTileHandler::CubeTileHandler().
|
private |
Disallow assignments of this object.
other | The CubeBsqHandler on the right-hand side of the assignment that we are copying into *this. |
|
protectedinherited |
Definition at line 603 of file CubeIoHandler.cpp.
Referenced by CubeBsqHandler(), and Isis::CubeTileHandler::CubeTileHandler().
|
inherited |
Read cube data from disk into the buffer.
This is not const because it caches the read cube chunks from the disk.
bufferToFill | The buffer to populate with cube data. |
Definition at line 246 of file CubeIoHandler.cpp.
References Isis::Buffer::Band(), Isis::Buffer::BandDimension(), Isis::Buffer::Line(), Isis::Buffer::LineDimension(), Isis::Null, Isis::Buffer::Sample(), Isis::Buffer::SampleDimension(), and Isis::Buffer::size().
|
protectedvirtual |
This needs to populate the chunkToFill with unswapped raw bytes from the disk.
chunkToFill | The container that needs to be filled with cube data. |
Implements Isis::CubeIoHandler.
Definition at line 91 of file CubeBsqHandler.cpp.
References _FILEINFO_, Isis::RawCubeChunk::getByteCount(), getChunkStartByte(), Isis::CubeIoHandler::getDataFile(), Isis::IException::Io, and Isis::RawCubeChunk::setRawData().
|
protectedinherited |
Definition at line 612 of file CubeIoHandler.cpp.
Referenced by CubeBsqHandler(), and Isis::CubeTileHandler::CubeTileHandler().
|
protectedinherited |
This should be called once from the child constructor.
This determines the chunk sizes used for the cube and often should remain constant for a particular cube (BSQ, for example, doesn't need it to be constant but Tile does). These being large can cause excessive use of disk space that stores no cube data. These being large can also drastically increase the amount of RAM consumed.
numSamples | The chunk size in the sample dimension |
numLines | The chunk size in the line dimension |
numBands | The chunk size in the band dimension |
Definition at line 637 of file CubeIoHandler.cpp.
References _FILEINFO_.
Referenced by CubeBsqHandler(), and Isis::CubeTileHandler::CubeTileHandler().
|
inherited |
This changes the virtual band list.
virtualBandList | A list where the indices are the vbands and the values are the physical bands. The values are 1-based. This can be specified as NULL, in which case the vbands are the physical bands. The virtual band list is copied (the pointer provided isn't remembered). |
Definition at line 458 of file CubeIoHandler.cpp.
|
virtual |
Function to update the labels with a Pvl object.
label | Pvl object to update with |
Implements Isis::CubeIoHandler.
Definition at line 84 of file CubeBsqHandler.cpp.
References Isis::PvlContainer::addKeyword(), and Isis::PvlObject::findObject().
|
inherited |
Write buffer data into the cube data on disk.
This could do no IO if the cube chunks required are already in memory and our caching algorithms say to not free any of the cube chunks afterwards.
bufferToWrite | The buffer to get cube data from. |
Definition at line 354 of file CubeIoHandler.cpp.
|
protectedvirtual |
This needs to write the chunkToWrite directly to disk with no modifications to the data itself.
chunkToWrite | The container that needs to be put on disk. |
Implements Isis::CubeIoHandler.
Definition at line 116 of file CubeBsqHandler.cpp.
References _FILEINFO_, Isis::RawCubeChunk::getByteCount(), getChunkStartByte(), Isis::CubeIoHandler::getDataFile(), Isis::RawCubeChunk::getRawData(), and Isis::IException::Io.