![]() |
NDEVR
API Documentation
|
A cache for reusing Model and Geometry objects to avoid repeated allocation. More...
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< Geometry > | geometries |
| Cached geometries that have been detached and are available for reuse. | |
| Buffer< Model > | models |
| Cached models that have been reset and are available for reuse. | |
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.
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.
| [in] | items | The geometries to detach and add to the cache. |
Definition at line 77 of file DesignObjectResourceCache.h.
References geometries.
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.
| [in] | items | The models to reset and add to the cache. |
Definition at line 62 of file DesignObjectResourceCache.h.
References models, and setModelToDefaults().
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.
| [in] | parent | The parent model to add children to. |
| [in] | size | The desired number of children to create. |
Definition at line 97 of file DesignObjectResourceCache.h.
References Model::createChildren(), createModel(), getMin(), and models.
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.
| [in] | parent | The parent model to attach the geometry to. |
Definition at line 143 of file DesignObjectResourceCache.h.
References Model::createChildGeometry(), geometries, and Model::setGeometryChild().
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.
| [in] | parent | The parent model to attach the child to. |
Definition at line 119 of file DesignObjectResourceCache.h.
References Model::addChild(), Model::createChild(), and models.
Referenced by createChildren().
|
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.
| [in] | model | The 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().