src/core/qgsvectordataprovider.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     qgsvectordataprovider.h - DataProvider Interface for vector layers
00003      --------------------------------------
00004     Date                 : 23-Sep-2004
00005     Copyright            : (C) 2004 by Marco Hugentobler
00006     email                : marco.hugentobler@autoform.ch
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: qgsvectordataprovider.h 9781 2008-12-13 11:07:45Z jef $ */
00016 #ifndef QGSVECTORDATAPROVIDER_H
00017 #define QGSVECTORDATAPROVIDER_H
00018 
00019 
00020 class QTextCodec;
00021 
00022 #include <QList>
00023 #include <QSet>
00024 #include <QMap>
00025 
00026 //QGIS Includes
00027 #include "qgis.h"
00028 #include "qgsdataprovider.h"
00029 #include "qgsvectorlayer.h"
00030 #include "qgsfield.h"
00031 
00032 typedef QMap<QString, QString> QgsNewAttributesMap;
00033 typedef QMap<QString, QVariant::Type> QgsNativeTypeMap;
00034 
00043 class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
00044 {
00045   public:
00046 
00047     // If you add to this, please also add to capabilitiesString()
00051     enum Capability
00052     {
00053       NoCapabilities =                     0,
00054       AddFeatures =                        1,
00055       DeleteFeatures =               1 <<  1,
00056       ChangeAttributeValues =        1 <<  2,
00057       AddAttributes =                1 <<  3,
00058       DeleteAttributes =             1 <<  4,
00059       SaveAsShapefile =              1 <<  5,
00060       CreateSpatialIndex =           1 <<  6,
00061       SelectAtId =                   1 <<  7,
00062       ChangeGeometries =             1 <<  8,
00063       SelectGeometryAtId =           1 <<  9,
00064       RandomSelectGeometryAtId =     1 << 10,
00065       SequentialSelectGeometryAtId = 1 << 11
00066     };
00067 
00069     const static int EditingCapabilities = AddFeatures | DeleteFeatures |
00070                                            ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes;
00071 
00076     QgsVectorDataProvider( QString uri = QString() );
00077 
00081     virtual ~QgsVectorDataProvider();
00082 
00086     virtual QString storageType() const;
00087 
00095     virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
00096                          QgsRectangle rect = QgsRectangle(),
00097                          bool fetchGeometry = true,
00098                          bool useIntersect = false ) = 0;
00099 
00104     virtual long updateFeatureCount();
00105 
00117     virtual bool featureAtId( int featureId,
00118                               QgsFeature& feature,
00119                               bool fetchGeometry = true,
00120                               QgsAttributeList fetchAttributes = QgsAttributeList() );
00121 
00127     virtual bool nextFeature( QgsFeature& feature ) = 0;
00128 
00133     virtual QGis::WkbType geometryType() const = 0;
00134 
00135 
00140     virtual long featureCount() const = 0;
00141 
00142 
00146     virtual uint fieldCount() const = 0;
00147 
00153     virtual const QgsFieldMap &fields() const = 0;
00154 
00159     virtual QString dataComment() const;
00160 
00162     virtual void rewind() = 0;
00163 
00172     virtual QVariant minimumValue( int index );
00173 
00182     virtual QVariant maximumValue( int index );
00183 
00191     virtual void uniqueValues( int index, QList<QVariant> &uniqueValues );
00192 
00197     virtual bool addFeatures( QgsFeatureList &flist );
00198 
00204     virtual bool deleteFeatures( const QgsFeatureIds &id );
00205 
00211     virtual bool addAttributes( const QgsNewAttributesMap & attributes );
00212 
00218     virtual bool deleteAttributes( const QgsAttributeIds& attributes );
00219 
00225     virtual bool changeAttributeValues( const QgsChangedAttributesMap & attr_map );
00226 
00230     virtual QVariant defaultValue( int fieldId );
00231 
00239     virtual bool changeGeometryValues( QgsGeometryMap & geometry_map );
00240 
00245     virtual bool createSpatialIndex();
00246 
00252     virtual int capabilities() const;
00253 
00257     QString capabilitiesString() const;
00258 
00262     virtual void setEncoding( const QString& e );
00263 
00267     QString encoding() const;
00268 
00272     int fieldNameIndex( const QString& fieldName ) const;
00273 
00275     QMap<QString, int> fieldNameMap() const;
00276 
00280     virtual QgsAttributeList attributeIndexes();
00281 
00283     const QgsNativeTypeMap &supportedNativeTypes() const;
00284 
00289     void enableGeometrylessFeatures( bool fetch );
00290 
00291   protected:
00292     QVariant convertValue( QVariant::Type type, QString value );
00293 
00294     void fillMinMaxCache();
00295 
00296     bool mCacheMinMaxDirty;
00297     QMap<int, QVariant> mCacheMinValues, mCacheMaxValues;
00298 
00300     QTextCodec* mEncoding;
00301 
00303     bool mFetchFeaturesWithoutGeom;
00304 
00306     bool mFetchGeom;
00307 
00309     QgsAttributeList mAttributesToFetch;
00310 
00312     QgsNativeTypeMap mSupportedNativeTypes;
00313 };
00314 
00315 #endif

Generated on Fri Jan 9 01:51:12 2009 for Quantum GIS API Documentation by  doxygen 1.5.1