Isis Developer Reference
CubeManager.h
Go to the documentation of this file.
1 #ifndef CubeManager_h
2 #define CubeManager_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include "IException.h"
11 
12 #include <QMap>
13 #include <QQueue>
14 #include <QString>
15 #include <memory>
16 
17 #include <iostream>
18 
19 using namespace std;
20 
21 /*
22  * Unless noted otherwise, the portions of Isis written by the
23  * USGS are public domain. See individual third-party library
24  * and package descriptions for intellectual property
25  * information,user agreements, and related information.
26  *
27  * Although Isis has been used by the USGS, no warranty, expressed or implied,
28  * is made by the USGS as to the accuracy and functioning of such software
29  * and related material nor shall the fact of distribution constitute any such
30  * warranty, and no responsibility is assumed by the USGS in connection
31  * therewith.
32  *
33  * For additional information, launch
34  * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see
35  * the Privacy &amp; Disclaimers page on the Isis website,
36  * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
37  * http://www.usgs.gov/privacy.html.
38  */
39 namespace Isis {
40  class Cube;
41 
70  class CubeManager {
71  public:
72  CubeManager();
73  ~CubeManager();
74 
84  static Cube *Open(const QString &cubeFileName) {
85  if (!p_instance) {
86  p_instance = new CubeManager();
87  }
88 
89  return p_instance->OpenCube(cubeFileName);
90  }
91 
102  void SetNumOpenCubes(unsigned int numCubes) {
103 
104  // check to see if numCubes exceeds the number of open files limitations
105  if (numCubes > p_maxOpenFiles) {
106  p_currentLimit = p_maxOpenFiles;
107  }
108  p_currentLimit = numCubes;
109  }
110 
111 
120  static void CleanUp(const QString &cubeFileName) {
121  p_instance->CleanCubes(cubeFileName);
122  }
123 
124 
130  static void CleanUp() {
131  delete p_instance;
132  p_instance = 0;
133  };
134 
135  void CleanCubes(const QString &cubeFileName);
136  void CleanCubes();
137  Cube *OpenCube(const QString &cubeFileName);
138 
139  protected:
140 
143 
146 
149 
151  unsigned int p_currentLimit;
152 
154  unsigned int p_maxOpenFiles;
155  };
156 }
157 
158 #endif
FileName.h
Cube.h
Isis::CubeManager::~CubeManager
~CubeManager()
This is the CubeManager destructor.
Definition: CubeManager.cpp:72
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::CubeManager::p_cubes
QMap< QString, Cube * > p_cubes
This keeps track of the open cubes.
Definition: CubeManager.h:145
Isis::CubeManager::p_instance
static CubeManager * p_instance
There is always at least one instance of CubeManager around.
Definition: CubeManager.h:142
Isis::CubeManager::p_maxOpenFiles
unsigned int p_maxOpenFiles
60% of the maximum number of open files allowed by system resources
Definition: CubeManager.h:154
Isis::CubeManager::Open
static Cube * Open(const QString &cubeFileName)
This method calls the method OpenCube() on the static instance.
Definition: CubeManager.h:84
IString.h
Isis::CubeManager::OpenCube
Cube * OpenCube(const QString &cubeFileName)
This method opens a cube.
Definition: CubeManager.cpp:95
Isis::CubeManager::CleanUp
static void CleanUp()
This method calls CleanCubes() on the static instance.
Definition: CubeManager.h:130
Isis::CubeManager
Class for quick re-accessing of cubes based on file name.
Definition: CubeManager.h:70
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::CubeManager::CleanUp
static void CleanUp(const QString &cubeFileName)
This method calls CleanCubes(const QString &cubeFileName) on the static instance.
Definition: CubeManager.h:120
Isis::CubeManager::p_currentLimit
unsigned int p_currentLimit
The current limit regarding number of open files allowed.
Definition: CubeManager.h:151
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::CubeManager::p_opened
QQueue< QString > p_opened
This keeps track of cubes that have been opened.
Definition: CubeManager.h:148
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
IException.h
Isis::CubeAttributeInput::bands
std::vector< QString > bands() const
Return a vector of the input bands specified.
Definition: CubeAttribute.cpp:82
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
QQueue< QString >
Isis::CubeAttributeInput
Manipulate and parse attributes of input cube filenames.
Definition: CubeAttribute.h:381
QMap
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:22
Isis::CubeManager::SetNumOpenCubes
void SetNumOpenCubes(unsigned int numCubes)
This sets the maximum number of opened cubes for this instance of CubeManager.
Definition: CubeManager.h:102
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::CubeManager::CubeManager
CubeManager()
This initializes a CubeManager object.
Definition: CubeManager.cpp:28
CubeManager.h
CubeAttribute.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IString::ToQt
QString ToQt() const
Retuns the object string as a QString.
Definition: IString.cpp:869
Isis::CubeManager::CleanCubes
void CleanCubes()
This method removes all cubes from memory.
Definition: CubeManager.cpp:167