Isis Developer Reference
CubeManager.h
Go to the documentation of this file.
1#ifndef CubeManager_h
2#define CubeManager_h
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
19using 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 */
39namespace Isis {
40 class Cube;
41
71 public:
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) {
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
145 QMap<QString, Cube *> p_cubes;
146
148 QQueue<QString> p_opened;
149
151 unsigned int p_currentLimit;
152
154 unsigned int p_maxOpenFiles;
155 };
156}
157
158#endif
IO Handler for Isis Cubes.
Definition Cube.h:168
Class for quick re-accessing of cubes based on file name.
Definition CubeManager.h:70
static void CleanUp(const QString &cubeFileName)
This method calls CleanCubes(const QString &cubeFileName) on the static instance.
Definition CubeManager.h:120
unsigned int p_maxOpenFiles
60% of the maximum number of open files allowed by system resources
Definition CubeManager.h:154
static CubeManager * p_instance
There is always at least one instance of CubeManager around.
Definition CubeManager.h:142
QMap< QString, Cube * > p_cubes
This keeps track of the open cubes.
Definition CubeManager.h:145
Cube * OpenCube(const QString &cubeFileName)
This method opens a cube.
Definition CubeManager.cpp:95
void CleanCubes()
This method removes all cubes from memory.
Definition CubeManager.cpp:165
QQueue< QString > p_opened
This keeps track of cubes that have been opened.
Definition CubeManager.h:148
CubeManager()
This initializes a CubeManager object.
Definition CubeManager.cpp:28
void SetNumOpenCubes(unsigned int numCubes)
This sets the maximum number of opened cubes for this instance of CubeManager.
Definition CubeManager.h:102
static void CleanUp()
This method calls CleanCubes() on the static instance.
Definition CubeManager.h:130
unsigned int p_currentLimit
The current limit regarding number of open files allowed.
Definition CubeManager.h:151
~CubeManager()
This is the CubeManager destructor.
Definition CubeManager.cpp:72
static Cube * Open(const QString &cubeFileName)
This method calls the method OpenCube() on the static instance.
Definition CubeManager.h:84
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.