public class Cache extends java.lang.Object implements CacheReporter
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoUpdate
Whether the cache should automatically update when a parameter changes.
|
protected java.lang.Object[] |
cache
Master array containing cached objects.
|
protected int[] |
currentPos
Current dimensional position.
|
protected boolean[] |
inCache
Whether each position is currently supposed to be cached.
|
protected java.util.Vector<CacheListener> |
listeners
List of cache event listeners.
|
protected ICacheSource |
source
Current cache source.
|
protected ICacheStrategy |
strategy
Current cache strategy.
|
Constructor and Description |
---|
Cache(ICacheStrategy strategy,
ICacheSource source,
boolean autoUpdate)
Constructs an object cache with the given cache strategy and source.
|
Modifier and Type | Method and Description |
---|---|
void |
addCacheListener(CacheListener l)
Adds a listener for status update events.
|
CacheListener[] |
getCacheListeners()
Gets a list of all registered status update listeners.
|
int[] |
getCurrentPos()
Gets the current dimensional position.
|
java.lang.Object |
getObject(int[] pos)
Gets the cached object at the given dimensional position.
|
ICacheSource |
getSource()
Gets the cache's caching source.
|
ICacheStrategy |
getStrategy()
Gets the cache's caching strategy.
|
boolean |
isInCache(int pos)
Returns true if the object at the given index is in the cache.
|
boolean |
isInCache(int[] pos)
Returns true if the object at the given dimensional position is
in the cache.
|
protected void |
notifyListeners(CacheEvent e)
Informs listeners of a cache update.
|
void |
recache()
Updates all planes on the load list.
|
void |
recache(int n)
Updates the given plane.
|
void |
removeCacheListener(CacheListener l)
Removes a listener for status update events.
|
void |
reset()
Reallocates the cache.
|
void |
setCurrentPos(int[] pos)
Sets the current dimensional position.
|
void |
setSource(ICacheSource source)
Sets the cache's caching source.
|
void |
setStrategy(ICacheStrategy strategy)
Sets the cache's caching strategy.
|
protected ICacheStrategy strategy
protected ICacheSource source
protected int[] currentPos
protected java.lang.Object[] cache
protected boolean[] inCache
protected java.util.Vector<CacheListener> listeners
protected boolean autoUpdate
public Cache(ICacheStrategy strategy, ICacheSource source, boolean autoUpdate) throws CacheException
CacheException
public java.lang.Object getObject(int[] pos) throws CacheException
CacheException
public boolean isInCache(int[] pos) throws CacheException
CacheException
public boolean isInCache(int pos) throws CacheException
CacheException
public void reset() throws CacheException
CacheException
public ICacheStrategy getStrategy()
public ICacheSource getSource()
public int[] getCurrentPos()
public void setStrategy(ICacheStrategy strategy) throws CacheException
CacheException
public void setSource(ICacheSource source) throws CacheException
CacheException
public void setCurrentPos(int[] pos) throws CacheException
CacheException
public void recache(int n) throws CacheException
CacheException
public void recache() throws CacheException
CacheException
public void addCacheListener(CacheListener l)
CacheReporter
addCacheListener
in interface CacheReporter
public void removeCacheListener(CacheListener l)
CacheReporter
removeCacheListener
in interface CacheReporter
public CacheListener[] getCacheListeners()
CacheReporter
getCacheListeners
in interface CacheReporter
protected void notifyListeners(CacheEvent e)
Copyright © 2024 Open Microscopy Environment