|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.asset.cache.SimpleAssetCache
public class SimpleAssetCache
SimpleAssetCache
is an asset cache
that caches assets without any automatic removal policy. The user
is expected to manually call deleteFromCache(com.jme3.asset.AssetKey)
to delete any assets.
Constructor Summary | |
---|---|
SimpleAssetCache()
|
Method Summary | ||
---|---|---|
|
addToCache(AssetKey<T> key,
T obj)
Adds an asset to the cache. |
|
void |
clearCache()
Deletes all assets from the cache. |
|
boolean |
deleteFromCache(AssetKey key)
Deletes an asset from the cache. |
|
|
getFromCache(AssetKey<T> key)
Retrieves an asset from the cache. |
|
void |
notifyNoAssetClone()
Notifies the cache that even though the methods AssetCache.addToCache(com.jme3.asset.AssetKey, java.lang.Object)
or AssetCache.getFromCache(com.jme3.asset.AssetKey) were used, there won't
be a call to AssetCache.registerAssetClone(com.jme3.asset.AssetKey, java.lang.Object)
for some reason. |
|
|
registerAssetClone(AssetKey<T> key,
T clone)
This should be called by the asset manager when it has successfully acquired a cached asset (with AssetCache.getFromCache(com.jme3.asset.AssetKey) )
and cloned it for use. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleAssetCache()
Method Detail |
---|
public <T> void addToCache(AssetKey<T> key, T obj)
AssetCache
AssetCache.getFromCache(com.jme3.asset.AssetKey)
method.
However the caching criteria may at some point choose that the asset
should be removed from the cache to save memory, in that case,
AssetCache.getFromCache(com.jme3.asset.AssetKey)
will return null.
Thread-Safe
addToCache
in interface AssetCache
T
- The type of the asset to cache.key
- The asset key that can be used to look up the asset.obj
- The asset data to cache.public <T> void registerAssetClone(AssetKey<T> key, T clone)
AssetCache
AssetCache.getFromCache(com.jme3.asset.AssetKey)
)
and cloned it for use.
Thread-Safe
registerAssetClone
in interface AssetCache
T
- The type of the asset to register.key
- The asset key of the loaded asset (used to retrieve from cache)clone
- The clone of the asset retrieved from
the cache.public <T> T getFromCache(AssetKey<T> key)
AssetCache
AssetCache.addToCache(com.jme3.asset.AssetKey, java.lang.Object)
.
The asset may be removed from the cache automatically even if
it was added previously, in that case, this method will return null.
Thread-Safe
getFromCache
in interface AssetCache
T
- The type of the asset to retrievekey
- The key used to lookup the asset.
public boolean deleteFromCache(AssetKey key)
AssetCache
Thread-Safe
deleteFromCache
in interface AssetCache
key
- The asset key to find the asset to delete.
public void clearCache()
AssetCache
Thread-Safe
clearCache
in interface AssetCache
public void notifyNoAssetClone()
AssetCache
AssetCache.addToCache(com.jme3.asset.AssetKey, java.lang.Object)
or AssetCache.getFromCache(com.jme3.asset.AssetKey)
were used, there won't
be a call to AssetCache.registerAssetClone(com.jme3.asset.AssetKey, java.lang.Object)
for some reason. For example, if an error occurred during loading
or if the addToCache/getFromCache were used from user code.
notifyNoAssetClone
in interface AssetCache
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |