GraphMetadata.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 GraphMetadata.h
22 
23  \brief Class used to define the graph metadata informations.
24 */
25 
26 #ifndef __TERRALIB_GRAPH_INTERNAL_GRAPHMETADATA_H
27 #define __TERRALIB_GRAPH_INTERNAL_GRAPHMETADATA_H
28 
29 // Terralib Includes
30 #include "../Config.h"
31 #include "../Enums.h"
32 
33 // STL Includes
34 #include <string>
35 
36 namespace te
37 {
38  // Forward declarations
39  namespace da { class DataSource; }
40  namespace dt { class Property; }
41  namespace gm { class Envelope; }
42 
43  namespace graph
44  {
45  class VertexProperty;
46  class EdgeProperty;
47 
48  /*!
49  \class GraphMetadata
50 
51  \brief Class used to define the graph metadata informations.
52 
53  \sa Enums, AbstractGraph
54  */
55 
57  {
58  public:
59 
60  /*! \brief Default constructor. */
62 
63  /*! \brief Default destructor. */
64  virtual ~GraphMetadata();
65 
66  /*!
67  \brief Function used to load the graph information given a graph id
68 
69  \param id The Graph identifier
70 
71  \exception Exception It throws an exception if graph id equal -1
72  */
73  virtual void load(int id) { };
74 
75  /*!
76  \brief Function used to save the graph information
77 
78  */
79  virtual void save() { };
80 
81  /*!
82  \brief Function used to update the graph information on a data source
83 
84  \exception Exception It throws an exception if graph id equal -1
85  */
86  virtual void update() { };
87 
88  /*!
89  \brief It returns the graph id
90 
91  \return Integer value with the graph id
92  */
93  int getId();
94 
95  /*!
96  \brief Set the graph name
97 
98  \param name String with the graph name
99 
100  */
101  void setName(std::string name);
102 
103  /*!
104  \brief It returns the graph name
105 
106  \return String with the graph name
107  */
108  std::string getName();
109 
110  /*!
111  \brief Set the graph description
112 
113  \param desc String with the graph description
114 
115  */
116  void setDescription(std::string desc);
117 
118  /*!
119  \brief It returns the the graph description
120 
121  \return String with the graph description
122  */
123  std::string getDescription();
124 
125  /*!
126  \brief Set the graph type (defined in Enums file)
127 
128  \param value Enumerator value that defines the graph type
129 
130  */
131  void setType(std::string graphType);
132 
133  /*!
134  \brief It returns the graph type (defined in Enums file)
135 
136  \return Enumerator value that defines the graph type
137  */
138  std::string getType();
139 
140  /*!
141  \brief Set the graph class (defined in Enums file)
142 
143  \param value Enumerator value that defines the graph class
144 
145  */
146  void setClass(GraphClass value);
147 
148  /*!
149  \brief It returns the the graph class (defined in Enums file)
150 
151  \return Enumerator value that defines the graph class
152  */
153  GraphClass getClass();
154 
155  /*!
156  \brief Set the graph storage mode (defined in Enums file)
157 
158  \param value Enumerator value that defines the graph storage mode
159 
160  */
161  void setStorageMode(GraphStorageMode value);
162 
163  /*!
164  \brief It returns the the graph storage mode (defined in Enums file)
165 
166  \return Enumerator value that defines the graph storage mode
167  */
168  GraphStorageMode getStorageMode();
169 
170  /*!
171  \brief It returns the data source associated with this graph
172 
173  \return A pointer to a data source
174  */
175  te::da::DataSource* getDataSource();
176 
177  /*!
178  \brief It returns the vertex table name that contains the vertex elements in data source
179 
180  \return String with the table name
181  */
182  std::string getVertexTableName();
183 
184  /*!
185  \brief It returns the edge table name that contains the vertex elements in data source
186 
187  \return String with the table name
188  */
189  std::string getEdgeTableName();
190 
191  /*!
192  \brief Add a new property associated to the vertex element
193 
194  param p New property to be associated with vertex elements.
195 
196  \note It's important before using this function call the flush() function, its necessary
197  to force the memory clear and the elements will be loaded with the right size of
198  properties.
199  */
200  virtual void addVertexProperty(te::dt::Property* p);
201 
202  /*!
203  \brief Remove a property associated to the vertex element
204 
205  \param idx Index of the property
206  */
207  virtual void removeVertexProperty(int idx);
208 
209  /*!
210  \brief Get a vertex property given a index
211 
212  \param idx Index of the property
213 
214  \return A property associated to the vertex element if the index is right and a null pointer in other case.
215 
216  */
217  virtual te::dt::Property* getVertexProperty(int idx);
218 
219  /*!
220  \brief Used to verify the number of properties associated to vertex elements
221 
222  \return Integer value with the number of properties.
223 
224  */
225  virtual int getVertexPropertySize();
226 
227  /*!
228  \brief Add a new property associated to the edge element
229 
230  param p New property to be associated with edge elements.
231 
232  \note It's important before using this function call the flush() function, its necessary
233  to force the memory clear and the elements will be loaded with the right size of
234  properties.
235  */
236  virtual void addEdgeProperty(te::dt::Property* p);
237 
238  /*!
239  \brief Remove a property associated to the edge element
240 
241  \param idx Index of the property
242  */
243  virtual void removeEdgeProperty(int idx);
244 
245  /*!
246  \brief Get a edge property given a index
247 
248  \param idx Index of the property
249 
250  \return A property associated to the edge element if the index is right and a null pointer in other case.
251 
252  */
253  virtual te::dt::Property* getEdgeProperty(int idx);
254 
255  /*!
256  \brief Used to verify the number of properties associated to edge elements
257 
258  \return Integer value with the number of properties.
259 
260  */
261  virtual int getEdgePropertySize();
262 
263  /*!
264  \brief Used to get the SRID of the geometry elements associated with this graph
265 
266  \return Integer value that defines the SRID
267  */
268  virtual int getSRID();
269 
270  /*!
271  \brief Used to set the SRID of the geometry elements associated with this graph
272 
273  \param Integer value that defines the SRID
274  */
275  virtual void setSRID(int srid);
276 
277  /*!
278  \brief Used to get the bounding box of the geometry elements associated with this graph
279 
280  \return The bounding box information
281  */
282  virtual te::gm::Envelope* getEnvelope();
283 
284  /*!
285  \brief Used to set the bounding box of the geometry elements associated with this graph
286 
287  \param The bounding box information
288  */
289  virtual void setEnvelope(te::gm::Envelope& extent);
290 
291 
292  protected:
293 
294  int m_id; //!< Attribute graph unique identifier.
295 
296  std::string m_name; //!< Attribute name.
297 
298  std::string m_description; //!< Attribute used to describe a graph.
299 
300  int m_srid; //!< Attribute used to define the graph projection.
301 
302  te::gm::Envelope* m_extent; //!< Attribute used to define the graph extent.
303 
304  std::string m_type; //!< Enum attribute used to defines the graph type.
305 
306  te::graph::GraphClass m_class; //!< Enum attribute used to defines the graph class.
307 
308  te::graph::GraphStorageMode m_mode; //!< Enum attribute used to defines the storage mode.
309 
310  te::da::DataSource* m_ds; //!< Data source attribute, has to be database information
311 
312  VertexProperty* m_vertexProp; //!< Attribute that defines the vertex properties.
313 
314  EdgeProperty* m_edgeProp; //!< Attribute that defines the edge properties.
315 
316 
317  public:
318 
319  size_t m_maxCacheSize; //!< Attribute used to set the max cache size
320  size_t m_maxVecCacheSize; //!< Attribute used to set the max vector cache size
321  double m_boxPercentSize; //!< Attribute used to box percent size used in loader strategy
322 
323  bool m_memoryGraph; //!< Flag used to indicate if the graph is a memory graph
324  };
325 
326  } // end namespace graph
327 } // end namespace te
328 
329 #endif // __TERRALIB_GRAPH_INTERNAL_GRAPHMETADATA_H
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178
std::string m_type
Enum attribute used to defines the graph type.
virtual void load(int id)
Function used to load the graph information given a graph id.
Definition: GraphMetadata.h:73
te::da::DataSource * m_ds
Data source attribute, has to be database information.
GraphClass
Definition: Enums.h:45
std::string m_description
Attribute used to describe a graph.
This class is used to define a set of properties of a Vertex.
EdgeProperty * m_edgeProp
Attribute that defines the edge properties.
bool m_memoryGraph
Flag used to indicate if the graph is a memory graph.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:119
It models a property definition.
Definition: Property.h:59
GraphStorageMode
Definition: Enums.h:55
te::graph::GraphStorageMode m_mode
Enum attribute used to defines the storage mode.
int m_id
Attribute graph unique identifier.
double m_boxPercentSize
Attribute used to box percent size used in loader strategy.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
URI C++ Library.
te::gm::Envelope * m_extent
Attribute used to define the graph extent.
size_t m_maxCacheSize
Attribute used to set the max cache size.
This class is used to define a set of properties of a Edge.
Definition: EdgeProperty.h:51
int m_srid
Attribute used to define the graph projection.
virtual void update()
Function used to update the graph information on a data source.
Definition: GraphMetadata.h:86
virtual void save()
Function used to save the graph information.
Definition: GraphMetadata.h:79
VertexProperty * m_vertexProp
Attribute that defines the vertex properties.
te::graph::GraphClass m_class
Enum attribute used to defines the graph class.
size_t m_maxVecCacheSize
Attribute used to set the max vector cache size.
std::string m_name
Attribute name.
Class used to define the graph metadata informations.
Definition: GraphMetadata.h:56