CrystalSpace

Public API Reference

CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition > Class Template Reference

Generic cache for resources. More...

#include <csutil/genericresourcecache.h>

List of all members.

Public Member Functions

T * AddActive (const T &value, const ReuseConditionAddParameter &reuseParam=ReuseConditionAddParameter(), const PurgeConditionAddParameter &purgeParam=PurgeConditionAddParameter())
 Add a resource as currently active.
void AdvanceTime (TimeType time)
 Advance the time kept by the cache.
void Clear (bool instaClear=false)
 Clear all cached resources.
PurgeCondition::StoredAuxiliaryInfo * GetPurgeAuxiliary (T *entry)
 Request the auxiliary information data of the purge condition mixin for a cache entry.
ReuseCondition::StoredAuxiliaryInfo * GetReuseAuxiliary (T *entry)
 Request the auxiliary information data of the reuse condition mixin for a cache entry.
void NudgeLastUsedTime (T *data)
 Change the last used time of a resource to the current time.
T * Query (const ResourceSortingKeyType &key=ResourceSortingKeyType(), bool exact=false)
 Query a resource. Returns 0 if none is available.
void RemoveActive (T *data)
 Free up a resource which is currently "active".
void SetAvailable (T *data)
 Manually mark a resource that is currently "active" as "available".

Public Attributes

TimeType agedPurgeInterval
 Interval for the aged resource scan.

Protected Attributes

bool clearReq
 Whether a "clear" is pending.
TimeType lastPurgeAged
 The last time the momentarily available resources were scanned for "aged" (long time unused) resources that could be freed.

Detailed Description

template<typename T, typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
class CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >

Generic cache for resources.

It can cache frequently needed, reuseable data, can fetch cached resources based on a given sorting (not just exact matches, also resources that are bigger than some given key) and free resources that were cached but not used for some time.

Definition at line 197 of file genericresourcecache.h.


Member Function Documentation

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
T* CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::AddActive ( const T &  value,
const ReuseConditionAddParameter &  reuseParam = ReuseConditionAddParameter (),
const PurgeConditionAddParameter &  purgeParam = PurgeConditionAddParameter () 
) [inline]

Add a resource as currently active.

(But will be reused once possible.)

Definition at line 537 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
void CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::AdvanceTime ( TimeType  time  )  [inline]

Advance the time kept by the cache.

Determines what resources can be reused or even freed.

Definition at line 462 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
void CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::Clear ( bool  instaClear = false  )  [inline]

Clear all cached resources.

instaClear immediately clears all resources when set, if not, clearing is delayed until the next AdvanceTime() call (useful when resources may still be in use).

Definition at line 421 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
PurgeCondition::StoredAuxiliaryInfo* CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::GetPurgeAuxiliary ( T *  entry  )  [inline]

Request the auxiliary information data of the purge condition mixin for a cache entry.

Definition at line 606 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
ReuseCondition::StoredAuxiliaryInfo* CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::GetReuseAuxiliary ( T *  entry  )  [inline]

Request the auxiliary information data of the reuse condition mixin for a cache entry.

Definition at line 596 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
void CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::NudgeLastUsedTime ( T *  data  )  [inline]

Change the last used time of a resource to the current time.

Can be used to prevent resources which are tracked as "available" from being purged.

Warning:
Never, ever, ever pass a resource which did *not* came from the instance of the cache you call this method on. Not heeding this warning will result in memory corruption.

Definition at line 558 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
T* CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::Query ( const ResourceSortingKeyType &  key = ResourceSortingKeyType(),
bool  exact = false 
) [inline]

Query a resource. Returns 0 if none is available.

Definition at line 512 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
void CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::RemoveActive ( T *  data  )  [inline]

Free up a resource which is currently "active".

Definition at line 584 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
void CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::SetAvailable ( T *  data  )  [inline]

Manually mark a resource that is currently "active" as "available".

Warning:
Never, ever, ever pass a resource which did *not* came from the instance of the cache you call this method on. Not heeding this warning will result in memory corruption.

Definition at line 572 of file genericresourcecache.h.


Member Data Documentation

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
TimeType CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::agedPurgeInterval

Interval for the aged resource scan.

Definition at line 401 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
bool CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::clearReq [protected]

Whether a "clear" is pending.

Definition at line 348 of file genericresourcecache.h.

template<typename T , typename _TimeType = uint, typename _ResourceSorting = ResourceCache::SortingNone, typename _ReuseCondition = ResourceCache::ReuseConditionAfterTime<_TimeType>, typename _PurgeCondition = ResourceCache::PurgeConditionAfterTime<_TimeType>>
TimeType CS::Utility::GenericResourceCache< T, _TimeType, _ResourceSorting, _ReuseCondition, _PurgeCondition >::lastPurgeAged [protected]

The last time the momentarily available resources were scanned for "aged" (long time unused) resources that could be freed.

Definition at line 346 of file genericresourcecache.h.


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

Generated for Crystal Space 1.4.1 by doxygen 1.7.1