Loading...
Searching...
No Matches
Graph.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 Graph.h
22
23 \brief This is the main graph implementation, that uses a
24 cache policy anda graph loader to get all elements
25 inside a data source.
26
27 All methods to access a graph element (vertex or edge)
28 will use the GraphData instance, if not found the element,
29 the class GraphCache will be consulted.
30*/
31
32#ifndef __TERRALIB_GRAPH_INTERNAL_GRAPH_H
33#define __TERRALIB_GRAPH_INTERNAL_GRAPH_H
34
35// Terralib Includes
36#include "../core/AbstractGraph.h"
37#include "../Config.h"
38
39
40// STL Includes
41#include <vector>
42
43namespace te
44{
45 namespace dt { class Property; }
46
47 namespace graph
48 {
49 //forward declarations
50 class AbstractCachePolicy;
51 class AbstractGraphLoaderStrategy;
52 class GraphData;
53 class GraphDataManager;
54 class GraphCache;
55 class GraphMetadata;
56
57
58 /*!
59 \class Graph
60
61 \brief This is the main graph implementation, that uses a
62 cache policy anda graph loader to get all elements
63 inside a data source.
64
65 All methods to access a graph element (vertex or edge)
66 will use the GraphData instance, if not found the element,
67 the class GraphCache will be consulted.
68
69 \sa AbstractGraph, GraphData, GraphCache
70 */
71
73 {
74 public:
75
76 /*! \brief constructor. */
78
79 /*!
80 \brief Constructor
81
82 \param metadata A pointer to a graph metadata implementation
83
84 */
85 Graph(GraphMetadata* metadata);
86
87 /*!
88 \brief Constructor
89
90 \param cp A pointer to a cache policy implementation
91
92 \param ls A pointer to a loader strategy implementation
93
94 */
96
97 /*! \brief Virtual destructor. */
99
100
101 /** @name Vertex Access Methods
102 * Method used to access vertex elements from a graph.
103 */
104 //@{
105
106 /*!
107 \brief Add a new vertex element to a graph
108
109 \param v Vertex element
110
111 \note This function turns the dirty flag of current GraphData to true, the
112 new flag of the vertex turns to true.
113
114 */
115 virtual void add(Vertex* v);
116
117 /*!
118 \brief Update the vertex element
119
120 \param v Vertex element
121
122 \note This function turns the dirty flag of current GraphData to true and
123 also the dirty flag of the vertex.
124
125 */
126 virtual void update(Vertex* v);
127
128 /*!
129 \brief This function removes the vertex element from graph, also was removed
130 in data source.
131
132 \param id Vertex identification
133
134 */
135 virtual void removeVertex(int id);
136
137 /*!
138 \brief It returns the vertex element if it's exist.
139
140 \param id Vertex identification
141
142 \return A valid vertex point if the element was found and a null pointer in other case.
143 */
144 virtual te::graph::Vertex* getVertex(int id);
145
146
147 /*!
148 \brief Add a new property associated to the vertex element
149
150 param p New property to be associated with vertex elements.
151
152 \note It's important before using this function call the flush() function, its necessary
153 to force the memory clear and the elements will be loaded with the right size of
154 properties.
155 */
157
158
159 /*!
160 \brief Remove a property associated to the vertex element
161
162 \param idx Index of the property
163 */
164 virtual void removeVertexProperty(int idx);
165
166 /*!
167 \brief Get a vertex property given a index
168
169 \param idx Index of the property
170
171 \return A property associated to the vertex element if the index is right and a null pointer in other case.
172
173 */
175
176 /*!
177 \brief Used to verify the number of properties associated to vertex elements
178
179 \return Integer value with the number of properties.
180
181 */
183
184
185 //@}
186
187 /** @name Edge Access Methods
188 * Method used to access edge elements from a graph.
189 */
190 //@{
191
192 /*!
193 \brief Add a new edge element to a graph
194
195 \param e Edge element
196
197 \note This function turns the dirty flag of current GraphData to true, the
198 new flag of the edge turns to true.
199
200 */
201 virtual void add(Edge* e);
202
203 /*!
204 \brief Update the edge element
205
206 \param e Edge element
207
208 \note This function turns the dirty flag of current GraphData to true and
209 also the dirty flag of the edge.
210
211 */
212 virtual void update(Edge* e);
213
214 /*!
215 \brief This function removes the edge element from graph, also was removed
216 in data source.
217
218 \param id Edge identification
219
220 */
221 virtual void removeEdge(int id);
222
223 /*!
224 \brief It returns the edge element if it's exist.
225
226 \param id Vertex identification
227
228 \return A valid vertex point if the element was found and a null pointer in other case.
229 */
230 virtual te::graph::Edge* getEdge(int id);
231
232 /*!
233 \brief Add a new property associated to the edge element
234
235 param p New property to be associated with edge elements.
236
237 \note It's important before using this function call the flush() function, its necessary
238 to force the memory clear and the elements will be loaded with the right size of
239 properties.
240 */
242
243 /*!
244 \brief Remove a property associated to the edge element
245
246 \param idx Index of the property
247 */
248 virtual void removeEdgeProperty(int idx);
249
250 /*!
251 \brief Get a edge property given a index
252
253 \param idx Index of the property
254
255 \return A property associated to the edge element if the index is right and a null pointer in other case.
256
257 */
259
260 /*!
261 \brief Used to verify the number of properties associated to edge elements
262
263 \return Integer value with the number of properties.
264
265 */
266 virtual int getEdgePropertySize();
267
268 //@}
269
270 /*!
271 \brief Function used to access the graph metadata
272
273 \return A pointer to a class that defines the graph metadata
274
275 */
277
278
279 /*!
280 \brief Function used to clear the memory cache, all elements was released from
281 memory, if any element was changes it will be saved.
282
283 \return
284
285 */
286 virtual void flush();
287
288 protected:
289
290 GraphDataManager* m_dataManager; //!< Used to load and save GraphData information from a DataSource
291
292 GraphCache* m_graphCache; //!< Class used to keep all graph data loaded
293
294 GraphMetadata* m_metadata; //!< Graph Data loader strategy
295
296 public:
297
298 GraphData* m_graphData; //!< This class has the graph data and properties
299 };
300
301 } // end namespace graph
302} // end namespace te
303
304#endif // __TERRALIB_GRAPH_INTERNAL_ABSTRACTGRAPH_H
It models a property definition.
Definition: Property.h:60
This class is used to set the main functions of a cache policy.
This class define the main functions necessary to save and load the graph data and metadata informati...
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:59
Class used to manager the graph data elements. This class uses a cache policy to control the elements...
Definition: GraphCache.h:61
This class define a important struct used to group a map of vertex and edges. A flag is used to indic...
Definition: GraphData.h:56
Class used to define the graph metadata informations.
Definition: GraphMetadata.h:57
This is the main graph implementation, that uses a cache policy anda graph loader to get all elements...
Definition: Graph.h:73
virtual int getVertexPropertySize()
Used to verify the number of properties associated to vertex elements.
virtual void flush()
Function used to clear the memory cache, all elements was released from memory, if any element was ch...
GraphMetadata * m_metadata
Graph Data loader strategy.
Definition: Graph.h:294
virtual void addVertexProperty(te::dt::Property *p)
Add a new property associated to the vertex element.
virtual int getEdgePropertySize()
Used to verify the number of properties associated to edge elements.
virtual void update(Edge *e)
Update the edge element.
virtual void removeVertex(int id)
This function removes the vertex element from graph, also was removed in data source.
virtual void removeEdgeProperty(int idx)
Remove a property associated to the edge element.
virtual te::graph::GraphMetadata * getMetadata()
Function used to access the graph metadata.
virtual void addEdgeProperty(te::dt::Property *p)
Add a new property associated to the edge element.
virtual void removeEdge(int id)
This function removes the edge element from graph, also was removed in data source.
Graph(AbstractCachePolicy *cp, AbstractGraphLoaderStrategy *ls)
Constructor.
~Graph()
Virtual destructor.
Graph()
constructor.
virtual te::dt::Property * getVertexProperty(int idx)
Get a vertex property given a index.
GraphDataManager * m_dataManager
Used to load and save GraphData information from a DataSource.
Definition: Graph.h:290
virtual void add(Edge *e)
Add a new edge element to a graph.
Graph(GraphMetadata *metadata)
Constructor.
virtual void update(Vertex *v)
Update the vertex element.
virtual te::dt::Property * getEdgeProperty(int idx)
Get a edge property given a index.
GraphData * m_graphData
This class has the graph data and properties.
Definition: Graph.h:298
virtual te::graph::Edge * getEdge(int id)
It returns the edge element if it's exist.
GraphCache * m_graphCache
Class used to keep all graph data loaded.
Definition: Graph.h:292
virtual te::graph::Vertex * getVertex(int id)
It returns the vertex element if it's exist.
virtual void add(Vertex *v)
Add a new vertex element to a graph.
virtual void removeVertexProperty(int idx)
Remove a property associated to the vertex element.
From the point of view of graph theory, vertices are treated as featureless and indivisible objects,...
Definition: Vertex.h:69
TerraLib.
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178