~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to src/qgsdataprovider.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Halasz
  • Date: 2004-12-21 09:46:27 UTC
  • Revision ID: james.westby@ubuntu.com-20041221094627-r9lb6mlz2o3yp8gn
Tags: upstream-0.6.0
ImportĀ upstreamĀ versionĀ 0.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                qgsdataprovider.h - DataProvider Interface 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: qgsdataprovider.h,v 1.14.2.3 2004/12/10 03:54:23 gsherman Exp $ */
 
16
 
 
17
#ifndef QQGSDATAPROVIDER_H
 
18
#define QQGSDATAPROVIDER_H
 
19
#include <qstring.h>
 
20
#include <vector>
 
21
#include <list>
 
22
class QgsRect;
 
23
class QgsFeature;
 
24
class QgsField;
 
25
class QgsDataSourceURI;
 
26
/** \class QgsDataProvider
 
27
* \brief Abstract base class for spatial data provider implementations
 
28
  *@author Gary E.Sherman
 
29
  */
 
30
 
 
31
class QgsDataProvider {
 
32
 
 
33
public: 
 
34
  /**
 
35
  * We need this so the subclass destructors get called
 
36
  */
 
37
  virtual ~QgsDataProvider() {};
 
38
 
 
39
  /**
 
40
  * Select features based on a bounding rectangle. Features can be retrieved 
 
41
  * with calls to getFirstFeature and getNextFeature. Request for features 
 
42
  * for use in drawing the map canvas should set useIntersect to false.
 
43
  * @param mbr QgsRect containing the extent to use in selecting features
 
44
  * @param useIntersect If true, use the intersects function to select features
 
45
  * rather than the PostGIS && operator that selects based on bounding box
 
46
  * overlap.
 
47
  *
 
48
  */
 
49
  virtual void select(QgsRect *mbr, bool useIntersect=false)=0;
 
50
  /** 
 
51
    * Set the data source specification. This may be a path or database
 
52
  * connection string
 
53
  * @param data source specification
 
54
  */
 
55
  virtual void setDataSourceUri(QString uri) = 0;
 
56
  
 
57
    /** 
 
58
  * Get the data source specification. This may be a path or database
 
59
  * connection string
 
60
  * @return data source specification
 
61
  */
 
62
  virtual QString getDataSourceUri() = 0;
 
63
 
 
64
  virtual QgsDataSourceURI * getURI()=0;
 
65
  /**
 
66
  * Get the extent of the layer
 
67
  * @return QgsRect containing the extent of the layer
 
68
  */
 
69
  virtual QgsRect * extent() = 0;
 
70
    
 
71
  /**
 
72
  * Identify features within the search radius specified by rect
 
73
  * @param rect Bounding rectangle of search radius
 
74
  * @return std::vector containing QgsFeature objects that intersect rect
 
75
  */
 
76
  //virtual std::vector<QgsFeature>& QgsDataProvider::identify(QgsRect *rect)=0;
 
77
 
 
78
   /**
 
79
   * Return the endian of this layer.
 
80
   * @return 0 for NDR (little endian), 1 for XDR (big endian
 
81
   */
 
82
  virtual int endian()=0;
 
83
 
 
84
  /**
 
85
   * Returns true if this is a valid layer. It is up to individual providers
 
86
   * to determine what constitutes a valid layer
 
87
   */
 
88
  virtual bool isValid()=0;
 
89
 
 
90
  /* Reset the layer - for an OGRLayer, this means clearing the
 
91
   * spatial filter and calling ResetReading
 
92
   */
 
93
  virtual void reset()
 
94
  { 
 
95
     // NOP by default 
 
96
  }
 
97
  /**
 
98
   * Update the feature count based on current spatial filter. If not
 
99
   * overridden in the data provider this function returns -1
 
100
   */
 
101
  virtual long updateFeatureCount()
 
102
  {
 
103
    return -1;
 
104
  }
 
105
  /**
 
106
   * Update the extents of the layer. Not implemented by default
 
107
   */
 
108
  virtual void updateExtents()
 
109
  {
 
110
    // NOP by default
 
111
  }
 
112
  /**
 
113
   * Set the subset string used to create a subset of features in
 
114
   * the layer. This may be a sql where clause or any other string
 
115
   * that can be used by the data provider to create a subset.
 
116
   * Must be implemented in the dataprovider.
 
117
   */
 
118
  virtual void setSubsetString(QString subset)
 
119
  {
 
120
    // NOP by default
 
121
  }
 
122
/**
 
123
 * Returns the subset definition string (typically sql) currently in
 
124
 * use by the layer and used by the provider to limit the feature set.
 
125
 * Must be overridden in the dataprovider, otherwise returns a null
 
126
 * QString.
 
127
 */
 
128
  virtual QString subsetString()
 
129
  {
 
130
    return QString::null;
 
131
  }
 
132
    
 
133
};
 
134
 
 
135
 
 
136
#endif
 
137