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 virtual OGRGeometry *GetSpatialFilter();
00112 virtual void SetSpatialFilter( OGRGeometry * );
00113 virtual void SetSpatialFilter( int iGeomField, OGRGeometry * );
00114
00115 virtual OGRErr SetAttributeFilter( const char * );
00116
00117 virtual void ResetReading();
00118 virtual OGRFeature *GetNextFeature();
00119 virtual OGRErr SetNextByIndex( long nIndex );
00120 virtual OGRFeature *GetFeature( long nFID );
00121 virtual OGRErr SetFeature( OGRFeature *poFeature );
00122 virtual OGRErr CreateFeature( OGRFeature *poFeature );
00123 virtual OGRErr DeleteFeature( long nFID );
00124
00125 virtual const char *GetName();
00126 virtual OGRwkbGeometryType GetGeomType();
00127 virtual OGRFeatureDefn *GetLayerDefn();
00128
00129 virtual OGRSpatialReference *GetSpatialRef();
00130
00131 virtual int GetFeatureCount( int bForce = TRUE );
00132 virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce = TRUE);
00133 virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
00134
00135 virtual int TestCapability( const char * );
00136
00137
00138
00139
00140 virtual OGRErr CreateField( OGRFieldDefn *poField,
00141 int bApproxOK = TRUE );
00142 virtual OGRErr DeleteField( int iField );
00143 virtual OGRErr ReorderFields( int* panMap );
00144 virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
00145
00146 virtual OGRErr SyncToDisk();
00147
00148 virtual OGRStyleTable *GetStyleTable();
00149 virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
00150
00151 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
00152
00153 virtual OGRErr StartTransaction();
00154 virtual OGRErr CommitTransaction();
00155 virtual OGRErr RollbackTransaction();
00156
00157 virtual const char *GetFIDColumn();
00158 virtual const char *GetGeometryColumn();
00159
00160 virtual OGRErr SetIgnoredFields( const char **papszFields );
00161 };
00162
00163 #endif // _OGRLAYERPOOL_H_INCLUDED