Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsfeature.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeature.h - Spatial Feature Class
3  --------------------------------------
4 Date : 09-Sep-2003
5 Copyright : (C) 2003 by Gary E.Sherman
6 email : sherman at mrcc.com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 /* $Id$ */
16 
17 #ifndef QGSFEATURE_H
18 #define QGSFEATURE_H
19 
20 #include <QMap>
21 #include <QString>
22 #include <QVariant>
23 #include <QList>
24 
25 class QgsGeometry;
26 class QgsRectangle;
27 class QgsFeature;
28 
29 // key = field index, value = field value
30 typedef QMap<int, QVariant> QgsAttributeMap;
31 
32 // key = feature id, value = changed attributes
33 typedef QMap<int, QgsAttributeMap> QgsChangedAttributesMap;
34 
35 // key = feature id, value = changed geometry
36 typedef QMap<int, QgsGeometry> QgsGeometryMap;
37 
38 // key = field index, value = field name
39 typedef QMap<int, QString> QgsFieldNameMap;
40 
41 typedef QList<QgsFeature> QgsFeatureList;
42 
49 class CORE_EXPORT QgsFeature
50 {
51  public:
53  QgsFeature( int id = 0, QString typeName = "" );
54 
56  QgsFeature( QgsFeature const & rhs );
57 
59  QgsFeature & operator=( QgsFeature const & rhs );
60 
62  ~QgsFeature();
63 
64 
69  int id() const;
70 
75  void setFeatureId( int id );
76 
77 
80  QString typeName() const;
81 
82 
85  void setTypeName( QString typeName );
86 
91  const QgsAttributeMap& attributeMap() const;
92 
94  void setAttributeMap( const QgsAttributeMap& attributeMap );
95 
99  void clearAttributeMap();
100 
104  void addAttribute( int field, QVariant attr );
105 
107  void deleteAttribute( int field );
108 
112  void changeAttribute( int field, QVariant attr );
113 
119  bool isValid() const;
120 
124  void setValid( bool validity );
125 
130  bool isDirty() const;
131 
136  void clean();
137 
141  QgsGeometry *geometry();
142 
147  QgsGeometry *geometryAndOwnership();
148 
151  void setGeometry( const QgsGeometry& geom );
152 
155  void setGeometry( QgsGeometry* geom );
156 
162  void setGeometryAndOwnership( unsigned char * geom, size_t length );
163 
164  private:
165 
167  int mFid;
168 
171 
177 
182 
184  // TODO: still applies? [MD]
185  bool mValid;
186 
188  // TODO: still applies? [MD]
189  bool mDirty;
190 
192  QString mTypeName;
193 
194 
195 }; // class QgsFeature
196 
197 
198 #endif