Isis 3 Programmer Reference
Isis::EmbreeTargetManager Class Reference

Class for managing the construction and destruction of EmbreeTargetShapes. More...

#include <EmbreeTargetManager.h>

Collaboration diagram for Isis::EmbreeTargetManager:
Collaboration graph

Classes

struct  EmbreeTargetShapeContainer
 Reference counting container for EmbreeTargetShapes. More...
 

Public Member Functions

EmbreeTargetShapecreate (const QString &shapeFile)
 Get a pointer to an EmbreeTargetShape containing the information from a shape file. More...
 
void free (const QString &shapeFile)
 Notify the manager that an EmbreeTargetShape is no longer in use. More...
 
int currentCacheSize () const
 Return the number of currently stored EmbreeTargetShapes. More...
 
int maxCacheSize () const
 Return the maximum number of stored EmbreeTargetShapes. More...
 
bool inCache (const QString &shapeFile) const
 Check if there is an already created EmbreeTargetShape for a file. More...
 
void setMaxCacheSize (const int &numShapes)
 Set the maximum number of stored EmbreeTargetShapes. More...
 

Static Public Member Functions

static EmbreeTargetManagergetInstance ()
 Retrieve reference to Singleton instance of this object. More...
 

Private Member Functions

 EmbreeTargetManager ()
 This constructor will initialize the EmbreeTargetManager object to default values. More...
 
 ~EmbreeTargetManager ()
 Destructor that frees all of the EmbreeTargetShapes managed by this object. More...
 
QString fullFilePath (const QString &filePath) const
 Helper function that takes a file path and returns the full file path. More...
 
void removeTargetShape (const QString &shapeFile)
 Method for removing an EmbreeTargetShape from the internal cache. More...
 

Static Private Member Functions

static void DieAtExit ()
 Exit termination routine. More...
 

Private Attributes

QMap< QString, EmbreeTargetShapeContainerm_targeCache
 !< Pointer to the singleton factory. More...
 
int m_maxCacheSize
 !< The cache of created target shapes. More...
 

Static Private Attributes

static EmbreeTargetManagerm_maker = 0
 Initialize the singleton factory pointer. More...
 

Detailed Description

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.

Author
2017-05-08 Jesse mapel
History:
2017-05-08 Jesse Mapel - Original Version.

Definition at line 53 of file EmbreeTargetManager.h.

Constructor & Destructor Documentation

◆ EmbreeTargetManager()

Isis::EmbreeTargetManager::EmbreeTargetManager ( )
private

This constructor will initialize the EmbreeTargetManager object to default values.

The default maximum number of shape models held in memory is 10

Definition at line 47 of file EmbreeTargetManager.cpp.

References DieAtExit().

Referenced by getInstance().

◆ ~EmbreeTargetManager()

Isis::EmbreeTargetManager::~EmbreeTargetManager ( )
private

Destructor that frees all of the EmbreeTargetShapes managed by this object.

Definition at line 58 of file EmbreeTargetManager.cpp.

References m_targeCache, and removeTargetShape().

Member Function Documentation

◆ create()

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.

Parameters
shapeFileThe path to the file to create an EmbreeTargetShape from
Returns
EmbreeTargetShape* A pointer to the loaded target shape. The manager still owns the object so it should not be deleted. Use EmbreeTargetManager::free to notify the manager that it is no longer in use.
See also
EmbreeTargetManager::free
Exceptions
IException::Programmer

Definition at line 146 of file EmbreeTargetManager.cpp.

References _FILEINFO_, fullFilePath(), inCache(), Isis::EmbreeTargetManager::EmbreeTargetShapeContainer::m_referenceCount, m_targeCache, Isis::EmbreeTargetManager::EmbreeTargetShapeContainer::m_targetShape, maxCacheSize(), and Isis::IException::Programmer.

Referenced by Isis::EmbreeShapeModel::EmbreeShapeModel().

◆ currentCacheSize()

int Isis::EmbreeTargetManager::currentCacheSize ( ) const

Return the number of currently stored EmbreeTargetShapes.

Returns
int The number of currently stored EmbreeTargetShapes.

Definition at line 250 of file EmbreeTargetManager.cpp.

References m_targeCache.

◆ DieAtExit()

void Isis::EmbreeTargetManager::DieAtExit ( )
staticprivate

Exit termination routine.

This (static) method ensure this object is destroyed when Qt exits.
Note that it is error to add this to the system _atexit() routine because this object utilizes Qt classes. At the time the atexit call stack is executed, Qt is long gone resulting in Very Bad Things. Fortunately, Qt has an exit stack function as well. This method is added to the Qt exit call stack.

Definition at line 77 of file EmbreeTargetManager.cpp.

References m_maker.

Referenced by EmbreeTargetManager().

◆ free()

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.

Parameters
shapeFileThe 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.
See also
EmbreeTargetManager::free
Exceptions
IException::Programmer

Definition at line 190 of file EmbreeTargetManager.cpp.

References _FILEINFO_, fullFilePath(), inCache(), m_targeCache, Isis::IException::Programmer, and removeTargetShape().

Referenced by Isis::EmbreeShapeModel::~EmbreeShapeModel().

◆ fullFilePath()

QString Isis::EmbreeTargetManager::fullFilePath ( const QString &  filePath) const
private

Helper function that takes a file path and returns the full file path.

Parameters
filePathThe file path to expand.
Returns
QString The full file path.
See also
FileName::Expanded()

Definition at line 111 of file EmbreeTargetManager.cpp.

References Isis::FileName::expanded().

Referenced by create(), free(), inCache(), and removeTargetShape().

◆ getInstance()

EmbreeTargetManager * Isis::EmbreeTargetManager::getInstance ( )
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.

Returns
EmbreeTargetManager* Pointer to Singleton instance of this object.

Definition at line 94 of file EmbreeTargetManager.cpp.

References EmbreeTargetManager(), and m_maker.

◆ inCache()

bool Isis::EmbreeTargetManager::inCache ( const QString &  shapeFile) const

Check if there is an already created EmbreeTargetShape for a file.

Parameters
shapeFileThe path to the file to check for

Definition at line 283 of file EmbreeTargetManager.cpp.

References fullFilePath(), and m_targeCache.

Referenced by create(), free(), and removeTargetShape().

◆ maxCacheSize()

int Isis::EmbreeTargetManager::maxCacheSize ( ) const

Return the maximum number of stored EmbreeTargetShapes.

Returns
int The maximum number of stored EmbreeTargetShapes.

Definition at line 260 of file EmbreeTargetManager.cpp.

References m_maxCacheSize.

Referenced by create().

◆ removeTargetShape()

void Isis::EmbreeTargetManager::removeTargetShape ( const QString &  shapeFile)
private

Method for removing an EmbreeTargetShape from the internal cache.

The EmbreeTargetShapeContainer destructor does not delete the EmbreeTargetShape, so this should be used to free delete anything from the cache.

Parameters
shapeFileThe path to the shape file used to create the EmbreeTargetShape that will be removed.
See also
EmbreeTargetManager::free
Exceptions
IException::Programmer

Definition at line 227 of file EmbreeTargetManager.cpp.

References _FILEINFO_, fullFilePath(), inCache(), m_targeCache, Isis::EmbreeTargetManager::EmbreeTargetShapeContainer::m_targetShape, and Isis::IException::Programmer.

Referenced by free(), and ~EmbreeTargetManager().

◆ setMaxCacheSize()

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.

Parameters
numShapesThe new maximum number of stored EmbreeTargetShapes.

Definition at line 273 of file EmbreeTargetManager.cpp.

References m_maxCacheSize.

Member Data Documentation

◆ m_maker

EmbreeTargetManager * Isis::EmbreeTargetManager::m_maker = 0
staticprivate

Initialize the singleton factory pointer.

Definition at line 112 of file EmbreeTargetManager.h.

Referenced by DieAtExit(), and getInstance().

◆ m_maxCacheSize

int Isis::EmbreeTargetManager::m_maxCacheSize
private

!< The cache of created target shapes.

Definition at line 115 of file EmbreeTargetManager.h.

Referenced by maxCacheSize(), and setMaxCacheSize().

◆ m_targeCache

QMap<QString, EmbreeTargetShapeContainer> Isis::EmbreeTargetManager::m_targeCache
private

!< Pointer to the singleton factory.

Definition at line 113 of file EmbreeTargetManager.h.

Referenced by create(), currentCacheSize(), free(), inCache(), removeTargetShape(), and ~EmbreeTargetManager().


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