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 <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 VolumeConfiggetConfig () const
 Returns the current VolumeConfig used by the cache.
std::shared_ptr< Volumeoperator() (const VolumeConfig &config)
VolumeReuseCache & operator= (const VolumeReuseCache &)=delete
VolumeReuseCache & operator= (VolumeReuseCache &&)=delete
 VolumeReuseCache (const VolumeReuseCache &)=delete
 VolumeReuseCache (VolumeReuseCache &&)=delete

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::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.

Parameters
configThe VolumeConfig to use for retrieving or creating the Volume.
Returns
std::shared_ptr<Volume> A shared pointer to a Volume instance.

The documentation for this class was generated from the following file:
  • modules/base/include/modules/base/datastructures/volumereusecache.h