All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractGraph.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 AbstractGraph.h
22 
23  \brief Abstract class used to define the main functions of graph struct. All
24  graph implementations must used this class.
25 */
26 
27 #ifndef __TERRALIB_GRAPH_INTERNAL_ABSTRACTGRAPH_H
28 #define __TERRALIB_GRAPH_INTERNAL_ABSTRACTGRAPH_H
29 
30 // Terralib Includes
31 #include "../Config.h"
32 
33 // STL Includes
34 #include <vector>
35 
36 namespace te
37 {
38  namespace dt { class Property; }
39 
40  namespace graph
41  {
42  //forward declarations
43  class AbstractIterator;
44  class GraphMetadata;
45  class Edge;
46  class Vertex;
47 
48  /*!
49  \class AbstractGraph
50 
51  \brief Abstract class used to define the main functions of graph struct. All
52  graph implementations must used this class.
53 
54  */
55 
57  {
58  public:
59 
60  /*! \brief Default constructor. */
61  AbstractGraph();
62 
63  /*! \brief Virtual destructor. */
64  virtual ~AbstractGraph();
65 
66 
67  /** @name Vertex Access Methods
68  * Method used to access vertex elements from a graph.
69  */
70  //@{
71 
72  /*!
73  \brief Add a new vertex element to a graph
74 
75  \param v Vertex element
76 
77  \note This function turns the dirty flag of current GraphData to true, the
78  new flag of the vertex turns to true.
79 
80  */
81  virtual void add(Vertex* v) = 0;
82 
83  /*!
84  \brief Update the vertex element
85 
86  \param v Vertex element
87 
88  \note This function turns the dirty flag of current GraphData to true and
89  also the dirty flag of the vertex.
90 
91  */
92  virtual void update(Vertex* v) = 0;
93 
94  /*!
95  \brief This function removes the vertex element from graph, also was removed
96  in data source.
97 
98  \param id Vertex identification
99 
100  */
101  virtual void removeVertex(int id) = 0;
102 
103  /*!
104  \brief It returns the vertex element if it's exist.
105 
106  \param id Vertex identification
107 
108  \return A valid vertex point if the element was found and a null pointer in other case.
109  */
110  virtual te::graph::Vertex* getVertex(int id) = 0;
111 
112  /*!
113  \brief It returns a pointer to the first vertex element of a graph
114 
115  \note This function is not implemented here, it's just a call to a iterator function.
116 
117  \return A valid vertex point if the element was found and a null pointer in other case.
118  */
119  virtual te::graph::Vertex* getFirstVertex();
120 
121  /*!
122  \brief It returns a pointer to the next vertex element of a graph
123 
124  \note This function is not implemented here, it's just a call to a iterator function.
125 
126  \return A valid vertex point if the element was found and a null pointer in other case.
127  */
128  virtual te::graph::Vertex* getNextVertex();
129 
130  /*!
131  \brief It returns a pointer to the previous vertex element of a graph
132 
133  \note This function is not implemented here, it's just a call to a iterator function.
134 
135  \return A valid vertex point if the element was found and a null pointer in other case.
136  */
137  virtual te::graph::Vertex* getPreviousVertex();
138 
139  /*!
140  \brief Add a new property associated to the vertex element
141 
142  param p New property to be associated with vertex elements.
143 
144  \note It's important before using this function call the flush() function, its necessary
145  to force the memory clear and the elements will be loaded with the right size of
146  properties.
147  */
148  virtual void addVertexProperty(te::dt::Property* p) = 0;
149 
150  /*!
151  \brief Remove a property associated to the vertex element
152 
153  \param idx Index of the property
154  */
155  virtual void removeVertexProperty(int idx) = 0;
156 
157  /*!
158  \brief Get a vertex property given a index
159 
160  \param idx Index of the property
161 
162  \return A property associated to the vertex element if the index is right and a null pointer in other case.
163 
164  */
165  virtual te::dt::Property* getVertexProperty(int idx) = 0;
166 
167  /*!
168  \brief Used to verify the number of properties associated to vertex elements
169 
170  \return Integer value with the number of properties.
171 
172  */
173  virtual int getVertexPropertySize() = 0;
174 
175  //@}
176 
177  /** @name Edge Access Methods
178  * Method used to access edge elements from a graph.
179  */
180  //@{
181 
182  /*!
183  \brief Add a new edge element to a graph
184 
185  \param e Edge element
186 
187  \note This function turns the dirty flag of current GraphData to true, the
188  new flag of the edge turns to true.
189 
190  */
191  virtual void add(Edge* e) = 0;
192 
193  /*!
194  \brief Update the edge element
195 
196  \param e Edge element
197 
198  \note This function turns the dirty flag of current GraphData to true and
199  also the dirty flag of the edge.
200 
201  */
202  virtual void update(Edge* e) = 0;
203 
204  /*!
205  \brief This function removes the edge element from graph, also was removed
206  in data source.
207 
208  \param id Edge identification
209 
210  */
211  virtual void removeEdge(int id) = 0;
212 
213  /*!
214  \brief It returns the edge element if it's exist.
215 
216  \param id Vertex identification
217 
218  \return A valid vertex point if the element was found and a null pointer in other case.
219  */
220  virtual te::graph::Edge* getEdge(int id) = 0;
221 
222  /*!
223  \brief It returns a pointer to the first edge element of a graph
224 
225  \note This function is not implemented here, it's just a call to a iterator function.
226 
227  \return A valid edge point if the element was found and a null pointer in other case.
228  */
229  te::graph::Edge* getFirstEdge();
230 
231  /*!
232  \brief It returns a pointer to the next edge element of a graph
233 
234  \note This function is not implemented here, it's just a call to a iterator function.
235 
236  \return A valid edge point if the element was found and a null pointer in other case.
237  */
238  te::graph::Edge* getNextEdge();
239 
240  /*!
241  \brief It returns a pointer to the previous edge element of a graph
242 
243  \note This function is not implemented here, it's just a call to a iterator function.
244 
245  \return A valid edge point if the element was found and a null pointer in other case.
246  */
247  te::graph::Edge* getPreviousEdge();
248 
249  /*!
250  \brief Add a new property associated to the edge element
251 
252  param p New property to be associated with edge elements.
253 
254  \note It's important before using this function call the flush() function, its necessary
255  to force the memory clear and the elements will be loaded with the right size of
256  properties.
257  */
258  virtual void addEdgeProperty(te::dt::Property* p) = 0;
259 
260  /*!
261  \brief Remove a property associated to the edge element
262 
263  \param idx Index of the property
264  */
265  virtual void removeEdgeProperty(int idx) = 0;
266 
267  /*!
268  \brief Get a edge property given a index
269 
270  \param idx Index of the property
271 
272  \return A property associated to the edge element if the index is right and a null pointer in other case.
273 
274  */
275  virtual te::dt::Property* getEdgeProperty(int idx) = 0;
276 
277  /*!
278  \brief Used to verify the number of properties associated to edge elements
279 
280  \return Integer value with the number of properties.
281 
282  */
283  virtual int getEdgePropertySize() = 0;
284 
285  //@}
286 
287  /*!
288  \brief Function used to access the graph metadata
289 
290  \return A pointer to a class that defines the graph metadata
291 
292  */
293  virtual te::graph::GraphMetadata* getMetadata() = 0;
294 
295  /*!
296  \brief Function used to clear the memory cache, all elements was released from
297  memory, if any element was changes it will be saved.
298 
299  \return
300 
301  */
302  virtual void flush() = 0;
303 
304  /*!
305  \brief Used to associate a iterator to graph
306 
307  \param i Valid pointer to a iterator
308 
309  */
310  void setIterator(te::graph::AbstractIterator* i);
311 
312  /*!
313  \brief Used to get a iterator associated to graph
314 
315  \return Valid pointer to a iterator if exist and null pointer in other case
316 
317  */
318  te::graph::AbstractIterator* getIterator();
319 
320  protected:
321 
322  te::graph::AbstractIterator* m_iterator; //!< Iterator attribute
323  };
324 
325  } // end namespace graph
326 } // end namespace te
327 
328 #endif // __TERRALIB_GRAPH_INTERNAL_ABSTRACTGRAPH_H
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:56
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
Definition: Edge.h:58
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:216
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
Definition: Vertex.h:68
te::graph::AbstractIterator * m_iterator
Iterator attribute.
This class defines a commun interface to represents a graph iterator class. The main diferency to ano...
It models a property definition.
Definition: Property.h:59
Class used to define the graph metadata informations.
Definition: GraphMetadata.h:56