USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::CubeManager Class Reference

Class for quick re-accessing of cubes based on file name. More...

#include <CubeManager.h>

Collaboration diagram for Isis::CubeManager:
Collaboration graph

Public Member Functions

 CubeManager ()
 This initializes a CubeManager object.
 
 ~CubeManager ()
 This is the CubeManager destructor.
 
void CleanCubes (const QString &cubeFileName)
 This method removes a cube from memory, if it exists.
 
void CleanCubes ()
 This method removes all cubes from memory.
 
CubeOpenCube (const QString &cubeFileName)
 This method opens a cube.
 
void SetNumOpenCubes (unsigned int numCubes)
 This sets the maximum number of opened cubes for this instance of CubeManager.
 

Static Public Member Functions

static CubeOpen (const QString &cubeFileName)
 This method calls the method OpenCube() on the static instance.
 
static void CleanUp (const QString &cubeFileName)
 This method calls CleanCubes(const QString &cubeFileName) on the static instance.
 
static void CleanUp ()
 This method calls CleanCubes() on the static instance.
 

Protected Attributes

QMap< QString, Cube * > p_cubes
 This keeps track of the open cubes.
 
QQueue< QString > p_opened
 This keeps track of cubes that have been opened.
 
unsigned int p_minimumCubes
 At least this many cubes must be allowed in memory, more can be cleaned up, 0 means no limit.
 

Static Protected Attributes

static CubeManager p_instance
 There is always at least one instance of CubeManager around.
 

Detailed Description

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.

Author
2008-05-20 Steven Lambright
Author
2008-06-19 Steven Lambright - Added CleanUp methods
History:

2008-08-19 Steven Koechle - Removed Geos includes

2011-06-08 Steven Lambright - Better handles the case when a Cube fails to open, fixes #161.

Author
2009-02-12 Steven Lambright - Made the class available as an instance and not just statically. Added optional cube open limits.
History:
2009-11-03 Mackenzie Boyd - Modified to include cube attributes (input) when opening cubes.

Definition at line 51 of file CubeManager.h.

Constructor & Destructor Documentation

Isis::CubeManager::CubeManager ( )

This initializes a CubeManager object.

Definition at line 16 of file CubeManager.cpp.

References p_minimumCubes.

Isis::CubeManager::~CubeManager ( )

This is the CubeManager destructor.

This method calls CleanCubes().

Definition at line 24 of file CubeManager.cpp.

References CleanCubes().

Member Function Documentation

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 invalid.

Parameters
cubeFileNameThe filename of the cube to remove from memory

Definition at line 92 of file CubeManager.cpp.

References p_cubes.

Referenced by CleanUp().

void Isis::CubeManager::CleanCubes ( )

This method removes all cubes from memory.

All pointers returned via OpenCube will be invalid.

Definition at line 109 of file CubeManager.cpp.

References p_cubes.

Referenced by OpenCube(), and ~CubeManager().

static void Isis::CubeManager::CleanUp ( const QString &  cubeFileName)
inlinestatic

This method calls CleanCubes(const QString &cubeFileName) on the static instance.

See Also
CleanCubes(const QString &cubeFileName)
Parameters
cubeFileNameThe filename of the cube to destroy from memory

Definition at line 77 of file CubeManager.h.

References CleanCubes(), and p_instance.

static void Isis::CubeManager::CleanUp ( )
inlinestatic

This method calls CleanCubes() on the static instance.

See Also
CleanCubes

Definition at line 86 of file CubeManager.h.

References CleanCubes(), and p_instance.

static Cube* Isis::CubeManager::Open ( const QString &  cubeFileName)
inlinestatic

This method calls the method OpenCube() on the static instance.

See Also
OpenCube
Parameters
cubeFileNameFileName of the cube to be opened
Returns
Cube* Pointer to the cube (guaranteed not null)

Definition at line 65 of file CubeManager.h.

References OpenCube(), and p_instance.

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.

Parameters
cubeFileNameThe filename of the cube you wish to open
Returns
Cube* A pointer to the cube object that CubeManager retains ownership to and may delete at any time

Definition at line 41 of file CubeManager.cpp.

References Isis::CubeAttributeInput::bands(), CleanCubes(), p_cubes, p_minimumCubes, p_opened, and Isis::IString::ToQt().

Referenced by Isis::InterestOperator::FindCnetRef(), Isis::ControlNetStatistics::GenerateImageStats(), Isis::InterestOperator::InterestByPoint(), Open(), and Isis::InterestOperator::ProcessLocked_Point_Reference().

void Isis::CubeManager::SetNumOpenCubes ( unsigned int  numCubes)
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.

Parameters
numCubesMaximum number of open cubes

Definition at line 102 of file CubeManager.h.

References p_minimumCubes.

Referenced by Isis::ControlNetStatistics::GenerateImageStats().

Member Data Documentation

QMap<QString, Cube *> Isis::CubeManager::p_cubes
protected

This keeps track of the open cubes.

Definition at line 111 of file CubeManager.h.

Referenced by CleanCubes(), and OpenCube().

CubeManager Isis::CubeManager::p_instance
staticprotected

There is always at least one instance of CubeManager around.

Definition at line 108 of file CubeManager.h.

Referenced by CleanUp(), and Open().

unsigned int Isis::CubeManager::p_minimumCubes
protected

At least this many cubes must be allowed in memory, more can be cleaned up, 0 means no limit.

Definition at line 116 of file CubeManager.h.

Referenced by CubeManager(), OpenCube(), and SetNumOpenCubes().

QQueue<QString> Isis::CubeManager::p_opened
protected

This keeps track of cubes that have been opened.

Definition at line 113 of file CubeManager.h.

Referenced by OpenCube().


The documentation for this class was generated from the following files: