Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::VolumeReuseCache Class Reference

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
VolumeReuseCacheoperator= (const VolumeReuseCache &)=delete
VolumeReuseCacheoperator= (VolumeReuseCache &&)=delete
const VolumeConfiggetConfig () const
 Returns the current VolumeConfig used by the cache.
void setConfig (const VolumeConfig &config)
 Sets a new VolumeConfig for the cache.
std::shared_ptr< Volumeget ()
 Retrieves a Volume from the cache or creates a new one if none are available.

Detailed Description

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:

VolumeReuseCache cache(config);
auto volume = cache.get();
See also
Volume
VolumeConfig

Member Function Documentation

◆ get()

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.

Returns
std::shared_ptr<Volume> A shared pointer to a Volume instance.

◆ setConfig()

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.

Parameters
configThe new VolumeConfig to use.

The documentation for this class was generated from the following file:
  • volumereusecache.h