All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MemoryIterator.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file AbstractIterator.cpp
22 
23  \brief
24 */
25 
26 // Terralib Includes
27 #include "../../common/Translator.h"
28 #include "../../common/StringUtils.h"
29 #include "../core/AbstractGraph.h"
30 #include "../core/GraphData.h"
31 #include "../graphs/Graph.h"
32 #include "../Config.h"
33 #include "../Exception.h"
34 #include "../Globals.h"
35 #include "MemoryIterator.h"
36 
38  te::graph::AbstractIterator(g)
39 {
40  te::graph::Graph* graph = dynamic_cast<te::graph::Graph*>(g);
41 
42  if(g)
43  {
45  m_edgeMap = graph->m_graphData->getEdgeMap();
46 
47  m_vertexMapIt = m_vertexMap.begin();
48  m_edgeMapIt = m_edgeMap.begin();
49  }
50 }
51 
53 {
54 }
55 
57 {
58  m_vertexMapIt = m_vertexMap.begin();
59 
60  return m_vertexMapIt->second;
61 }
62 
64 {
65  ++m_vertexMapIt;
66 
67  if(m_vertexMapIt != m_vertexMap.end())
68  return m_vertexMapIt->second;
69 
70  return 0;
71 }
72 
74 {
75  --m_vertexMapIt;
76 
77  return m_vertexMapIt->second;
78 }
79 
81 {
82  return m_vertexMapIt == m_vertexMap.end();
83 }
84 
86 {
87  return m_vertexMap.size();
88 }
89 
91 {
92  m_edgeMapIt = m_edgeMap.begin();
93 
94  return m_edgeMapIt->second;
95 }
96 
98 {
99  ++m_edgeMapIt;
100 
101  if(m_edgeMapIt != m_edgeMap.end())
102  return m_edgeMapIt->second;
103 
104  return 0;
105 }
106 
108 {
109  --m_edgeMapIt;
110 
111  return m_edgeMapIt->second;
112 }
113 
115 {
116  return m_edgeMapIt == m_edgeMap.end();
117 }
118 
120 {
121  return m_edgeMap.size();
122 }
virtual te::graph::Edge * getNextEdge()
It returns a pointer to the next edge element of a graph.
virtual te::graph::Vertex * getFirstVertex()
It returns a pointer to the first vertex element of a graph.
virtual te::graph::Vertex * getNextVertex()
It returns a pointer to the next vertex element of a graph.
VertexMap & getVertexMap()
It returns the the vertex map.
Definition: GraphData.cpp:89
virtual ~MemoryIterator()
Virtual destructor.
std::map< int, Edge * >::iterator m_edgeMapIt
Iterator for all edges from this graph.
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
Definition: Vertex.h:68
MemoryIterator(te::graph::AbstractGraph *g)
Default constructor.
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
Definition: Edge.h:58
virtual te::graph::Edge * getPreviousEdge()
It returns a pointer to the previous edge element of a graph.
std::map< int, Vertex * > m_vertexMap
This map contains all vertexs from this graph.
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:55
virtual bool isEdgeIteratorAfterEnd()
Used to check the iterator position.
EdgeMap & getEdgeMap()
It returns the the edge map.
Definition: GraphData.cpp:133
virtual bool isVertexIteratorAfterEnd()
Used to check the iterator position.
virtual te::graph::Edge * getFirstEdge()
It returns a pointer to the first edge element of a graph.
std::map< int, Edge * > m_edgeMap
This map contains all edges from this graph.
GraphData * m_graphData
This class has the graph data and properties.
Definition: Graph.h:298
virtual size_t getEdgeInteratorCount()
It returns the number of elements of this iterator.
This class defines a commun interface to represents a graph iterator class. The main diferency to ano...
virtual size_t getVertexInteratorCount()
It returns the number of elements of this iterator.
This is the main graph implementation, that uses a cache policy anda graph loader to get all elements...
Definition: Graph.h:72
virtual te::graph::Vertex * getPreviousVertex()
It returns a pointer to the previous vertex element of a graph.
std::map< int, Vertex * >::iterator m_vertexMapIt
Iterator for all vertexs from this graph.