Templated cache used to store unused graph items (nodes, curves, areas. More...
#include <LazyGraph.h>
Public Member Functions | |
bool | remove (ptr< T > t) |
Removes a resource from the cache, if found. | |
void | add (T *t, bool modified=false) |
Adds a resource to the cache. | |
Private Member Functions | |
GraphCache (Graph *g, unsigned int size=0) | |
Creates a new GraphCache. | |
~GraphCache () | |
Deletes this GraphCache. | |
Private Attributes | |
Graph * | owner |
Graph that uses this cache. | |
list< ptr< T > > | unusedResourcesOrder |
This lists allows to get the least recently used item in order to delete it when cache is full. | |
map< ptr< T >, typename list < ptr< T > >::iterator > | unusedResources |
Complete list of unused resources. | |
set< ptr< T > > | changedResources |
Complete list of changed resources. | |
unsigned int | size |
Maximum size of the cache. |
Templated cache used to store unused graph items (nodes, curves, areas.
.).
proland::LazyGraph::GraphCache< T >::GraphCache | ( | Graph * | g, | |
unsigned int | size = 0 | |||
) | [inline, private] |
Creates a new GraphCache.
g | graph that uses this cache. | |
size | the cache size : number of items it can contain (doesn't include modified items). |
proland::LazyGraph::GraphCache< T >::~GraphCache | ( | ) | [inline, private] |
Deletes this GraphCache.
void proland::LazyGraph::GraphCache< T >::add | ( | T * | t, | |
bool | modified = false | |||
) | [inline] |
Adds a resource to the cache.
If required (when cache is full), it will delete the least recently used item.
t | the resource to add. | |
modified | whether the resource was changed or not. This enables LazyGraphs to keep changed items in memory, instead of eventually deleting them and restoring an outdated version. |
bool proland::LazyGraph::GraphCache< T >::remove | ( | ptr< T > | t | ) | [inline] |
Removes a resource from the cache, if found.
t | the resource to remove. |
set<ptr<T> > proland::LazyGraph::GraphCache< T >::changedResources [private] |
Complete list of changed resources.
These resources doesn't count in the number of unused resources.
Graph* proland::LazyGraph::GraphCache< T >::owner [private] |
Graph that uses this cache.
unsigned int proland::LazyGraph::GraphCache< T >::size [private] |
Maximum size of the cache.
map<ptr<T>, typename list<ptr<T> >::iterator> proland::LazyGraph::GraphCache< T >::unusedResources [private] |
Complete list of unused resources.
list<ptr<T> > proland::LazyGraph::GraphCache< T >::unusedResourcesOrder [private] |
This lists allows to get the least recently used item in order to delete it when cache is full.