GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

ogrlayerpool.h
1 /******************************************************************************
2 * $Id: ogrlayerpool.h 32177 2015-12-14 07:25:30Z goatbar $
3 *
4 * Project: OpenGIS Simple Features Reference Implementation
5 * Purpose: Defines OGRLayerPool and OGRProxiedLayer class
6 * Author: Even Rouault, even dot rouault at mines dash paris dot org
7 *
8 ******************************************************************************
9 * Copyright (c) 2012-2013, Even Rouault <even dot rouault at mines-paris dot org>
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 OGRLAYERPOOL_H_INCLUDED
31 #define OGRLAYERPOOL_H_INCLUDED
32
33 #include "ogrsf_frmts.h"
34
35 typedef OGRLayer* (*OpenLayerFunc)(void* user_data);
36 typedef void (*FreeUserDataFunc)(void* user_data);
37
38 class OGRLayerPool;
39
40 /************************************************************************/
41 /* OGRAbstractProxiedLayer */
42 /************************************************************************/
43
44 class OGRAbstractProxiedLayer : public OGRLayer
45 {
46 friend class OGRLayerPool;
47
48 OGRAbstractProxiedLayer *poPrevLayer; /* Chain to a layer that was used more recently */
49 OGRAbstractProxiedLayer *poNextLayer; /* Chain to a layer that was used less recently */
50
51 protected:
52 OGRLayerPool *poPool;
53
54 virtual void CloseUnderlyingLayer() = 0;
55
56 public:
57 OGRAbstractProxiedLayer(OGRLayerPool* poPool);
58 virtual ~OGRAbstractProxiedLayer();
59 };
60
61 /************************************************************************/
62 /* OGRLayerPool */
63 /************************************************************************/
64
65 class OGRLayerPool
66 {
67 protected:
68 OGRAbstractProxiedLayer *poMRULayer; /* the most recently used layer */
69 OGRAbstractProxiedLayer *poLRULayer; /* the least recently used layer (still opened) */
70 int nMRUListSize; /* the size of the list */
71 int nMaxSimultaneouslyOpened;
72
73 public:
74 OGRLayerPool(int nMaxSimultaneouslyOpened = 100);
75 ~OGRLayerPool();
76
77 void SetLastUsedLayer(OGRAbstractProxiedLayer* poProxiedLayer);
78 void UnchainLayer(OGRAbstractProxiedLayer* poProxiedLayer);
79
80 int GetMaxSimultaneouslyOpened() const { return nMaxSimultaneouslyOpened; }
81 int GetSize() const { return nMRUListSize; }
82 };
83
84 /************************************************************************/
85 /* OGRProxiedLayer */
86 /************************************************************************/
87
88 class OGRProxiedLayer : public OGRAbstractProxiedLayer
89 {
90 OpenLayerFunc pfnOpenLayer;
91 FreeUserDataFunc pfnFreeUserData;
92 void *pUserData;
93 OGRLayer *poUnderlyingLayer;
94 OGRFeatureDefn *poFeatureDefn;
95 OGRSpatialReference *poSRS;
96
97 int OpenUnderlyingLayer();
98
99 protected:
100
101 virtual void CloseUnderlyingLayer();
102
103 public:
104
105 OGRProxiedLayer(OGRLayerPool* poPool,
106 OpenLayerFunc pfnOpenLayer,
107 FreeUserDataFunc pfnFreeUserData,
108 void* pUserData);
109 virtual ~OGRProxiedLayer();
110
111 OGRLayer *GetUnderlyingLayer();
112
113 virtual OGRGeometry *GetSpatialFilter();
114 virtual void SetSpatialFilter( OGRGeometry * );
115 virtual void SetSpatialFilter( int iGeomField, OGRGeometry * );
116
117 virtual OGRErr SetAttributeFilter( const char * );
118
119 virtual void ResetReading();
120 virtual OGRFeature *GetNextFeature();
121 virtual OGRErr SetNextByIndex( GIntBig nIndex );
122 virtual OGRFeature *GetFeature( GIntBig nFID );
123 virtual OGRErr ISetFeature( OGRFeature *poFeature );
124 virtual OGRErr ICreateFeature( OGRFeature *poFeature );
125 virtual OGRErr DeleteFeature( GIntBig nFID );
126
127 virtual const char *GetName();
128 virtual OGRwkbGeometryType GetGeomType();
129 virtual OGRFeatureDefn *GetLayerDefn();
130
131 virtual OGRSpatialReference *GetSpatialRef();
132
133 virtual GIntBig GetFeatureCount( int bForce = TRUE );
134 virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce = TRUE);
135 virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
136
137 virtual int TestCapability( const char * );
138
139 virtual OGRErr CreateField( OGRFieldDefn *poField,
140 int bApproxOK = TRUE );
141 virtual OGRErr DeleteField( int iField );
142 virtual OGRErr ReorderFields( int* panMap );
143 virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
144
145 virtual OGRErr SyncToDisk();
146
147 virtual OGRStyleTable *GetStyleTable();
148 virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
149
150 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
151
152 virtual OGRErr StartTransaction();
153 virtual OGRErr CommitTransaction();
154 virtual OGRErr RollbackTransaction();
155
156 virtual const char *GetFIDColumn();
157 virtual const char *GetGeometryColumn();
158
159 virtual OGRErr SetIgnoredFields( const char **papszFields );
160 };
161
162 #endif // OGRLAYERPOOL_H_INCLUDED
OGRProxiedLayer::GetLayerDefn
virtual OGRFeatureDefn * GetLayerDefn()
Fetch the schema information for this layer.
Definition: ogrlayerpool.cpp:368
OGRProxiedLayer::SyncToDisk
virtual OGRErr SyncToDisk()
Flush pending changes to disk.
Definition: ogrlayerpool.cpp:490
OGRProxiedLayer::GetName
virtual const char * GetName()
Return the layer name.
Definition: ogrlayerpool.cpp:348
OGRProxiedLayer::GetExtent
virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce=TRUE)
Fetch the extent of this layer, on the specified geometry field.
Definition: ogrlayerpool.cpp:419
OGRAbstractProxiedLayer
Definition: ogrlayerpool.h:44
OGRProxiedLayer::SetNextByIndex
virtual OGRErr SetNextByIndex(GIntBig nIndex)
Move read cursor to the nIndex'th feature in the current resultset.
Definition: ogrlayerpool.cpp:298
OGRProxiedLayer::GetFeature
virtual OGRFeature * GetFeature(GIntBig nFID)
Fetch a feature by its identifier.
Definition: ogrlayerpool.cpp:308
OGRProxiedLayer::ResetReading
virtual void ResetReading()
Reset feature reading to start on the first feature.
Definition: ogrlayerpool.cpp:278
OGRFeatureDefn
Definition of a feature class or feature layer.
Definition: ogr_feature.h:206
OGRProxiedLayer::GetSpatialFilter
virtual OGRGeometry * GetSpatialFilter()
This method returns the current spatial filter for this layer.
Definition: ogrlayerpool.cpp:239
OGRProxiedLayer::DeleteField
virtual OGRErr DeleteField(int iField)
Delete an existing field on a layer.
Definition: ogrlayerpool.cpp:460
OGRProxiedLayer::CreateField
virtual OGRErr CreateField(OGRFieldDefn *poField, int bApproxOK=TRUE)
Create a new field on a layer.
Definition: ogrlayerpool.cpp:449
OGRFieldDefn
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:62
OGRProxiedLayer::ReorderFields
virtual OGRErr ReorderFields(int *panMap)
Reorder all the fields of a layer.
Definition: ogrlayerpool.cpp:470
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:333
OGRProxiedLayer::SetStyleTableDirectly
virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable)
Set layer style table.
Definition: ogrlayerpool.cpp:510
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:104
ogrsf_frmts.h
Classes related to registration of format support, and opening datasets.
OGRProxiedLayer::GetGeometryColumn
virtual const char * GetGeometryColumn()
This method returns the name of the underlying database column being used as the geometry column...
Definition: ogrlayerpool.cpp:570
OGRProxiedLayer::GetNextFeature
virtual OGRFeature * GetNextFeature()
Fetch the next available feature from this layer.
Definition: ogrlayerpool.cpp:288
OGRProxiedLayer::GetStyleTable
virtual OGRStyleTable * GetStyleTable()
Returns layer style table.
Definition: ogrlayerpool.cpp:500
OGRLayerPool
Definition: ogrlayerpool.h:65
OGRProxiedLayer::TestCapability
virtual int TestCapability(const char *)
Test if this layer supported the named capability.
Definition: ogrlayerpool.cpp:439
OGRProxiedLayer::DeleteFeature
virtual OGRErr DeleteFeature(GIntBig nFID)
Delete feature from layer.
Definition: ogrlayerpool.cpp:338
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:129
OGRProxiedLayer::GetSpatialRef
virtual OGRSpatialReference * GetSpatialRef()
Fetch the spatial reference system for this layer.
Definition: ogrlayerpool.cpp:391
OGREnvelope
Simple container for a bounding region.
Definition: ogr_core.h:48
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:66
OGRProxiedLayer
Definition: ogrlayerpool.h:88
OGRProxiedLayer::SetIgnoredFields
virtual OGRErr SetIgnoredFields(const char **papszFields)
Set which fields can be omitted when retrieving features from the layer.
Definition: ogrlayerpool.cpp:580
OGRFeature
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:274
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:82
OGRProxiedLayer::ICreateFeature
virtual OGRErr ICreateFeature(OGRFeature *poFeature)
Create and write a new feature within a layer.
Definition: ogrlayerpool.cpp:328
OGRProxiedLayer::SetSpatialFilter
virtual void SetSpatialFilter(OGRGeometry *)
Set a new spatial filter.
Definition: ogrlayerpool.cpp:249
OGRProxiedLayer::GetFeatureCount
virtual GIntBig GetFeatureCount(int bForce=TRUE)
Fetch the feature count in this layer.
Definition: ogrlayerpool.cpp:409
OGRProxiedLayer::ISetFeature
virtual OGRErr ISetFeature(OGRFeature *poFeature)
Rewrite an existing feature.
Definition: ogrlayerpool.cpp:318
OGRProxiedLayer::SetStyleTable
virtual void SetStyleTable(OGRStyleTable *poStyleTable)
Set layer style table.
Definition: ogrlayerpool.cpp:520
OGRProxiedLayer::GetFIDColumn
virtual const char * GetFIDColumn()
This method returns the name of the underlying database column being used as the FID column...
Definition: ogrlayerpool.cpp:560
OGRProxiedLayer::AlterFieldDefn
virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn, int nFlags)
Alter the definition of an existing field on a layer.
Definition: ogrlayerpool.cpp:480
OGRProxiedLayer::SetAttributeFilter
virtual OGRErr SetAttributeFilter(const char *)
Set a new attribute query.
Definition: ogrlayerpool.cpp:268
OGRProxiedLayer::GetGeomType
virtual OGRwkbGeometryType GetGeomType()
Return the layer geometry type.
Definition: ogrlayerpool.cpp:358

Generated for GDAL by 1.8.8.