Isis 3 Programmer Reference
|
Class for quick re-accessing of cubes based on file name. More...
#include <CubeManager.h>
Public Member Functions | |
CubeManager () | |
This initializes a CubeManager object. More... | |
~CubeManager () | |
This is the CubeManager destructor. More... | |
void | SetNumOpenCubes (unsigned int numCubes) |
This sets the maximum number of opened cubes for this instance of CubeManager. More... | |
void | CleanCubes (const QString &cubeFileName) |
This method removes a cube from memory, if it exists. More... | |
void | CleanCubes () |
This method removes all cubes from memory. More... | |
Cube * | OpenCube (const QString &cubeFileName) |
This method opens a cube. More... | |
Static Public Member Functions | |
static Cube * | Open (const QString &cubeFileName) |
This method calls the method OpenCube() on the static instance. More... | |
static void | CleanUp (const QString &cubeFileName) |
This method calls CleanCubes(const QString &cubeFileName) on the static instance. More... | |
static void | CleanUp () |
This method calls CleanCubes() on the static instance. More... | |
Protected Attributes | |
QMap< QString, Cube * > | p_cubes |
This keeps track of the open cubes. More... | |
QQueue< QString > | p_opened |
This keeps track of cubes that have been opened. More... | |
unsigned int | p_currentLimit |
The current limit regarding number of open files allowed. More... | |
unsigned int | p_maxOpenFiles |
60% of the maximum number of open files allowed by system resources More... | |
Static Protected Attributes | |
static CubeManager * | p_instance = 0 |
There is always at least one instance of CubeManager around. More... | |
Class for quick re-accessing of cubes based on file name.
This class holds cubes in static memory for reading. This is helpful to prevent reading of the same cube many times. Files will remain opened for reading, this is not for use with a cube that will ever be written to. You can either use the static methods of the class, in which case cubes will be cleaned up after IsisMain(...) is done executing, or you can instantiate the class for more control.
Definition at line 70 of file CubeManager.h.
Isis::CubeManager::CubeManager | ( | ) |
This initializes a CubeManager object.
Definition at line 28 of file CubeManager.cpp.
References CleanUp(), p_currentLimit, p_maxOpenFiles, and Isis::IException::Programmer.
Isis::CubeManager::~CubeManager | ( | ) |
This is the CubeManager destructor.
This method calls CleanCˇubes().
Definition at line 72 of file CubeManager.cpp.
References CleanCubes().
void Isis::CubeManager::CleanCubes | ( | ) |
This method removes all cubes from memory.
All pointers returned via OpenCube will be NULL.
Definition at line 167 of file CubeManager.cpp.
References p_cubes.
Referenced by OpenCube(), and ~CubeManager().
void Isis::CubeManager::CleanCubes | ( | const QString & | cubeFileName | ) |
This method removes a cube from memory, if it exists.
If the cube is not loaded into memory, nothing happens. This will cause any pointers to this cube, obtained via OpenCube, to be NULL.
cubeFileName | The filename of the cube to remove from memory |
Definition at line 148 of file CubeManager.cpp.
References p_cubes.
Referenced by Isis::ControlNetValidMeasure::~ControlNetValidMeasure().
|
inlinestatic |
This method calls CleanCubes() on the static instance.
Definition at line 130 of file CubeManager.h.
Referenced by CubeManager().
|
inlinestatic |
This method calls CleanCubes(const QString &cubeFileName) on the static instance.
cubeFileName | The filename of the cube to destroy from memory |
Definition at line 120 of file CubeManager.h.
|
inlinestatic |
This method calls the method OpenCube() on the static instance.
cubeFileName | FileName of the cube to be opened |
Definition at line 84 of file CubeManager.h.
Referenced by Isis::DemShape::DemShape().
Cube * Isis::CubeManager::OpenCube | ( | const QString & | cubeFileName | ) |
This method opens a cube.
If the cube is already opened, this method will return the cube from memory. The CubeManager class retains ownership of this cube pointer, so do not close the cube, destroy the pointer, or otherwise modify the cube object or pointer such that another object using them would fail. This method does not guarantee you are the only one with this pointer, nor is it recommended to keep this pointer out of a local (method) scope.
Note that this method will allow for 60% of the system's maximum file limit + 1 cubes to be opened, since the cube passed is opened and then cleanup follows. However, since our maximum limit is 60% of the system limit, this will allow enough room for this extra file to be opened before the cleanup occurs.
cubeFileName | The filename of the cube you wish to open |
Definition at line 95 of file CubeManager.cpp.
References Isis::CubeAttributeInput::bands(), CleanCubes(), Isis::FileName::expanded(), p_cubes, p_currentLimit, p_opened, and Isis::IString::ToQt().
Referenced by Isis::InterestOperator::FindCnetRef(), Isis::InterestOperator::FindOverlapByImageFootPrint(), Isis::ControlNetStatistics::GenerateImageStats(), Isis::InterestOperator::InterestByPoint(), and Isis::InterestOperator::ProcessLocked_Point_Reference().
|
inline |
This sets the maximum number of opened cubes for this instance of CubeManager.
The last "maxCubes" opened cubes are guaranteed to be valid as long as one of the CleanCubes(...) are not called. If the maximum number of open cubes specified exceeds 60% of system limitations, the maximum number of opened cubes will be set to a 60% of the system's open file limitation (this considers files used by the current process).
numCubes | Maximum number of open cubes |
Definition at line 102 of file CubeManager.h.
Referenced by Isis::ControlNetStatistics::GenerateImageStats(), and Isis::ControlNetValidMeasure::ReadSerialNumbers().
This keeps track of the open cubes.
Definition at line 145 of file CubeManager.h.
Referenced by CleanCubes(), and OpenCube().
|
protected |
The current limit regarding number of open files allowed.
Definition at line 151 of file CubeManager.h.
Referenced by CubeManager(), and OpenCube().
|
staticprotected |
There is always at least one instance of CubeManager around.
Definition at line 142 of file CubeManager.h.
|
protected |
60% of the maximum number of open files allowed by system resources
Definition at line 154 of file CubeManager.h.
Referenced by CubeManager().
|
protected |
This keeps track of cubes that have been opened.
Definition at line 148 of file CubeManager.h.
Referenced by OpenCube().