Loading...
Searching...
No Matches
Edge.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 Edge.h
22
23 \brief Class used to define the edge struct of a graph. Its compose
24 with a identifier, the vertex origin and destiny information,
25 a set of properties if exist and flags to inform his state
26 (new or dirty).
27*/
28
29#ifndef __TERRALIB_GRAPH_INTERNAL_EDGE_H
30#define __TERRALIB_GRAPH_INTERNAL_EDGE_H
31
32// Terralib Includes
33#include "../Config.h"
34
35// STL Includes
36#include <string>
37#include <vector>
38
39namespace te
40{
41 // Forward declarations
42 namespace dt { class AbstractData; }
43
44 namespace graph
45 {
46
47 /*!
48 \class Edge
49
50 \brief Class used to define the edge struct of a graph. Its compose
51 with a identifier, the vertex origin and destiny information,
52 a set of properties if exist and flags to inform his state
53 (new or dirty).
54
55 \sa AbstractGraph
56 */
57
59 {
60 public:
61
62 /*!
63 \brief Constructor.
64
65 \param id Edge identifier
66
67 \param vFrom The vertex origin Id
68
69 \param vTo The vertex destiny Id
70
71 \param isNew Flag used to indicate that the element is new
72
73 */
74 Edge(int id, int vFrom, int vTo, bool isNew = true);
75
76 /*! \brief Copy constructor. */
78
79 /*! \brief Default destructor. */
81
82 /*!
83 \brief It returns the edge identification
84
85 \return Integer value with the edge Id
86 */
87 int getId();
88
89 /*!
90 \brief It returns the vertex origin identification
91
92 \return Integer value with the vertex Id
93 */
94 int getIdFrom();
95
96 /*!
97 \brief It returns the vertex destiny identification
98
99 \return Integer value with the vertex Id
100 */
101 int getIdTo();
102
103 /*!
104 \brief It returns the vector of attributes associated with this element
105
106 \return A vector of AbstractData (can be any type of data)
107 */
108 std::vector<te::dt::AbstractData*>& getAttributes();
109
110 /*!
111 \brief This function is used to set the number of attributes associated with the edge elements
112
113 \param size Integer value to define the attribute size
114
115 \note Its important to use this method after a new property was associated to a edge
116 Function defined in AbstractGraph addEdgeProperty.
117
118 */
119 void setAttributeVecSize(int size);
120
121 /*!
122 \brief Add a new attribute to this element
123
124 \param idx Index of the new attribute (must be a valid position)
125
126 \param ad AbstractData (can be any type of data)
127
128 */
130
131 /*!
132 \brief Remove a attribute associated with this element
133
134 \param idx Index of the attribute (must be a valid position)
135
136 */
137 void removeAttribute(int idx);
138
139 /*!
140 \brief Flag used to indicate that this element was changed
141
142 \param flag Boolean value used to indicate the edge state
143 */
144 void setDirty(bool flag);
145
146 /*!
147 \brief Used to verify the edge state.
148
149 \return Boolean value used to indicate the edge state
150 */
151 bool isDirty();
152
153 /*!
154 \brief Flag used to indicate that this element was a new one
155
156 \return Boolean value used to indicate the edge state
157 */
158 bool isNew();
159
160
161 protected:
162 int m_edgeId; //!< This is the edge unique identifier.
163
164 int m_vertexIdFrom; //!< Origin vertex identifier from this edge.
165
166 int m_vertexIdTo; //!< Destiny vertex identifier from this edge.
167
168 std::vector<te::dt::AbstractData*> m_attrs; //!< This is the list of all edge attributes.
169
170 bool m_dirty; //!< Flag used to indicate that edge was changed
171
172 bool m_new; //!< Flag used to indicate if this element is a new one.
173 };
174 } // end namespace graph
175} // end namespace te
176
177#endif // __TERRALIB_GRAPH_INTERNAL_EDGE_H
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.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
bool m_dirty
Flag used to indicate that edge was changed.
Definition: Edge.h:170
void setDirty(bool flag)
Flag used to indicate that this element was changed.
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the edge elements.
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element.
bool isDirty()
Used to verify the edge state.
std::vector< te::dt::AbstractData * > m_attrs
This is the list of all edge attributes.
Definition: Edge.h:168
int m_edgeId
This is the edge unique identifier.
Definition: Edge.h:162
int m_vertexIdFrom
Origin vertex identifier from this edge.
Definition: Edge.h:164
bool isNew()
Flag used to indicate that this element was a new one.
Edge(te::graph::Edge *rhs)
Copy constructor.
void removeAttribute(int idx)
Remove a attribute associated with this element.
~Edge()
Default destructor.
int getIdTo()
It returns the vertex destiny identification.
bool m_new
Flag used to indicate if this element is a new one.
Definition: Edge.h:172
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
int getIdFrom()
It returns the vertex origin identification.
int getId()
It returns the edge identification.
int m_vertexIdTo
Destiny vertex identifier from this edge.
Definition: Edge.h:166
Edge(int id, int vFrom, int vTo, bool isNew=true)
Constructor.
TerraLib.
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178