Isis Developer Reference
|
Class for managing the construction and destruction of EmbreeTargetShapes. More...
#include <EmbreeTargetManager.h>
Public Member Functions | |
EmbreeTargetShape * | create (const QString &shapeFile) |
Get a pointer to an EmbreeTargetShape containing the information from a shape file. | |
void | free (const QString &shapeFile) |
Notify the manager that an EmbreeTargetShape is no longer in use. | |
int | currentCacheSize () const |
Return the number of currently stored EmbreeTargetShapes. | |
int | maxCacheSize () const |
Return the maximum number of stored EmbreeTargetShapes. | |
bool | inCache (const QString &shapeFile) const |
Check if there is an already created EmbreeTargetShape for a file. | |
void | setMaxCacheSize (const int &numShapes) |
Set the maximum number of stored EmbreeTargetShapes. | |
Static Public Member Functions | |
static EmbreeTargetManager * | getInstance () |
Retrieve reference to Singleton instance of this object. | |
Class for managing the construction and destruction of EmbreeTargetShapes.
This class is a singleton that constructs and holds EmbreeTargetShape. Due to the time required to construct a new EmbreeTargetShape and the large memory requirements, this class limits their creation and the number that can be held in memory at one time.
When an EmbreeTargetShape is requested the EmbreeTargetManager will first check if an EmbreeTargetShape for that file already exists. If one does, a pointer to the existing EmbreeTargetShape is given and the reference count is incremented. If one does not exist yet, a new EmbreeTargetShape is created on the heap. When an EmbreeTargetShape is no longer used, the EmbreeTargetManager should be notified and it will decrement the reference count on that EmbreeTargetShape. If the EmbreeTargetShape is no longer used by anything, then it is deleted.
EmbreeTargetShape * Isis::EmbreeTargetManager::create | ( | const QString & | shapeFile | ) |
Get a pointer to an EmbreeTargetShape containing the information from a shape file.
If the shape file has already been stored in an EmbreeTargetShape then a pointer to that is returned. If the shape file has not been loaded yet, then it is loaded and a pointer to the EmbreeTargetShape is returned.
In both cases, ownership of the pointer is not passed. Use EmbreeTargetManager::free to notify the EmbreeTargetManager that the pointer is no longer in use.
The EmbreeTargetShapes take a large amount of time to create and memory to store, so the manager limits the number that can be opened at one time. If the limit is reached and a new one is requested, an error is thrown. Use EmbreeTargetManager::setMaxCacheSize to change the maximum number of EmbreeTargetShapes.
shapeFile | The path to the file to create an EmbreeTargetShape from |
IException::Programmer |
References _FILEINFO_.
Referenced by Isis::EmbreeShapeModel::EmbreeShapeModel(), and Isis::EmbreeShapeModel::EmbreeShapeModel().
int Isis::EmbreeTargetManager::currentCacheSize | ( | ) | const |
Return the number of currently stored EmbreeTargetShapes.
void Isis::EmbreeTargetManager::free | ( | const QString & | shapeFile | ) |
Notify the manager that an EmbreeTargetShape is no longer in use.
This method will decrease the internal reference count for the target shape. Then if there are not more references. the EmbreeTargetShape is destroyed to free up memory.
shapeFile | The path to the file used to create the EmbreeTargetShape. This should be the same as the parameter used with EmbreeTargetManager::create to get a pointer to the EmbreeTargetShape. |
IException::Programmer |
References _FILEINFO_.
Referenced by Isis::EmbreeShapeModel::~EmbreeShapeModel().
|
static |
Retrieve reference to Singleton instance of this object.
The only access provided for Singleton instance of this object. All method access is made through the pointer returned by this method. The object is created upon the first call to this method. The object is deleted when Qt shuts down.
Referenced by Isis::ShapeModelFactory::create().
bool Isis::EmbreeTargetManager::inCache | ( | const QString & | shapeFile | ) | const |
Check if there is an already created EmbreeTargetShape for a file.
shapeFile | The path to the file to check for |
int Isis::EmbreeTargetManager::maxCacheSize | ( | ) | const |
Return the maximum number of stored EmbreeTargetShapes.
void Isis::EmbreeTargetManager::setMaxCacheSize | ( | const int & | numShapes | ) |
Set the maximum number of stored EmbreeTargetShapes.
This does not apply retroactively. If there are more stored EmbreeTargetShapes than the new maximum, then they will remain and new EmbreeTargetShapes cannot be created until the number currently open goes below the maximum.
numShapes | The new maximum number of stored EmbreeTargetShapes. |