All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GraphMetadata.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 }
47 
49 {
50  m_ds->close();
51 
52  delete m_ds;
53 
54  delete m_vertexProp;
55  delete m_edgeProp;
56 
57  delete m_extent;
58 }
59 
61 {
62  return m_id;
63 }
64 
65 void te::graph::GraphMetadata::setName(std::string name)
66 {
67  m_name = name;
68 }
69 
71 {
72  return m_name;
73 }
74 
76 {
77  m_description = desc;
78 }
79 
81 {
82  return m_description;
83 }
84 
85 void te::graph::GraphMetadata::setType(std::string graphType)
86 {
87  m_type = graphType;
88 }
89 
91 {
92  return m_type;
93 }
94 
96 {
97  m_class = value;
98 }
99 
101 {
102  return m_class;
103 }
104 
106 {
107  m_mode = value;
108 }
109 
111 {
112  return m_mode;
113 }
114 
116 {
117  return m_ds;
118 }
119 
121 {
122  std::string tableName = "";
123 
124  if(getStorageMode() == te::graph::Vertex_List)
125  {
126  tableName = getName() + Globals::sm_tableVertexModelSufixName;
127  }
128  else if(getStorageMode() == te::graph::Edge_List)
129  {
130  tableName = getName() + Globals::sm_tableVertexAttributeModelSufixName;
131  }
132 
133  return tableName;
134 }
135 
137 {
138  std::string tableName = "";
139 
140  if(getStorageMode() == te::graph::Vertex_List)
141  {
142  tableName = getName() + Globals::sm_tableEdgeAttributeModelSufixName;
143  }
144  else if(getStorageMode() == te::graph::Edge_List)
145  {
146  tableName = getName() + Globals::sm_tableEdgeModelSufixName;
147  }
148 
149  return tableName;
150 }
151 
153 {
154  if(m_vertexProp == 0)
155  {
156  m_vertexProp = new te::graph::VertexProperty();
157  }
158 
159  m_vertexProp->add(p);
160 }
161 
163 {
164  if(m_vertexProp != 0)
165  {
166  te::dt::Property* p = getVertexProperty(idx);
167 
168  m_vertexProp->remove(p);
169  }
170 }
171 
173 {
174  if(m_vertexProp != 0)
175  {
176  return m_vertexProp->getProperty(idx);
177  }
178 
179  return 0;
180 }
181 
183 {
184  if(m_vertexProp != 0)
185  {
186  return m_vertexProp->getProperties().size();
187  }
188 
189  return 0;
190 }
191 
193 {
194  if(m_edgeProp == 0)
195  {
196  m_edgeProp = new te::graph::EdgeProperty();
197  }
198 
199  m_edgeProp->add(p);
200 }
201 
203 {
204  if(m_edgeProp != 0)
205  {
206  te::dt::Property* p = getEdgeProperty(idx);
207 
208  m_edgeProp->remove(p);
209  }
210 }
211 
213 {
214  if(m_edgeProp != 0)
215  {
216  return m_edgeProp->getProperty(idx);
217  }
218 
219  return 0;
220 }
221 
223 {
224  if(m_edgeProp != 0)
225  {
226  return m_edgeProp->getProperties().size();
227  }
228 
229  return 0;
230 }
231 
233 {
234  return m_srid;
235 }
236 
238 {
239  m_srid = srid;
240 }
241 
243 {
244  return m_extent;
245 }
246 
248 {
249  delete m_extent;
250 
251  m_extent = new te::gm::Envelope(extent);
252 }
GraphMetadata(te::da::DataSource *ds)
Default constructor.
GraphClass getClass()
It returns the the graph class (defined in Enums file)
virtual void setEnvelope(te::gm::Envelope &extent)
Used to set the bounding box of the geometry elements associated with this graph. ...
static const int sm_graphVecCacheDefaultMaxSize
This definition is used to set the max graph cache vector size.
Definition: Globals.h:70
GraphStorageMode getStorageMode()
It returns the the graph storage mode (defined in Enums file)
GraphStorageMode
Definition: Enums.h:55
std::string getEdgeTableName()
It returns the edge table name that contains the vertex elements in data source.
virtual te::dt::Property * getVertexProperty(int idx)
Get a vertex property given a index.
virtual int getVertexPropertySize()
Used to verify the number of properties associated to vertex elements.
std::string getName()
It returns the graph name.
void setStorageMode(GraphStorageMode value)
Set the graph storage mode (defined in Enums file)
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.
Definition: EdgeProperty.h:51
GraphClass
Definition: Enums.h:45
static const std::string sm_tableVertexModelSufixName
Database Model Vertex Model Table Name.
Definition: Globals.h:99
std::string getVertexTableName()
It returns the vertex table name that contains the vertex elements in data source.
virtual te::dt::Property * getEdgeProperty(int idx)
Get a edge property given a index.
virtual void addEdgeProperty(te::dt::Property *p)
Add a new property associated to the edge element.
static const int sm_boxLoaderStrategyDefaultSize
This definition is used to set the default box strategy loader box size.
Definition: Globals.h:71
void setName(std::string name)
Set the graph name.
virtual te::gm::Envelope * getEnvelope()
Used to get the bounding box of the geometry elements associated with this graph. ...
size_t m_maxVecCacheSize
Attribute used to set the max vector cache size.
static const std::string sm_tableEdgeModelSufixName
Database Model Edge Model Table Name.
Definition: Globals.h:93
int getId()
It returns the graph id.
static const std::string sm_tableEdgeAttributeModelSufixName
Database Model Edge Attribute Model Table Name.
Definition: Globals.h:94
virtual void removeVertexProperty(int idx)
Remove a property associated to the vertex element.
void setClass(GraphClass value)
Set the graph class (defined in Enums file)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:116
static const std::string sm_tableVertexAttributeModelSufixName
Database Model Vertex Attribute Model Table Name.
Definition: Globals.h:100
virtual void removeEdgeProperty(int idx)
Remove a property associated to the edge element.
virtual int getSRID()
Used to get the SRID of the geometry elements associated with this graph.
It models a property definition.
Definition: Property.h:59
static const int sm_graphCacheDefaultMaxSize
This definition is used to set the max graph cache size.
Definition: Globals.h:69
void setDescription(std::string desc)
Set the graph description.
double m_boxPercentSize
Attribute used to box percent size used in loader strategy.
std::string getType()
It returns the graph type (defined in Enums file)
virtual int getEdgePropertySize()
Used to verify the number of properties associated to edge elements.
This class is used to define a set of properties of a Vertex.
void setType(std::string graphType)
Set the graph type (defined in Enums file)
This class is used to define a set of properties of a Edge.
std::string getDescription()
It returns the the graph description.
This class is used to define a set of properties of a Vertex.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual void setSRID(int srid)
Used to set the SRID of the geometry elements associated with this graph.
Class used to define the graph metadata informations.
size_t m_maxCacheSize
Attribute used to set the max cache size.
virtual ~GraphMetadata()
Default destructor.
te::da::DataSource * getDataSource()
It returns the data source associated with this graph.