AbstractIterator.h
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.h
22 
23  \brief This class defines a commun interface to represents a graph
24  iterator class. The main diferency to anothers iterators is
25  the possibility to iterate over the edges or vertexs from a
26  graph.
27 */
28 
29 #ifndef __TERRALIB_GRAPH_INTERNAL_ABSTRACTITERATOR_H
30 #define __TERRALIB_GRAPH_INTERNAL_ABSTRACTITERATOR_H
31 
32 // Terralib Includes
33 #include "../../dataaccess/dataset/DataSet.h"
34 #include "../core/AbstractGraph.h"
35 #include "../Config.h"
36 
37 
38 // STL Includes
39 #include <memory>
40 #include <vector>
41 
42 namespace te
43 {
44  namespace graph
45  {
46  //forward declarations
47  class Edge;
48  class Vertex;
49 
50  /*!
51  \class AbstractIterator
52 
53  \brief This class defines a commun interface to represents a graph
54  iterator class. The main diferency to anothers iterators is
55  the possibility to iterate over the edges or vertexs from a
56  graph.
57 
58  \sa
59  */
60 
62  {
63  public:
64 
65  /*! \brief Default constructor. */
67 
68  /*! \brief Virtual destructor. */
69  virtual ~AbstractIterator();
70 
71 
72  /** @name Vertex Iterator Methods
73  * Method used to access vertex elements from a graph.
74  */
75  //@{
76 
77  /*!
78  \brief It returns a pointer to the first vertex element of a graph
79 
80  \return A valid vertex point if the element was found and a null pointer in other case.
81  */
82  virtual te::graph::Vertex* getFirstVertex() = 0;
83 
84  /*!
85  \brief It returns a pointer to the next vertex element of a graph
86 
87  \return A valid vertex point if the element was found and a null pointer in other case.
88  */
89  virtual te::graph::Vertex* getNextVertex();
90 
91  /*!
92  \brief It returns a pointer to the previous vertex element of a graph
93 
94  \return A valid vertex point if the element was found and a null pointer in other case.
95  */
96  virtual te::graph::Vertex* getPreviousVertex();
97 
98  /*!
99  \brief Used to check the iterator position
100 
101  \return True if the iterator is at after the end and false in other case
102  */
103  virtual bool isVertexIteratorAfterEnd();
104 
105  /*!
106  \brief It returns the number of elements of this iterator
107 
108  \return Size t value.
109  */
110  virtual size_t getVertexInteratorCount();
111 
112  /*!
113  \brief Used to set that the isolated vertex must be listed
114 
115  \param flag Flag used to set.
116  */
117  void listIsolatedVertex(bool flag);
118 
119  //@}
120 
121  /** @name Vertex Iterator Methods
122  * Method used to access vertex elements from a graph.
123  */
124  //@{
125 
126  /*!
127  \brief It returns a pointer to the first edge element of a graph
128 
129  \return A valid edge point if the element was found and a null pointer in other case.
130  */
131  virtual te::graph::Edge* getFirstEdge() = 0;
132 
133  /*!
134  \brief It returns a pointer to the next edge element of a graph
135 
136  \return A valid edge point if the element was found and a null pointer in other case.
137  */
138  virtual te::graph::Edge* getNextEdge();
139 
140  /*!
141  \brief It returns a pointer to the previous edge element of a graph
142 
143  \return A valid edge point if the element was found and a null pointer in other case.
144  */
145  virtual te::graph::Edge* getPreviousEdge();
146 
147  /*!
148  \brief Used to check the iterator position
149 
150  \return True if the iterator is at after the end and false in other case
151  */
152  virtual bool isEdgeIteratorAfterEnd();
153 
154  /*!
155  \brief It returns the number of elements of this iterator
156 
157  \return Size t value.
158  */
159  virtual size_t getEdgeInteratorCount();
160 
161  //@}
162 
163  protected:
164 
165  te::graph::AbstractGraph* m_graph; //!< Pointer to a abstract graph used to access the elements
166 
167  std::auto_ptr<te::da::DataSet> m_vertexQuery; //!< Attribute used to keep the vertex iterator
168  std::auto_ptr<te::da::DataSet> m_edgeQuery; //!< Attribute used to keep the edge iterator
169 
170  bool m_listIsolatedVertex; //!< Flag used to indicated that the isolated vertex will be listed
171  };
172 
173  } // end namespace graph
174 } // end namespace te
175 
176 #endif // __TERRALIB_GRAPH_INTERNAL_ABSTRACTITERATOR_H
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178
std::auto_ptr< te::da::DataSet > m_edgeQuery
Attribute used to keep the edge iterator.
te::graph::AbstractGraph * m_graph
Pointer to a abstract graph used to access the elements.
bool m_listIsolatedVertex
Flag used to indicated that the isolated vertex will be listed.
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
Definition: Vertex.h:68
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
Definition: Edge.h:58
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:55
URI C++ Library.
This class defines a commun interface to represents a graph iterator class. The main diferency to ano...
std::auto_ptr< te::da::DataSet > m_vertexQuery
Attribute used to keep the vertex iterator.