Quantum GIS API Documentation  1.7.4
src/core/qgsfeature.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                       qgsfeature.h - Spatial Feature Class
00003                      --------------------------------------
00004 Date                 : 09-Sep-2003
00005 Copyright            : (C) 2003 by Gary E.Sherman
00006 email                : sherman at mrcc.com
00007  ***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 /* $Id$ */
00016 
00017 #ifndef QGSFEATURE_H
00018 #define QGSFEATURE_H
00019 
00020 #include <QMap>
00021 #include <QString>
00022 #include <QVariant>
00023 #include <QList>
00024 
00025 class QgsGeometry;
00026 class QgsRectangle;
00027 class QgsFeature;
00028 
00029 // key = field index, value = field value
00030 typedef QMap<int, QVariant> QgsAttributeMap;
00031 
00032 // key = feature id, value = changed attributes
00033 typedef QMap<int, QgsAttributeMap> QgsChangedAttributesMap;
00034 
00035 // key = feature id, value = changed geometry
00036 typedef QMap<int, QgsGeometry> QgsGeometryMap;
00037 
00038 // key = field index, value = field name
00039 typedef QMap<int, QString> QgsFieldNameMap;
00040 
00041 typedef QList<QgsFeature> QgsFeatureList;
00042 
00049 class CORE_EXPORT QgsFeature
00050 {
00051   public:
00053     QgsFeature( int id = 0, QString typeName = "" );
00054 
00056     QgsFeature( QgsFeature const & rhs );
00057 
00059     QgsFeature & operator=( QgsFeature const & rhs );
00060 
00062     ~QgsFeature();
00063 
00064 
00069     int id() const;
00070 
00075     void setFeatureId( int id );
00076 
00077 
00080     QString typeName() const;
00081 
00082 
00085     void setTypeName( QString typeName );
00086 
00091     const QgsAttributeMap& attributeMap() const;
00092 
00094     void setAttributeMap( const QgsAttributeMap& attributeMap );
00095 
00099     void clearAttributeMap();
00100 
00104     void addAttribute( int field, QVariant attr );
00105 
00107     void deleteAttribute( int field );
00108 
00112     void changeAttribute( int field, QVariant attr );
00113 
00119     bool isValid() const;
00120 
00124     void setValid( bool validity );
00125 
00130     bool isDirty() const;
00131 
00136     void clean();
00137 
00141     QgsGeometry *geometry();
00142 
00147     QgsGeometry *geometryAndOwnership();
00148 
00151     void setGeometry( const QgsGeometry& geom );
00152 
00155     void setGeometry( QgsGeometry* geom );
00156 
00162     void setGeometryAndOwnership( unsigned char * geom, size_t length );
00163 
00164   private:
00165 
00167     int mFid;
00168 
00170     QgsAttributeMap mAttributes;
00171 
00176     QgsGeometry *mGeometry;
00177 
00181     bool mOwnsGeometry;
00182 
00184     // TODO: still applies? [MD]
00185     bool mValid;
00186 
00188     // TODO: still applies? [MD]
00189     bool mDirty;
00190 
00192     QString mTypeName;
00193 
00194 
00195 }; // class QgsFeature
00196 
00197 
00198 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines