Isis 3 Programmer Reference
CubeManager.h
1 #ifndef CubeManager_h
2 #define CubeManager_h
3 
4 #include "IException.h"
5 
6 #include <QMap>
7 #include <QQueue>
8 #include <QString>
9 #include <memory>
10 
11 #include <iostream>
12 
13 using namespace std;
14 
15 /*
16  * Unless noted otherwise, the portions of Isis written by the
17  * USGS are public domain. See individual third-party library
18  * and package descriptions for intellectual property
19  * information,user agreements, and related information.
20  *
21  * Although Isis has been used by the USGS, no warranty, expressed or implied,
22  * is made by the USGS as to the accuracy and functioning of such software
23  * and related material nor shall the fact of distribution constitute any such
24  * warranty, and no responsibility is assumed by the USGS in connection
25  * therewith.
26  *
27  * For additional information, launch
28  * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see
29  * the Privacy &amp; Disclaimers page on the Isis website,
30  * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
31  * http://www.usgs.gov/privacy.html.
32  */
33 namespace Isis {
34  class Cube;
35 
64  class CubeManager {
65  public:
66  CubeManager();
67  ~CubeManager();
68 
78  static Cube *Open(const QString &cubeFileName) {
79  if (!p_instance) {
80  p_instance = new CubeManager();
81  }
82 
83  return p_instance->OpenCube(cubeFileName);
84  }
85 
96  void SetNumOpenCubes(unsigned int numCubes) {
97 
98  // check to see if numCubes exceeds the number of open files limitations
99  if (numCubes > p_maxOpenFiles) {
100  p_currentLimit = p_maxOpenFiles;
101  }
102  p_currentLimit = numCubes;
103  }
104 
105 
114  static void CleanUp(const QString &cubeFileName) {
115  p_instance->CleanCubes(cubeFileName);
116  }
117 
118 
124  static void CleanUp() {
125  delete p_instance;
126  p_instance = 0;
127  };
128 
129  void CleanCubes(const QString &cubeFileName);
130  void CleanCubes();
131  Cube *OpenCube(const QString &cubeFileName);
132 
133  protected:
134 
137 
140 
143 
145  unsigned int p_currentLimit;
146 
148  unsigned int p_maxOpenFiles;
149  };
150 }
151 
152 #endif
QQueue< QString > p_opened
This keeps track of cubes that have been opened.
Definition: CubeManager.h:142
static void CleanUp(const QString &cubeFileName)
This method calls CleanCubes(const QString &cubeFileName) on the static instance. ...
Definition: CubeManager.h:114
unsigned int p_currentLimit
The current limit regarding number of open files allowed.
Definition: CubeManager.h:145
Namespace for the standard library.
void SetNumOpenCubes(unsigned int numCubes)
This sets the maximum number of opened cubes for this instance of CubeManager.
Definition: CubeManager.h:96
QMap< QString, Cube * > p_cubes
This keeps track of the open cubes.
Definition: CubeManager.h:139
static Cube * Open(const QString &cubeFileName)
This method calls the method OpenCube() on the static instance.
Definition: CubeManager.h:78
Class for quick re-accessing of cubes based on file name.
Definition: CubeManager.h:64
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
static CubeManager * p_instance
There is always at least one instance of CubeManager around.
Definition: CubeManager.h:136
unsigned int p_maxOpenFiles
60% of the maximum number of open files allowed by system resources
Definition: CubeManager.h:148
static void CleanUp()
This method calls CleanCubes() on the static instance.
Definition: CubeManager.h:124
IO Handler for Isis Cubes.
Definition: Cube.h:170