All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "../Globals.h"
30 #include "EdgeProperty.h"
31 #include "VertexProperty.h"
32 #include "GraphMetadata.h"
33 
35  m_id(-1),
36  m_extent(0),
37  m_type(""),
38  m_ds(ds),
39  m_vertexProp(0),
40  m_edgeProp(0)
41 
42 {
46  m_memoryGraph = false;
47 }
48 
50 {
51  if(m_ds)
52  m_ds->close();
53 
54  delete m_ds;
55 
56  delete m_vertexProp;
57  delete m_edgeProp;
58 
59  delete m_extent;
60 }
61 
63 {
64  return m_id;
65 }
66 
67 void te::graph::GraphMetadata::setName(std::string name)
68 {
69  m_name = name;
70 }
71 
73 {
74  return m_name;
75 }
76 
78 {
79  m_description = desc;
80 }
81 
83 {
84  return m_description;
85 }
86 
87 void te::graph::GraphMetadata::setType(std::string graphType)
88 {
89  m_type = graphType;
90 }
91 
93 {
94  return m_type;
95 }
96 
98 {
99  m_class = value;
100 }
101 
103 {
104  return m_class;
105 }
106 
108 {
109  m_mode = value;
110 }
111 
113 {
114  return m_mode;
115 }
116 
118 {
119  return m_ds;
120 }
121 
123 {
124  std::string tableName = "";
125 
126  if(getStorageMode() == te::graph::Vertex_List)
127  {
128  tableName = getName() + Globals::sm_tableVertexModelSufixName;
129  }
130  else if(getStorageMode() == te::graph::Edge_List)
131  {
132  tableName = getName() + Globals::sm_tableVertexAttributeModelSufixName;
133  }
134 
135  return tableName;
136 }
137 
139 {
140  std::string tableName = "";
141 
142  if(getStorageMode() == te::graph::Vertex_List)
143  {
144  tableName = getName() + Globals::sm_tableEdgeAttributeModelSufixName;
145  }
146  else if(getStorageMode() == te::graph::Edge_List)
147  {
148  tableName = getName() + Globals::sm_tableEdgeModelSufixName;
149  }
150 
151  return tableName;
152 }
153 
155 {
156  if(m_vertexProp == 0)
157  {
158  m_vertexProp = new te::graph::VertexProperty();
159  }
160 
161  m_vertexProp->add(p);
162 }
163 
165 {
166  if(m_vertexProp != 0)
167  {
168  te::dt::Property* p = getVertexProperty(idx);
169 
170  m_vertexProp->remove(p);
171  }
172 }
173 
175 {
176  if(m_vertexProp != 0)
177  {
178  return m_vertexProp->getProperty(idx);
179  }
180 
181  return 0;
182 }
183 
185 {
186  if(m_vertexProp != 0)
187  {
188  return m_vertexProp->getProperties().size();
189  }
190 
191  return 0;
192 }
193 
195 {
196  if(m_edgeProp == 0)
197  {
198  m_edgeProp = new te::graph::EdgeProperty();
199  }
200 
201  m_edgeProp->add(p);
202 }
203 
205 {
206  if(m_edgeProp != 0)
207  {
208  te::dt::Property* p = getEdgeProperty(idx);
209 
210  m_edgeProp->remove(p);
211  }
212 }
213 
215 {
216  if(m_edgeProp != 0)
217  {
218  return m_edgeProp->getProperty(idx);
219  }
220 
221  return 0;
222 }
223 
225 {
226  if(m_edgeProp != 0)
227  {
228  return m_edgeProp->getProperties().size();
229  }
230 
231  return 0;
232 }
233 
235 {
236  return m_srid;
237 }
238 
240 {
241  m_srid = srid;
242 }
243 
245 {
246  return m_extent;
247 }
248 
250 {
251  delete m_extent;
252 
253  m_extent = new te::gm::Envelope(extent);
254 }
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
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