CrystalSpace

Public API Reference

iCacheManager Struct Reference

A generic cache system. More...

#include <iutil/cache.h>

Inheritance diagram for iCacheManager:

List of all members.

Public Member Functions

virtual bool CacheData (const void *data, size_t size, const char *type, const char *scope, uint32 id)=0
 Cache some data.
virtual bool ClearCache (const char *type=0, const char *scope=0, const uint32 *id=0)=0
 Clear items from the cache.
virtual void Flush ()=0
 Ensure that the cached data is written on whatever medium is behind the cache.
virtual const char * GetCurrentScope () const =0
 Get current scope or 0 if none set.
virtual const char * GetCurrentType () const =0
 Get current type or 0 if none set.
virtual bool IsReadOnly () const =0
 Is the cache manager read-only?
virtual csPtr< iDataBufferReadCache (const char *type, const char *scope, uint32 id)=0
 Retrieve some data from the cache.
virtual void SetCurrentScope (const char *scope)=0
 Set current scope.
virtual void SetCurrentType (const char *type)=0
 Set current type.
virtual void SetReadOnly (bool ro)=0
 Force the cache manager to be read-only.

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. ~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.

Definition at line 52 of file cache.h.


Member Function Documentation

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

Cache some data.

Returns true if this succeeded.

Implemented in csNullCacheManager, and csVfsCacheManager.

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

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.

virtual void iCacheManager::Flush (  )  [pure virtual]

Ensure that the cached data is written on whatever medium is behind the cache.

Implemented in csNullCacheManager, and csVfsCacheManager.

virtual const char* iCacheManager::GetCurrentScope (  )  const [pure virtual]

Get current scope or 0 if none set.

Implemented in csNullCacheManager, and csVfsCacheManager.

virtual const char* iCacheManager::GetCurrentType (  )  const [pure virtual]

Get current type or 0 if none set.

Implemented in csNullCacheManager, and csVfsCacheManager.

virtual bool iCacheManager::IsReadOnly (  )  const [pure virtual]

Is the cache manager read-only?

Implemented in csNullCacheManager, and csVfsCacheManager.

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

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.

virtual 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 0.

Implemented in csNullCacheManager, and csVfsCacheManager.

virtual 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 0.

Implemented in csNullCacheManager, and csVfsCacheManager.

virtual void iCacheManager::SetReadOnly ( bool  ro  )  [pure virtual]

Force the cache manager to be read-only.

This will prevent updates of the cache but CacheData() will still return true to indicate success.

Implemented in csNullCacheManager, and csVfsCacheManager.


The documentation for this struct was generated from the following file:

Generated for Crystal Space 2.1 by doxygen 1.6.1