AbstractGraph.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 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 GraphMetadata;
44  class Edge;
45  class Vertex;
46 
47  /*!
48  \class AbstractGraph
49 
50  \brief Abstract class used to define the main functions of graph struct. All
51  graph implementations must used this class.
52 
53  */
54 
56  {
57  public:
58 
59  /*! \brief Default constructor. */
60  AbstractGraph();
61 
62  /*! \brief Virtual destructor. */
63  virtual ~AbstractGraph();
64 
65 
66  /** @name Vertex Access Methods
67  * Method used to access vertex elements from a graph.
68  */
69  //@{
70 
71  /*!
72  \brief Add a new vertex element to a graph
73 
74  \param v Vertex element
75 
76  \note This function turns the dirty flag of current GraphData to true, the
77  new flag of the vertex turns to true.
78 
79  */
80  virtual void add(Vertex* v) = 0;
81 
82  /*!
83  \brief Update the vertex element
84 
85  \param v Vertex element
86 
87  \note This function turns the dirty flag of current GraphData to true and
88  also the dirty flag of the vertex.
89 
90  */
91  virtual void update(Vertex* v) = 0;
92 
93  /*!
94  \brief This function removes the vertex element from graph, also was removed
95  in data source.
96 
97  \param id Vertex identification
98 
99  */
100  virtual void removeVertex(int id) = 0;
101 
102  /*!
103  \brief It returns the vertex element if it's exist.
104 
105  \param id Vertex identification
106 
107  \return A valid vertex point if the element was found and a null pointer in other case.
108  */
109  virtual te::graph::Vertex* getVertex(int id) = 0;
110 
111  /*!
112  \brief Add a new property associated to the vertex element
113 
114  param p New property to be associated with vertex elements.
115 
116  \note It's important before using this function call the flush() function, its necessary
117  to force the memory clear and the elements will be loaded with the right size of
118  properties.
119  */
120  virtual void addVertexProperty(te::dt::Property* p) = 0;
121 
122  /*!
123  \brief Remove a property associated to the vertex element
124 
125  \param idx Index of the property
126  */
127  virtual void removeVertexProperty(int idx) = 0;
128 
129  /*!
130  \brief Get a vertex property given a index
131 
132  \param idx Index of the property
133 
134  \return A property associated to the vertex element if the index is right and a null pointer in other case.
135 
136  */
137  virtual te::dt::Property* getVertexProperty(int idx) = 0;
138 
139  /*!
140  \brief Used to verify the number of properties associated to vertex elements
141 
142  \return Integer value with the number of properties.
143 
144  */
145  virtual int getVertexPropertySize() = 0;
146 
147  //@}
148 
149  /** @name Edge Access Methods
150  * Method used to access edge elements from a graph.
151  */
152  //@{
153 
154  /*!
155  \brief Add a new edge element to a graph
156 
157  \param e Edge element
158 
159  \note This function turns the dirty flag of current GraphData to true, the
160  new flag of the edge turns to true.
161 
162  */
163  virtual void add(Edge* e) = 0;
164 
165  /*!
166  \brief Update the edge element
167 
168  \param e Edge element
169 
170  \note This function turns the dirty flag of current GraphData to true and
171  also the dirty flag of the edge.
172 
173  */
174  virtual void update(Edge* e) = 0;
175 
176  /*!
177  \brief This function removes the edge element from graph, also was removed
178  in data source.
179 
180  \param id Edge identification
181 
182  */
183  virtual void removeEdge(int id) = 0;
184 
185  /*!
186  \brief It returns the edge element if it's exist.
187 
188  \param id Vertex identification
189 
190  \return A valid vertex point if the element was found and a null pointer in other case.
191  */
192  virtual te::graph::Edge* getEdge(int id) = 0;
193 
194  /*!
195  \brief Add a new property associated to the edge element
196 
197  param p New property to be associated with edge elements.
198 
199  \note It's important before using this function call the flush() function, its necessary
200  to force the memory clear and the elements will be loaded with the right size of
201  properties.
202  */
203  virtual void addEdgeProperty(te::dt::Property* p) = 0;
204 
205  /*!
206  \brief Remove a property associated to the edge element
207 
208  \param idx Index of the property
209  */
210  virtual void removeEdgeProperty(int idx) = 0;
211 
212  /*!
213  \brief Get a edge property given a index
214 
215  \param idx Index of the property
216 
217  \return A property associated to the edge element if the index is right and a null pointer in other case.
218 
219  */
220  virtual te::dt::Property* getEdgeProperty(int idx) = 0;
221 
222  /*!
223  \brief Used to verify the number of properties associated to edge elements
224 
225  \return Integer value with the number of properties.
226 
227  */
228  virtual int getEdgePropertySize() = 0;
229 
230  //@}
231 
232  /*!
233  \brief Function used to access the graph metadata
234 
235  \return A pointer to a class that defines the graph metadata
236 
237  */
238  virtual te::graph::GraphMetadata* getMetadata() = 0;
239 
240  /*!
241  \brief Function used to clear the memory cache, all elements was released from
242  memory, if any element was changes it will be saved.
243 
244  \return
245 
246  */
247  virtual void flush() = 0;
248  };
249 
250  } // end namespace graph
251 } // end namespace te
252 
253 #endif // __TERRALIB_GRAPH_INTERNAL_ABSTRACTGRAPH_H
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178
It models a property definition.
Definition: Property.h:59
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.
Class used to define the graph metadata informations.
Definition: GraphMetadata.h:56