![]() |
Inviwo 0.9.12-pre
Inviwo documentation
|
Provides a cache for reusing Volume objects with a specific configuration. More...
#include <modules/base/datastructures/volumereusecache.h>
Public Types | |
| enum class | Status : std::uint8_t { NoChange , ClearedCache } |
Public Member Functions | |
| std::pair< std::shared_ptr< Volume >, Status > | get (const VolumeConfig &config) |
| Retrieves a Volume from the cache or creates a new one if none are available. | |
| const VolumeConfig & | getConfig () const |
| Returns the current VolumeConfig used by the cache. | |
| std::shared_ptr< Volume > | operator() (const VolumeConfig &config) |
| VolumeReuseCache & | operator= (const VolumeReuseCache &)=delete |
| VolumeReuseCache & | operator= (VolumeReuseCache &&)=delete |
| VolumeReuseCache (const VolumeReuseCache &)=delete | |
| VolumeReuseCache (VolumeReuseCache &&)=delete | |
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::pair< std::shared_ptr< Volume >, Status > inviwo::VolumeReuseCache::get | ( | const VolumeConfig & | config | ) |
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 given 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.
| config | The VolumeConfig to use for retrieving or creating the Volume. |