Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

iCacheManager Struct Reference

A generic cache system. More...

#include <cache.h>

Inheritance diagram for iCacheManager:

iBase csVfsCacheManager List of all members.

Public Methods

virtual void SetCurrentType (const char *type)=0
 Set current type. More...

virtual const char* GetCurrentType () const=0
 Get current type or NULL if none set.

virtual void SetCurrentScope (const char *scope)=0
 Set current scope. More...

virtual const char* GetCurrentScope () const=0
 Get current scope or NULL if none set.

virtual bool CacheData (void *data, uint32 size, const char *type, const char *scope, uint32 id)=0
 Cache some data. More...

virtual iDataBufferReadCache (const char *type, const char *scope, uint32 id)=0
 Retreive some data from the cache. More...

virtual bool ClearCache (const char *type=NULL, const char *scope=NULL, const uint32 *id=NULL)=0
 Clear items from the cache. More...


Detailed Description

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. 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 NULL for type and/or scope in CacheData() and ReadCache(). If you don't use NULL then the given value will override the default values.


Member Function Documentation

bool iCacheManager::CacheData ( void * data,
uint32 size,
const char * type,
const char * scope,
uint32 id ) [pure virtual]
 

Cache some data.

Returns true if this succeeded.

Reimplemented in csVfsCacheManager.

bool iCacheManager::ClearCache ( const char * type = NULL,
const char * scope = NULL,
const uint32 * id = NULL ) [pure virtual]
 

Clear items from the cache.

There are four ways to call this function:

  • NULL, NULL, NULL: clear entire cache.
  • 'type', NULL, NULL: clear everything of this type.
  • 'type', 'scope', NULL: 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.

Reimplemented in csVfsCacheManager.

iDataBuffer * iCacheManager::ReadCache ( const char * type,
const char * scope,
uint32 id ) [pure virtual]
 

Retreive some data from the cache.

Returns NULL if the data could not be found in the cache. The returned data buffer should be DecRef()'ed if you are ready with it.

Reimplemented in csVfsCacheManager.

void iCacheManager::SetCurrentScope ( const char * scope ) [pure virtual]
 

Set current scope.

This will be used in CacheData() and ReadCache() when the given 'scope' there is NULL.

Reimplemented in csVfsCacheManager.

void iCacheManager::SetCurrentType ( const char * type ) [pure virtual]
 

Set current type.

This will be used in CacheData() and ReadCache() when the given 'type' there is NULL.

Reimplemented in csVfsCacheManager.


The documentation for this struct was generated from the following file:
Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000