proland::LazyGraph::GraphCache< T > Class Template Reference

Templated cache used to store unused graph items (nodes, curves, areas. More...

#include <LazyGraph.h>

List of all members.

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

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

Detailed Description

template<typename T>
class proland::LazyGraph::GraphCache< T >

Templated cache used to store unused graph items (nodes, curves, areas.

.).


Constructor & Destructor Documentation

template<typename T>
proland::LazyGraph::GraphCache< T >::GraphCache ( Graph g,
unsigned int  size = 0 
) [inline, private]

Creates a new GraphCache.

Parameters:
g graph that uses this cache.
size the cache size : number of items it can contain (doesn't include modified items).
template<typename T>
proland::LazyGraph::GraphCache< T >::~GraphCache (  )  [inline, private]

Deletes this GraphCache.


Member Function Documentation

template<typename T>
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.

Parameters:
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.
template<typename T>
bool proland::LazyGraph::GraphCache< T >::remove ( ptr< T >  t  )  [inline]

Removes a resource from the cache, if found.

Parameters:
t the resource to remove.
Returns:
true if the resource was in the cache. Otherwise, returns false.

Member Data Documentation

template<typename T>
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.

template<typename T>
Graph* proland::LazyGraph::GraphCache< T >::owner [private]

Graph that uses this cache.

template<typename T>
unsigned int proland::LazyGraph::GraphCache< T >::size [private]

Maximum size of the cache.

template<typename T>
map<ptr<T>, typename list<ptr<T> >::iterator> proland::LazyGraph::GraphCache< T >::unusedResources [private]

Complete list of unused resources.

template<typename T>
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.


Generated on Sat May 12 09:42:48 2012 for proland by  doxygen 1.6.1