| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/container/cachedresource.h>

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 |
| 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.
| bool VRS::CachedResource< KEY, RESOURCE >::contains | ( | const KEY & | ) |
Checks whether an entry with the key is currently cached. Does NOT increase the counter!
| RESOURCE& VRS::CachedResource< KEY, RESOURCE >::find | ( | const KEY & | ) |
Returns the resource that is stored for the key. Assert when the key is not found.
| 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.
| void VRS::CachedResource< KEY, RESOURCE >::insert | ( | const KEY & | , | |
| const RESOURCE & | ||||
| ) |
Inserts a new key-data pair into the dictionary.
| 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.