Package loci.formats.cache
Class Cache
java.lang.Object
loci.formats.cache.Cache
- All Implemented Interfaces:
CacheReporter
Cache provides a means of managing subsets of large collections of image
planes in memory. Each cache has a source, which provides image planes or
other objects from somewhere (typically derived from an IFormatReader),
and a strategy dictating which image planes should be loaded into the cache,
in which order, and which planes should be dropped from the cache. The
essence of the logic is the idea that the cache has a "current" position
across the multidimensional image series's dimensional axes, with the
strategy indicating which surrounding planes to load into the cache (i.e.,
planes within a certain range along each dimensional axis).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the cache should automatically update when a parameter changes.protected Object[]Master array containing cached objects.protected int[]Current dimensional position.protected boolean[]Whether each position is currently supposed to be cached.protected Vector<CacheListener> List of cache event listeners.protected ICacheSourceCurrent cache source.protected ICacheStrategyCurrent cache strategy. -
Constructor Summary
ConstructorsConstructorDescriptionCache(ICacheStrategy strategy, ICacheSource source, boolean autoUpdate) Constructs an object cache with the given cache strategy and source. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener for status update events.Gets a list of all registered status update listeners.int[]Gets the current dimensional position.getObject(int[] pos) Gets the cached object at the given dimensional position.Gets the cache's caching source.Gets the cache's caching strategy.booleanisInCache(int pos) Returns true if the object at the given index is in the cache.booleanisInCache(int[] pos) Returns true if the object at the given dimensional position is in the cache.protected voidInforms listeners of a cache update.voidrecache()Updates all planes on the load list.voidrecache(int n) Updates the given plane.voidRemoves a listener for status update events.voidreset()Reallocates the cache.voidsetCurrentPos(int[] pos) Sets the current dimensional position.voidsetSource(ICacheSource source) Sets the cache's caching source.voidsetStrategy(ICacheStrategy strategy) Sets the cache's caching strategy.
-
Field Details
-
strategy
Current cache strategy. -
source
Current cache source. -
currentPos
protected int[] currentPosCurrent dimensional position. -
cache
Master array containing cached objects. -
inCache
protected boolean[] inCacheWhether each position is currently supposed to be cached. -
listeners
List of cache event listeners. -
autoUpdate
protected boolean autoUpdateWhether the cache should automatically update when a parameter changes.
-
-
Constructor Details
-
Cache
public Cache(ICacheStrategy strategy, ICacheSource source, boolean autoUpdate) throws CacheException Constructs an object cache with the given cache strategy and source.- Throws:
CacheException
-
-
Method Details
-
getObject
Gets the cached object at the given dimensional position.- Throws:
CacheException
-
isInCache
Returns true if the object at the given dimensional position is in the cache.- Throws:
CacheException
-
isInCache
Returns true if the object at the given index is in the cache.- Throws:
CacheException
-
reset
Reallocates the cache.- Throws:
CacheException
-
getStrategy
Gets the cache's caching strategy. -
getSource
Gets the cache's caching source. -
getCurrentPos
public int[] getCurrentPos()Gets the current dimensional position. -
setStrategy
Sets the cache's caching strategy.- Throws:
CacheException
-
setSource
Sets the cache's caching source.- Throws:
CacheException
-
setCurrentPos
Sets the current dimensional position.- Throws:
CacheException
-
recache
Updates the given plane.- Throws:
CacheException
-
recache
Updates all planes on the load list.- Throws:
CacheException
-
addCacheListener
Description copied from interface:CacheReporterAdds a listener for status update events.- Specified by:
addCacheListenerin interfaceCacheReporter
-
removeCacheListener
Description copied from interface:CacheReporterRemoves a listener for status update events.- Specified by:
removeCacheListenerin interfaceCacheReporter
-
getCacheListeners
Description copied from interface:CacheReporterGets a list of all registered status update listeners.- Specified by:
getCacheListenersin interfaceCacheReporter
-
notifyListeners
Informs listeners of a cache update.
-