![]() |
Inviwo 0.9.12-pre
Inviwo documentation
|
Provides a cache for reusing Volume objects with a specific configuration. More...
#include <volumereusecache.h>
Public Member Functions | |
VolumeReuseCache (VolumeConfig config={}) | |
VolumeReuseCache (const VolumeReuseCache &)=delete | |
VolumeReuseCache (VolumeReuseCache &&)=delete | |
VolumeReuseCache & | operator= (const VolumeReuseCache &)=delete |
VolumeReuseCache & | operator= (VolumeReuseCache &&)=delete |
const VolumeConfig & | getConfig () const |
Returns the current VolumeConfig used by the cache. | |
void | setConfig (const VolumeConfig &config) |
Sets a new VolumeConfig for the cache. | |
std::shared_ptr< Volume > | get () |
Retrieves a Volume from the cache or creates a new one if none are available. |
Provides a cache for reusing Volume objects with a specific configuration.
The VolumeReuseCache class manages a pool of Volume objects that share the same VolumeConfig. This allows for efficient reuse of Volume instances, reducing the overhead of frequent allocations and deallocations. The cache is initialized with a given VolumeConfig, which can be updated at runtime. When a Volume is requested via get(), the cache will return an existing Volume if available, or create a new one if the cache is empty.
Copy and move operations are disabled to ensure unique ownership of the cache.
Example usage:
std::shared_ptr< Volume > inviwo::VolumeReuseCache::get | ( | ) |
Retrieves a Volume from the cache or creates a new one if none are available.
Returns a shared pointer to a Volume object matching the current configuration. If the cache contains available Volumes, one is reused; otherwise, a new Volume is created. After the volume is reused, call Volume::discardHistograms() to have them recalculated.
void inviwo::VolumeReuseCache::setConfig | ( | const VolumeConfig & | config | ) |
Sets a new VolumeConfig for the cache.
Updates the configuration used for creating new Volume objects. If the existing config does not match the new config, existing volumes will be discarded and new Volumes will be created as needed.
config | The new VolumeConfig to use. |