crystalspace.jbind.interfaces.iutil.cache
Interface iCacheManager

All Superinterfaces:
iBase, iPointer
All Known Implementing Classes:
csCacheManager

public interface iCacheManager
extends iBase

A generic cache system. A client can use this to cache data that was hard to calculate. The data is not converted in any way so it is the responsability of the client to correct platform depending issues like endianess and structure padding. Every item in a cache has a 'type', a 'scope', and a unique id. The 'type' can be something like 'lightmap', 'octree', ... The 'scope' can be something like 'myRegion_mySector', ... The 'id' is a unique ID for the cached item in the given type and scope. ~0 can be taken for the cases "no ID" or "ID unused". Avoid using '/' and '\' characters in both type and scope as this may cause conflicts with the given cache (if it caches on a file system for example). Note that both 'type' and 'scope' can be made default using SetCurrentType() and SetCurrentScope(). If those are set then you can use 0 for type and/or scope in CacheData() and ReadCache(). If you don't use 0 then the given value will override the default values.

Author:
Java wrapper - Quentin Anciaux, c++ version - http://crystal.sourceforge.net/docs/online/devapi/structiCacheManager.php

Method Summary
 boolean cacheData(iPointer data, int size, java.lang.String type, java.lang.String scope, int id)
          Cache some data.
 boolean clearCache()
          Clear items from the cache.
 boolean clearCache(java.lang.String type)
          Clear items from the cache.
 boolean clearCache(java.lang.String type, java.lang.String scope)
          Clear items from the cache.
 boolean clearCache(java.lang.String type, java.lang.String scope, int id)
          Clear items from the cache.
 java.lang.String getCurrentScope()
          Get current scope or 0 if none set.
 java.lang.String getCurrentType()
          Get current type or 0 if none set.
 iDataBuffer readCache(java.lang.String type, java.lang.String scope, int id)
          Retrieve some data from the cache.
 void setCurrentScope(java.lang.String scope)
          Set current scope.
 void setCurrentType(java.lang.String type)
          Set current type.
 
Methods inherited from interface crystalspace.jbind.interfaces.iutil.scf.iBase
decRef, getName, getRefCount, getVersion, incRef, queryInterface, queryInterfaceSafe
 
Methods inherited from interface crystalspace.jbind.interfaces.iPointer
changePointer, getPointer, isMemoryOwner, setMemoryOwner
 

Method Detail

cacheData

public boolean cacheData(iPointer data,
                         int size,
                         java.lang.String type,
                         java.lang.String scope,
                         int id)
Cache some data. Returns true if this succeeded. Implemented in csNullCacheManager, and csVfsCacheManager.

Parameters:
data -
size -
type -
scope -
id -
Returns:

clearCache

public boolean clearCache()
Clear items from the cache. There are four ways to call this function: * 0, 0, 0: clear entire cache. * 'type', 0, 0: clear everything of this type. * 'type', 'scope', 0: clear everything of this type and scope. * 'type', 'scope', id: clear the specific item. Returns true if items were deleted. Returns false if item was not found or deletion is not possible. Implemented in csNullCacheManager, and csVfsCacheManager.

Returns:

clearCache

public boolean clearCache(java.lang.String type)
Clear items from the cache. There are four ways to call this function: * 0, 0, 0: clear entire cache. * 'type', 0, 0: clear everything of this type. * 'type', 'scope', 0: clear everything of this type and scope. * 'type', 'scope', id: clear the specific item. Returns true if items were deleted. Returns false if item was not found or deletion is not possible. Implemented in csNullCacheManager, and csVfsCacheManager.

Parameters:
type -
Returns:

clearCache

public boolean clearCache(java.lang.String type,
                          java.lang.String scope)
Clear items from the cache. There are four ways to call this function: * 0, 0, 0: clear entire cache. * 'type', 0, 0: clear everything of this type. * 'type', 'scope', 0: clear everything of this type and scope. * 'type', 'scope', id: clear the specific item. Returns true if items were deleted. Returns false if item was not found or deletion is not possible. Implemented in csNullCacheManager, and csVfsCacheManager.

Parameters:
type -
scope -
Returns:

clearCache

public boolean clearCache(java.lang.String type,
                          java.lang.String scope,
                          int id)
Clear items from the cache. There are four ways to call this function: * 0, 0, 0: clear entire cache. * 'type', 0, 0: clear everything of this type. * 'type', 'scope', 0: clear everything of this type and scope. * 'type', 'scope', id: clear the specific item. Returns true if items were deleted. Returns false if item was not found or deletion is not possible. Implemented in csNullCacheManager, and csVfsCacheManager.

Parameters:
type -
scope -
id -
Returns:

getCurrentScope

public java.lang.String getCurrentScope()
Get current scope or 0 if none set. Implemented in csNullCacheManager, and csVfsCacheManager.

Returns:

getCurrentType

public java.lang.String getCurrentType()
Get current type or 0 if none set. Implemented in csNullCacheManager, and csVfsCacheManager.

Returns:

readCache

public iDataBuffer readCache(java.lang.String type,
                             java.lang.String scope,
                             int id)
Retrieve some data from the cache. Returns 0 if the data could not be found in the cache. Remarks: Returned buffer is NOT null-terminated. Don't modify returned buffer! Implemented in csNullCacheManager, and csVfsCacheManager.

Parameters:
type -
scope -
id -
Returns:

setCurrentScope

public void setCurrentScope(java.lang.String scope)
Set current scope. This will be used in CacheData(); and ReadCache(); when the given 'scope' there is 0. Implemented in csNullCacheManager, and csVfsCacheManager.

Parameters:
scope -

setCurrentType

public void setCurrentType(java.lang.String type)
Set current type. This will be used in CacheData(); and ReadCache(); when the given 'type' there is 0. Implemented in csNullCacheManager, and csVfsCacheManager.

Parameters:
type -