OGR
ogr_gensql.h
1 /******************************************************************************
2  * $Id: ogr_gensql.h 24634 2012-07-01 14:39:00Z rouault $
3  *
4  * Project: OpenGIS Simple Features Reference Implementation
5  * Purpose: Classes related to generic implementation of ExecuteSQL().
6  * Author: Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2002, Frank Warmerdam
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #ifndef _OGR_GENSQL_H_INCLUDED
31 #define _OGR_GENSQL_H_INCLUDED
32 
33 #include "ogrsf_frmts.h"
34 #include "swq.h"
35 #include "cpl_hash_set.h"
36 
37 /************************************************************************/
38 /* OGRGenSQLResultsLayer */
39 /************************************************************************/
40 
41 class CPL_DLL OGRGenSQLResultsLayer : public OGRLayer
42 {
43  private:
44  OGRDataSource *poSrcDS;
45  OGRLayer *poSrcLayer;
46  void *pSelectInfo;
47 
48  char *pszWHERE;
49 
50  OGRLayer **papoTableLayers;
51 
52  OGRFeatureDefn *poDefn;
53 
54  int PrepareSummary();
55 
56  int nIndexSize;
57  long *panFIDIndex;
58  int bOrderByValid;
59 
60  int nNextIndexFID;
61  OGRFeature *poSummaryFeature;
62 
63  int iFIDFieldIndex;
64 
65  int nExtraDSCount;
66  OGRDataSource **papoExtraDS;
67 
68  OGRFeature *TranslateFeature( OGRFeature * );
69  void CreateOrderByIndex();
70  void SortIndexSection( OGRField *pasIndexFields,
71  int nStart, int nEntries );
72  int Compare( OGRField *pasFirst, OGRField *pasSecond );
73 
74  void ClearFilters();
75 
76  void FindAndSetIgnoredFields();
77  void ExploreExprForIgnoredFields(swq_expr_node* expr, CPLHashSet* hSet);
78  void AddFieldDefnToSet(int iTable, int iColumn, CPLHashSet* hSet);
79 
80  int ContainGeomSpecialField(swq_expr_node* expr);
81 
82  void InvalidateOrderByIndex();
83 
84  public:
86  void *pSelectInfo,
87  OGRGeometry *poSpatFilter,
88  const char *pszWHERE,
89  const char *pszDialect );
90  virtual ~OGRGenSQLResultsLayer();
91 
92  virtual OGRGeometry *GetSpatialFilter();
93 
94  virtual void ResetReading();
95  virtual OGRFeature *GetNextFeature();
96  virtual OGRErr SetNextByIndex( long nIndex );
97  virtual OGRFeature *GetFeature( long nFID );
98 
99  virtual OGRFeatureDefn *GetLayerDefn();
100 
102 
103  virtual int GetFeatureCount( int bForce = TRUE );
104  virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
105 
106  virtual int TestCapability( const char * );
107 
108  virtual void SetSpatialFilter( OGRGeometry * );
109  virtual OGRErr SetAttributeFilter( const char * );
110 };
111 
112 #endif /* ndef _OGR_GENSQL_H_INCLUDED */
113 

Generated for GDAL by doxygen 1.8.4.