Class used to manager the graph data elements. This class uses a cache policy to control the elements in memory. If a element was requested and not found in cache, the GraphDataManager is used to loaded a new GraphData. More...
#include <GraphCache.h>
Public Member Functions | |
| GraphCache (AbstractCachePolicy *cp, GraphDataManager *dm) | |
| Default constructor. More... | |
| ~GraphCache () | |
| Default destructor. More... | |
Graph Cache Manager Methods | |
Method used to manager a graph data | |
| GraphData * | getGraphDataByVertexId (int id) |
| Get a graph data from vector using a vertex id information. if not found a new graph data has to be loaded using AbstractDataManager. More... | |
| GraphData * | getGraphDataByEdgeId (int id) |
| Get a graph data from vector using a edge id information. if not found a new graph data has to be loaded using AbstractDataManager. More... | |
| GraphData * | getGraphData () |
| Get a graph data. More... | |
| GraphData * | createGraphData () |
| Creates a new graph data structure. More... | |
| void | removeGraphData (int idx) |
| Used to remove a graph data from cache. More... | |
| void | saveGraphData (GraphData *data) |
| Save the graph data structure inside a data source. More... | |
| void | clearCache () |
| Used to remove from memory all elements loaded. More... | |
| GraphData * | checkCacheByVertexId (int id) |
| This functions check in cache if the vertex element with a given id was alredy in memory. More... | |
| GraphData * | checkCacheByEdgeId (int id) |
| This functions check in cache if the edge element with a given id was alredy in memory. More... | |
Protected Member Functions | |
| int | getGraphDataId () |
| Protected function used to define a new value of Id to a graph data. More... | |
Private Attributes | |
| GraphDataManager * | m_dataManager |
| Used to load and save GraphData information from a DataSource. More... | |
| int | m_graphDataCounter |
| Graph data identifier counter. More... | |
| std::map< int, GraphData * > | m_graphDataMap |
| This map represents all data loaded in cache. More... | |
| GraphMetadata * | m_metadata |
| Graph metadata information. More... | |
| AbstractCachePolicy * | m_policy |
| Cache policy to control the cache in memory. More... | |
Class used to manager the graph data elements. This class uses a cache policy to control the elements in memory. If a element was requested and not found in cache, the GraphDataManager is used to loaded a new GraphData.
Definition at line 60 of file GraphCache.h.
| te::graph::GraphCache::GraphCache | ( | AbstractCachePolicy * | cp, |
| GraphDataManager * | dm | ||
| ) |
Default constructor.
| cp | Implementation of a cache policy |
| dm | Data manager pointer |
Definition at line 41 of file GraphCache.cpp.
References te::graph::GraphDataManager::getLoaderStrategy(), te::graph::AbstractGraphLoaderStrategy::getMetadata(), m_dataManager, m_graphDataCounter, m_metadata, m_policy, te::graph::AbstractCachePolicyFactory::make(), and TE_DEFAULT_CACHE_POLICY_TYPE.
| te::graph::GraphCache::~GraphCache | ( | ) |
Default destructor.
Definition at line 53 of file GraphCache.cpp.
References clearCache(), and m_policy.
| te::graph::GraphData * te::graph::GraphCache::checkCacheByEdgeId | ( | int | id | ) |
This functions check in cache if the edge element with a given id was alredy in memory.
| id | The edge Id |
Definition at line 270 of file GraphCache.cpp.
References te::graph::AbstractCachePolicy::accessed(), d, te::graph::GraphData::getEdgeMap(), te::graph::GraphData::getId(), m_graphDataMap, and m_policy.
Referenced by getGraphDataByEdgeId(), te::graph::SequenceLoaderStrategy::loadDataByEdgeId(), and te::graph::BoxLoaderStrategy::loadDataByEdgeId().
| te::graph::GraphData * te::graph::GraphCache::checkCacheByVertexId | ( | int | id | ) |
This functions check in cache if the vertex element with a given id was alredy in memory.
| id | The vertex Id |
Definition at line 246 of file GraphCache.cpp.
References te::graph::AbstractCachePolicy::accessed(), d, te::graph::GraphData::getId(), te::graph::GraphData::getVertexMap(), m_graphDataMap, and m_policy.
Referenced by te::graph::DirectedGraph::add(), te::graph::UndirectedGraph::add(), te::graph::BidirectionalGraph::add(), getGraphDataByVertexId(), te::graph::SequenceLoaderStrategy::loadDataByVertexId(), and te::graph::BoxLoaderStrategy::loadDataByVertexId().
| void te::graph::GraphCache::clearCache | ( | ) |
Used to remove from memory all elements loaded.
Definition at line 222 of file GraphCache.cpp.
References d, te::common::FreeContents(), te::graph::GraphData::isDirty(), m_dataManager, m_graphDataMap, and te::graph::GraphDataManager::saveGraphData().
Referenced by te::graph::Graph::flush(), and ~GraphCache().
| te::graph::GraphData * te::graph::GraphCache::createGraphData | ( | ) |
Creates a new graph data structure.
Definition at line 183 of file GraphCache.cpp.
References te::graph::AbstractCachePolicy::added(), d, getGraphDataId(), te::graph::GraphData::getId(), m_graphDataMap, te::graph::GraphMetadata::m_maxVecCacheSize, m_metadata, and m_policy.
Referenced by getGraphData().
| te::graph::GraphData * te::graph::GraphCache::getGraphData | ( | ) |
Get a graph data.
Definition at line 124 of file GraphCache.cpp.
References createGraphData(), d, te::graph::GraphData::getEdgeMap(), te::graph::GraphData::getId(), te::graph::GraphData::getVertexMap(), m_graphDataMap, te::graph::GraphMetadata::m_maxCacheSize, te::graph::GraphMetadata::m_maxVecCacheSize, m_metadata, m_policy, removeGraphData(), saveGraphData(), te::graph::AbstractCachePolicy::toRemove(), and te::graph::AbstractCachePolicy::update().
Referenced by te::graph::Graph::add().
| te::graph::GraphData * te::graph::GraphCache::getGraphDataByEdgeId | ( | int | id | ) |
Get a graph data from vector using a edge id information. if not found a new graph data has to be loaded using AbstractDataManager.
| id | The edge identifier of the desired element. |
Definition at line 92 of file GraphCache.cpp.
References te::graph::AbstractCachePolicy::accessed(), checkCacheByEdgeId(), d, te::graph::GraphData::getEdgeMap(), te::graph::GraphData::getId(), te::graph::GraphDataManager::loadGraphDataByEdgeId(), m_dataManager, m_graphDataMap, and m_policy.
Referenced by te::graph::Graph::getEdge(), and te::graph::Graph::removeEdge().
| te::graph::GraphData * te::graph::GraphCache::getGraphDataByVertexId | ( | int | id | ) |
Get a graph data from vector using a vertex id information. if not found a new graph data has to be loaded using AbstractDataManager.
| id | The vertex identifier of the desired element. |
Definition at line 60 of file GraphCache.cpp.
References te::graph::AbstractCachePolicy::accessed(), checkCacheByVertexId(), d, te::graph::GraphData::getId(), te::graph::GraphData::getVertexMap(), te::graph::GraphDataManager::loadGraphDataByVertexId(), m_dataManager, m_graphDataMap, and m_policy.
Referenced by te::graph::Graph::getVertex(), and te::graph::Graph::removeVertex().
|
protected |
Protected function used to define a new value of Id to a graph data.
Definition at line 294 of file GraphCache.cpp.
References m_graphDataCounter.
Referenced by createGraphData().
| void te::graph::GraphCache::removeGraphData | ( | int | idx | ) |
Used to remove a graph data from cache.
| idx | The graph data identifier |
Definition at line 199 of file GraphCache.cpp.
References m_graphDataMap.
Referenced by getGraphData().
| void te::graph::GraphCache::saveGraphData | ( | GraphData * | data | ) |
Save the graph data structure inside a data source.
| data | The graph data to be saved |
Definition at line 214 of file GraphCache.cpp.
References m_dataManager, and te::graph::GraphDataManager::saveGraphData().
Referenced by getGraphData().
|
private |
Used to load and save GraphData information from a DataSource.
Definition at line 181 of file GraphCache.h.
Referenced by clearCache(), getGraphDataByEdgeId(), getGraphDataByVertexId(), GraphCache(), and saveGraphData().
|
private |
Graph data identifier counter.
Definition at line 185 of file GraphCache.h.
Referenced by getGraphDataId(), and GraphCache().
This map represents all data loaded in cache.
Definition at line 177 of file GraphCache.h.
Referenced by checkCacheByEdgeId(), checkCacheByVertexId(), clearCache(), createGraphData(), getGraphData(), getGraphDataByEdgeId(), getGraphDataByVertexId(), and removeGraphData().
|
private |
Graph metadata information.
Definition at line 183 of file GraphCache.h.
Referenced by createGraphData(), getGraphData(), and GraphCache().
|
private |
Cache policy to control the cache in memory.
Definition at line 179 of file GraphCache.h.
Referenced by checkCacheByEdgeId(), checkCacheByVertexId(), createGraphData(), getGraphData(), getGraphDataByEdgeId(), getGraphDataByVertexId(), GraphCache(), and ~GraphCache().