GraphMetadata.cpp
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.cpp
22 
23  \brief Class used to define the graph metadata informations.
24 */
25 
26 // TerraLib Includes
27 #include "../../geometry/Envelope.h"
28 #include "../../dataaccess/datasource/DataSource.h"
29 #include "../../srs/Config.h"
30 #include "../Globals.h"
31 #include "EdgeProperty.h"
32 #include "VertexProperty.h"
33 #include "GraphMetadata.h"
34 
36  m_id(-1),
37  m_srid(TE_UNKNOWN_SRS),
38  m_extent(0),
39  m_type(""),
40  m_ds(ds),
41  m_vertexProp(0),
42  m_edgeProp(0)
43 
44 {
48  m_memoryGraph = false;
49 }
50 
52 {
53  if(m_ds)
54  m_ds->close();
55 
56  delete m_ds;
57 
58  delete m_vertexProp;
59  delete m_edgeProp;
60 
61  delete m_extent;
62 }
63 
65 {
66  return m_id;
67 }
68 
69 void te::graph::GraphMetadata::setName(std::string name)
70 {
71  m_name = name;
72 }
73 
75 {
76  return m_name;
77 }
78 
80 {
81  m_description = desc;
82 }
83 
85 {
86  return m_description;
87 }
88 
89 void te::graph::GraphMetadata::setType(std::string graphType)
90 {
91  m_type = graphType;
92 }
93 
95 {
96  return m_type;
97 }
98 
100 {
101  m_class = value;
102 }
103 
105 {
106  return m_class;
107 }
108 
110 {
111  m_mode = value;
112 }
113 
115 {
116  return m_mode;
117 }
118 
120 {
121  return m_ds;
122 }
123 
125 {
126  std::string tableName = "";
127 
128  if(getStorageMode() == te::graph::Vertex_List)
129  {
130  tableName = getName() + Globals::sm_tableVertexModelSufixName;
131  }
132  else if(getStorageMode() == te::graph::Edge_List)
133  {
134  tableName = getName() + Globals::sm_tableVertexAttributeModelSufixName;
135  }
136 
137  return tableName;
138 }
139 
141 {
142  std::string tableName = "";
143 
144  if(getStorageMode() == te::graph::Vertex_List)
145  {
146  tableName = getName() + Globals::sm_tableEdgeAttributeModelSufixName;
147  }
148  else if(getStorageMode() == te::graph::Edge_List)
149  {
150  tableName = getName() + Globals::sm_tableEdgeModelSufixName;
151  }
152 
153  return tableName;
154 }
155 
157 {
158  if(m_vertexProp == 0)
159  {
160  m_vertexProp = new te::graph::VertexProperty();
161  }
162 
163  m_vertexProp->add(p);
164 }
165 
167 {
168  if(m_vertexProp != 0)
169  {
170  te::dt::Property* p = getVertexProperty(idx);
171 
172  m_vertexProp->remove(p);
173  }
174 }
175 
177 {
178  if(m_vertexProp != 0)
179  {
180  return m_vertexProp->getProperty(idx);
181  }
182 
183  return 0;
184 }
185 
187 {
188  if(m_vertexProp != 0)
189  {
190  return m_vertexProp->getProperties().size();
191  }
192 
193  return 0;
194 }
195 
197 {
198  if(m_edgeProp == 0)
199  {
200  m_edgeProp = new te::graph::EdgeProperty();
201  }
202 
203  m_edgeProp->add(p);
204 }
205 
207 {
208  if(m_edgeProp != 0)
209  {
210  te::dt::Property* p = getEdgeProperty(idx);
211 
212  m_edgeProp->remove(p);
213  }
214 }
215 
217 {
218  if(m_edgeProp != 0)
219  {
220  return m_edgeProp->getProperty(idx);
221  }
222 
223  return 0;
224 }
225 
227 {
228  if(m_edgeProp != 0)
229  {
230  return m_edgeProp->getProperties().size();
231  }
232 
233  return 0;
234 }
235 
237 {
238  return m_srid;
239 }
240 
242 {
243  m_srid = srid;
244 }
245 
247 {
248  return m_extent;
249 }
250 
252 {
253  delete m_extent;
254 
255  m_extent = new te::gm::Envelope(extent);
256 }
te::da::DataSource * getDataSource()
It returns the data source associated with this graph.
GraphClass getClass()
It returns the the graph class (defined in Enums file)
virtual ~GraphMetadata()
Default destructor.
virtual te::dt::Property * getVertexProperty(int idx)
Get a vertex property given a index.
virtual int getSRID()
Used to get the SRID of the geometry elements associated with this graph.
virtual te::dt::Property * getEdgeProperty(int idx)
Get a edge property given a index.
virtual int getVertexPropertySize()
Used to verify the number of properties associated to vertex elements.
GraphClass
Definition: Enums.h:45
void setStorageMode(GraphStorageMode value)
Set the graph storage mode (defined in Enums file)
This class is used to define a set of properties of a Vertex.
virtual void addVertexProperty(te::dt::Property *p)
Add a new property associated to the vertex element.
This class is used to define a set of properties of a Edge.
virtual void setEnvelope(te::gm::Envelope &extent)
Used to set the bounding box of the geometry elements associated with this graph. ...
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:118
virtual te::gm::Envelope * getEnvelope()
Used to get the bounding box of the geometry elements associated with this graph. ...
It models a property definition.
Definition: Property.h:59
Class used to define the graph metadata informations.
GraphStorageMode
Definition: Enums.h:55
void setName(std::string name)
Set the graph name.
std::string getName()
It returns the graph name.
void setClass(GraphClass value)
Set the graph class (defined in Enums file)
static const int sm_graphCacheDefaultMaxSize
This definition is used to set the max graph cache size.
Definition: Globals.h:67
double m_boxPercentSize
Attribute used to box percent size used in loader strategy.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:41
std::string getDescription()
It returns the the graph description.
size_t m_maxCacheSize
Attribute used to set the max cache size.
void setType(std::string graphType)
Set the graph type (defined in Enums file)
virtual void setSRID(int srid)
Used to set the SRID of the geometry elements associated with this graph.
This class is used to define a set of properties of a Vertex.
This class is used to define a set of properties of a Edge.
Definition: EdgeProperty.h:51
int getId()
It returns the graph id.
static const int sm_boxLoaderStrategyDefaultSize
This definition is used to set the default box strategy loader box size.
Definition: Globals.h:69
std::string getEdgeTableName()
It returns the edge table name that contains the vertex elements in data source.
virtual void removeVertexProperty(int idx)
Remove a property associated to the vertex element.
virtual void removeEdgeProperty(int idx)
Remove a property associated to the edge element.
GraphMetadata(te::da::DataSource *ds)
Default constructor.
virtual int getEdgePropertySize()
Used to verify the number of properties associated to edge elements.
std::string getVertexTableName()
It returns the vertex table name that contains the vertex elements in data source.
std::string getType()
It returns the graph type (defined in Enums file)
static const int sm_graphVecCacheDefaultMaxSize
This definition is used to set the max graph cache vector size.
Definition: Globals.h:68
GraphStorageMode getStorageMode()
It returns the the graph storage mode (defined in Enums file)
void setDescription(std::string desc)
Set the graph description.
static const std::string sm_tableEdgeAttributeModelSufixName
Database Model Edge Attribute Model Table Name.
Definition: Globals.h:90
size_t m_maxVecCacheSize
Attribute used to set the max vector cache size.
static const std::string sm_tableVertexAttributeModelSufixName
Database Model Vertex Attribute Model Table Name.
Definition: Globals.h:96
static const std::string sm_tableEdgeModelSufixName
Database Model Edge Model Table Name.
Definition: Globals.h:89
virtual void addEdgeProperty(te::dt::Property *p)
Add a new property associated to the edge element.
static const std::string sm_tableVertexModelSufixName
Database Model Vertex Model Table Name.
Definition: Globals.h:95