version 3.3

VRS::CachedResource< KEY, RESOURCE > Class Template Reference

#include <vrs/container/cachedresource.h>

Inheritance diagram for VRS::CachedResource< KEY, RESOURCE >:

VRS::SharedObj VRS::Visitable VRS::CachedEngineResource< KEY, RESOURCE >

List of all members.

Public Member Functions

 CachedResource (unsigned int frames=10)
bool contains (const KEY &)
RESOURCE & find (const KEY &)
RESOURCE & operator[] (const KEY &)
void insert (const KEY &, const RESOURCE &)
virtual void cleanUp ()

Classes

struct  InternalResourceData


Detailed Description

template<typename KEY, typename RESOURCE>
class VRS::CachedResource< KEY, RESOURCE >

std::map-like Dictionary class for caching intermediate data that can be used over several frames, but which is cleared if the data has not been used for longer time.

Constructor & Destructor Documentation

template<typename KEY, typename RESOURCE>
VRS::CachedResource< KEY, RESOURCE >::CachedResource ( unsigned int  frames = 10  ) 

For each key-data pair in the dictionary, an internal counter is maintained. Each time a resource is access via a key, the counter is reset; for each call of cleanUp(), all counters in the dictionary are incremented. When, in cleanUp, one counter becomes greater or equal than the constructor-argument frames, the corresponding key-data pair is removed from the dictionary.


Member Function Documentation

template<typename KEY, typename RESOURCE>
bool VRS::CachedResource< KEY, RESOURCE >::contains ( const KEY &   ) 

Checks whether an entry with the key is currently cached. Does NOT increase the counter!

template<typename KEY, typename RESOURCE>
RESOURCE& VRS::CachedResource< KEY, RESOURCE >::find ( const KEY &   ) 

Returns the resource that is stored for the key. Assert when the key is not found.

template<typename KEY, typename RESOURCE>
RESOURCE& VRS::CachedResource< KEY, RESOURCE >::operator[] ( const KEY &   ) 

Returns the resource that is stored for the key, or, if the key is not yet contained in the dictionary, creates a new resource, stores it among with the key, and returns the new resource.

template<typename KEY, typename RESOURCE>
void VRS::CachedResource< KEY, RESOURCE >::insert ( const KEY &  ,
const RESOURCE &   
)

Inserts a new key-data pair into the dictionary.

template<typename KEY, typename RESOURCE>
virtual void VRS::CachedResource< KEY, RESOURCE >::cleanUp (  )  [virtual]

This method increases counters for all key-data pairs, and removes those entries that have not been accessed for m_frames invokations of cleanUp. cleanUp will be typically called once per frame or time interval.


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

Generated on Fri May 18 06:00:18 2012 by Doxygen 1.5.6
© 2001-2010 Hasso-Plattner-Institut | Impressum | Contact