00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _OGRLAYERPOOL_H_INCLUDED
00031 #define _OGRLAYERPOOL_H_INCLUDED
00032
00033 #include "ogrsf_frmts.h"
00034
00035 typedef OGRLayer* (*OpenLayerFunc)(void* user_data);
00036 typedef void (*FreeUserDataFunc)(void* user_data);
00037
00038 class OGRLayerPool;
00039
00040
00041
00042
00043
00044 class OGRAbstractProxiedLayer : public OGRLayer
00045 {
00046 friend class OGRLayerPool;
00047
00048 OGRAbstractProxiedLayer *poPrevLayer;
00049 OGRAbstractProxiedLayer *poNextLayer;
00050
00051 protected:
00052 OGRLayerPool *poPool;
00053
00054 virtual void CloseUnderlyingLayer() = 0;
00055
00056 public:
00057 OGRAbstractProxiedLayer(OGRLayerPool* poPool);
00058 virtual ~OGRAbstractProxiedLayer();
00059 };
00060
00061
00062
00063
00064
00065 class OGRLayerPool
00066 {
00067 protected:
00068 OGRAbstractProxiedLayer *poMRULayer;
00069 OGRAbstractProxiedLayer *poLRULayer;
00070 int nMRUListSize;
00071 int nMaxSimultaneouslyOpened;
00072
00073 public:
00074 OGRLayerPool(int nMaxSimultaneouslyOpened = 100);
00075 ~OGRLayerPool();
00076
00077 void SetLastUsedLayer(OGRAbstractProxiedLayer* poProxiedLayer);
00078 void UnchainLayer(OGRAbstractProxiedLayer* poProxiedLayer);
00079
00080 int GetMaxSimultaneouslyOpened() const { return nMaxSimultaneouslyOpened; }
00081 int GetSize() const { return nMRUListSize; }
00082 };
00083
00084
00085
00086
00087
00088 class OGRProxiedLayer : public OGRAbstractProxiedLayer
00089 {
00090 OpenLayerFunc pfnOpenLayer;
00091 FreeUserDataFunc pfnFreeUserData;
00092 void *pUserData;
00093 OGRLayer *poUnderlyingLayer;
00094 OGRFeatureDefn *poFeatureDefn;
00095 OGRSpatialReference *poSRS;
00096
00097 int OpenUnderlyingLayer();
00098
00099 protected:
00100
00101 virtual void CloseUnderlyingLayer();
00102
00103 public:
00104
00105 OGRProxiedLayer(OGRLayerPool* poPool,
00106 OpenLayerFunc pfnOpenLayer,
00107 FreeUserDataFunc pfnFreeUserData,
00108 void* pUserData);
00109 virtual ~OGRProxiedLayer();
00110
00111 OGRLayer *GetUnderlyingLayer();
00112
00113 virtual OGRGeometry *GetSpatialFilter();
00114 virtual void SetSpatialFilter( OGRGeometry * );
00115 virtual void SetSpatialFilter( int iGeomField, OGRGeometry * );
00116
00117 virtual OGRErr SetAttributeFilter( const char * );
00118
00119 virtual void ResetReading();
00120 virtual OGRFeature *GetNextFeature();
00121 virtual OGRErr SetNextByIndex( GIntBig nIndex );
00122 virtual OGRFeature *GetFeature( GIntBig nFID );
00123 virtual OGRErr ISetFeature( OGRFeature *poFeature );
00124 virtual OGRErr ICreateFeature( OGRFeature *poFeature );
00125 virtual OGRErr DeleteFeature( GIntBig nFID );
00126
00127 virtual const char *GetName();
00128 virtual OGRwkbGeometryType GetGeomType();
00129 virtual OGRFeatureDefn *GetLayerDefn();
00130
00131 virtual OGRSpatialReference *GetSpatialRef();
00132
00133 virtual GIntBig GetFeatureCount( int bForce = TRUE );
00134 virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce = TRUE);
00135 virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
00136
00137 virtual int TestCapability( const char * );
00138
00139 virtual OGRErr CreateField( OGRFieldDefn *poField,
00140 int bApproxOK = TRUE );
00141 virtual OGRErr DeleteField( int iField );
00142 virtual OGRErr ReorderFields( int* panMap );
00143 virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
00144
00145 virtual OGRErr SyncToDisk();
00146
00147 virtual OGRStyleTable *GetStyleTable();
00148 virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
00149
00150 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
00151
00152 virtual OGRErr StartTransaction();
00153 virtual OGRErr CommitTransaction();
00154 virtual OGRErr RollbackTransaction();
00155
00156 virtual const char *GetFIDColumn();
00157 virtual const char *GetGeometryColumn();
00158
00159 virtual OGRErr SetIgnoredFields( const char **papszFields );
00160 };
00161
00162 #endif // _OGRLAYERPOOL_H_INCLUDED