NDEVR
API Documentation
DesignObjectResourceCache

A cache for reusing Model and Geometry objects to avoid repeated allocation. More...

Collaboration diagram for DesignObjectResourceCache:
[legend]

Public Member Functions

void addToCache (const Buffer< Geometry > &items)
 Adds a buffer of Geometry objects to the cache after detaching them from parents.
void addToCache (const Buffer< Model > &items)
 Adds a buffer of Models to the cache after resetting each to defaults.
void createChildren (Model &parent, uint04 size)
 Ensures a parent model has the specified number of children, using cached models when available.
Geometry createGeometry (Model &parent)
 Creates or retrieves a Geometry for the given parent model, preferring cached geometries.
Model createModel (Model &parent)
 Creates or retrieves a child Model for the given parent, preferring cached models.
void setModelToDefaults (Model &model)
 Resets a Model to its default state so it can be reused from the cache.

Public Attributes

Buffer< Geometrygeometries
 Cached geometries that have been detached and are available for reuse.
Buffer< Modelmodels
 Cached models that have been reset and are available for reuse.

Detailed Description

A cache for reusing Model and Geometry objects to avoid repeated allocation.

DesignObjectResourceCache stores previously used Model and Geometry objects that have been reset to a default state so they can be recycled. This avoids the cost of creating and destroying design objects when the same logical slots can be reused.

Definition at line 14 of file DesignObjectResourceCache.h.

Member Function Documentation

◆ addToCache() [1/2]

void DesignObjectResourceCache::addToCache ( const Buffer< Geometry > & items)
inline

Adds a buffer of Geometry objects to the cache after detaching them from parents.

Each geometry is removed from any parent models before being stored in the cache for later reuse.

Parameters
[in]itemsThe geometries to detach and add to the cache.

Definition at line 77 of file DesignObjectResourceCache.h.

References geometries.

◆ addToCache() [2/2]

void DesignObjectResourceCache::addToCache ( const Buffer< Model > & items)
inline

Adds a buffer of Models to the cache after resetting each to defaults.

Each model is detached from its current hierarchy and reset before being stored in the cache for later reuse.

Parameters
[in]itemsThe models to reset and add to the cache.

Definition at line 62 of file DesignObjectResourceCache.h.

References models, and setModelToDefaults().

◆ createChildren()

void DesignObjectResourceCache::createChildren ( Model & parent,
uint04 size )
inline

Ensures a parent model has the specified number of children, using cached models when available.

If the cache does not have enough models to satisfy the request, the remaining children are created directly under the parent. Cached models are reattached first.

Parameters
[in]parentThe parent model to add children to.
[in]sizeThe desired number of children to create.

Definition at line 97 of file DesignObjectResourceCache.h.

References Model::createChildren(), createModel(), getMin(), and models.

◆ createGeometry()

Geometry DesignObjectResourceCache::createGeometry ( Model & parent)
inline

Creates or retrieves a Geometry for the given parent model, preferring cached geometries.

If the cache contains available geometries, the last one is removed from the cache and set as the geometry child of the parent. Otherwise a new geometry is created.

Parameters
[in]parentThe parent model to attach the geometry to.
Returns
The recycled or newly created geometry.

Definition at line 143 of file DesignObjectResourceCache.h.

References Model::createChildGeometry(), geometries, and Model::setGeometryChild().

◆ createModel()

Model DesignObjectResourceCache::createModel ( Model & parent)
inline

Creates or retrieves a child Model for the given parent, preferring cached models.

If the cache contains available models, the last one is removed from the cache and attached as a child of the parent. Otherwise a new child is created.

Parameters
[in]parentThe parent model to attach the child to.
Returns
The recycled or newly created child model.

Definition at line 119 of file DesignObjectResourceCache.h.

References Model::addChild(), Model::createChild(), and models.

Referenced by createChildren().

◆ setModelToDefaults()

void DesignObjectResourceCache::setModelToDefaults ( Model & model)
inline

Resets a Model to its default state so it can be reused from the cache.

Detaches the model from its parent, clears all children, layer, material, and geometry associations, and resets all properties to their default values.

Parameters
[in]modelThe model to reset to defaults.

Definition at line 25 of file DesignObjectResourceCache.h.

References asc_modified_time, author, calculation_ignored, can_select_children, child_base_ptr, DesignObject::clearAllMetaData(), Model::clearChildren(), Model::clearLayer(), Model::clearMaterial(), creation_time, desc_modified_time, fixed_bounding_box, Model::getParent(), is_application_owned, is_deleted, DesignObject::isValid(), library_id, modified_time, Model::removeChild(), Model::removeGeometry(), DesignObject::set(), Time::SystemTime(), transform, and type.

Referenced by addToCache().


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