Cache that manages the precomputed Graphs (including root Graph). More...
#include <GraphProducer.h>
Inherits Object.
Public Member Functions | |
GraphCache (GraphPtr root, string graphName, ptr< ResourceManager > manager, bool loadSubgraphs=false) | |
Creates a new GraphCache. | |
~GraphCache () | |
Deletes this GraphCache. | |
GraphPtr | getTile (TileCache::Tile::Id tileId) |
Returns the graph corresponding to a precomputed Tile. | |
void | add (TileCache::Tile::Id id, GraphPtr graph) |
Adds a graph to the cache and save it to the disk. | |
Private Attributes | |
bool | loadSubgraphs |
Determines whether to load subgraphs or not. | |
string | graphName |
The name of the file from which we loaded the root Graph. | |
ptr< ResourceManager > | manager |
The resource manager used to load .graph files. | |
map< TileCache::Tile::Id, GraphPtr > | graphs |
Maps Tile Ids with Graphs. |
Cache that manages the precomputed Graphs (including root Graph).
It can load directly from the disk every tiles at a given level. If the file doesn't exist, the tile will be created from the root Graph (in GraphProducer::doCreateTile()) and then stored in cache and saved to disk.
proland::GraphProducer::GraphCache::GraphCache | ( | GraphPtr | root, | |
string | graphName, | |||
ptr< ResourceManager > | manager, | |||
bool | loadSubgraphs = false | |||
) |
Creates a new GraphCache.
root | the root Graph. | |
graphName | the name of the file from which we loaded the root Graph. This is used to load and save the Graphs at level GraphProducer::precomputedLevel, if different from 0. | |
manager | the resource manager that will load the .graph files. | |
loadSubgraphs | whether to load subgraphs or not. |
proland::GraphProducer::GraphCache::~GraphCache | ( | ) |
Deletes this GraphCache.
void proland::GraphProducer::GraphCache::add | ( | TileCache::Tile::Id | id, | |
GraphPtr | graph | |||
) |
Adds a graph to the cache and save it to the disk.
id | the id of the tile to add. | |
graph | the corresponding Graph. |
GraphPtr proland::GraphProducer::GraphCache::getTile | ( | TileCache::Tile::Id | tileId | ) |
Returns the graph corresponding to a precomputed Tile.
If it's in cache, it just returns it. If not, it checks if it can load and return it. If it's not available, returns NULL. It will then be recomputed from the root Tile in GraphProducer, added to the cache, and saved on the disk.
tileId | the id of the tile to load. |
string proland::GraphProducer::GraphCache::graphName [private] |
The name of the file from which we loaded the root Graph.
This is used to load and save the Graphs at level GraphProducer::precomputedLevel, if different from 0.
map<TileCache::Tile::Id, GraphPtr> proland::GraphProducer::GraphCache::graphs [private] |
Maps Tile Ids with Graphs.
bool proland::GraphProducer::GraphCache::loadSubgraphs [private] |
Determines whether to load subgraphs or not.
ptr<ResourceManager> proland::GraphProducer::GraphCache::manager [private] |
The resource manager used to load .graph files.