All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::graph::GraphCache Class Reference

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

GraphDatagetGraphDataByVertexId (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...
 
GraphDatagetGraphDataByEdgeId (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...
 
GraphDatagetGraphData ()
 Get a graph data. More...
 
GraphDatacreateGraphData ()
 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...
 
GraphDatacheckCacheByVertexId (int id)
 This functions check in cache if the vertex element with a given id was alredy in memory. More...
 
GraphDatacheckCacheByEdgeId (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

GraphDataManagerm_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...
 
GraphMetadatam_metadata
 Graph metadata information. More...
 
AbstractCachePolicym_policy
 Cache policy to control the cache in memory. More...
 

Detailed Description

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.

See also
GraphDataManager, GraphData

Definition at line 60 of file GraphCache.h.

Constructor & Destructor Documentation

te::graph::GraphCache::GraphCache ( AbstractCachePolicy cp,
GraphDataManager dm 
)
te::graph::GraphCache::~GraphCache ( )

Default destructor.

Definition at line 53 of file GraphCache.cpp.

Member Function Documentation

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.

Parameters
idThe edge Id
Returns
If the element was found its returns a pointer to a graph data that contains this element

Definition at line 270 of file GraphCache.cpp.

References te::graph::GraphData::getEdgeMap(), and te::graph::GraphData::getId().

Referenced by 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.

Parameters
idThe vertex Id
Returns
If the element was found its returns a pointer to a graph data that contains this element

Definition at line 246 of file GraphCache.cpp.

References te::graph::GraphData::getId(), and te::graph::GraphData::getVertexMap().

Referenced by te::graph::SequenceLoaderStrategy::loadDataByVertexId(), and te::graph::BoxLoaderStrategy::loadDataByVertexId().

void te::graph::GraphCache::clearCache ( )

Used to remove from memory all elements loaded.

Note
The function Flush from AbstractGraph calls this function.

Definition at line 222 of file GraphCache.cpp.

References te::common::FreeContents(), and te::graph::GraphData::isDirty().

te::graph::GraphData * te::graph::GraphCache::createGraphData ( )

Creates a new graph data structure.

Returns
A pointer to a new graph data

Definition at line 183 of file GraphCache.cpp.

References te::graph::GraphData::getId().

te::graph::GraphData * te::graph::GraphCache::getGraphData ( )

Get a graph data.

Note
It's always try to return the graph data with the max number of elements that is not already full. If its not possible a new graph data will be created.
Returns
A pointer to a graph data.

Definition at line 124 of file GraphCache.cpp.

References te::graph::GraphData::getEdgeMap(), te::graph::GraphData::getId(), and te::graph::GraphData::getVertexMap().

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.

Parameters
idThe edge identifier of the desired element.
Returns
A Graph Data that contains the request element.

Definition at line 92 of file GraphCache.cpp.

References te::graph::GraphData::getEdgeMap(), and te::graph::GraphData::getId().

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.

Parameters
idThe vertex identifier of the desired element.
Returns
A Graph Data that contains the request element.

Definition at line 60 of file GraphCache.cpp.

References te::graph::GraphData::getId(), and te::graph::GraphData::getVertexMap().

int te::graph::GraphCache::getGraphDataId ( )
protected

Protected function used to define a new value of Id to a graph data.

Returns
Integer value with the id information

Definition at line 294 of file GraphCache.cpp.

void te::graph::GraphCache::removeGraphData ( int  idx)

Used to remove a graph data from cache.

Parameters
idxThe graph data identifier

Definition at line 199 of file GraphCache.cpp.

void te::graph::GraphCache::saveGraphData ( GraphData data)

Save the graph data structure inside a data source.

Parameters
dataThe graph data to be saved

Definition at line 214 of file GraphCache.cpp.

Member Data Documentation

GraphDataManager* te::graph::GraphCache::m_dataManager
private

Used to load and save GraphData information from a DataSource.

Definition at line 181 of file GraphCache.h.

Referenced by GraphCache().

int te::graph::GraphCache::m_graphDataCounter
private

Graph data identifier counter.

Definition at line 185 of file GraphCache.h.

Referenced by GraphCache().

std::map<int, GraphData*> te::graph::GraphCache::m_graphDataMap
private

This map represents all data loaded in cache.

Definition at line 177 of file GraphCache.h.

GraphMetadata* te::graph::GraphCache::m_metadata
private

Graph metadata information.

Definition at line 183 of file GraphCache.h.

Referenced by GraphCache().

AbstractCachePolicy* te::graph::GraphCache::m_policy
private

Cache policy to control the cache in memory.

Definition at line 179 of file GraphCache.h.

Referenced by GraphCache().


The documentation for this class was generated from the following files: