ogreditablelayer.h

00001 /******************************************************************************
00002  * $Id: ogreditablelayer.h 33714 2016-03-13 05:42:13Z goatbar $
00003  *
00004  * Project:  OpenGIS Simple Features Reference Implementation
00005  * Purpose:  Defines OGREditableLayer class
00006  * Author:   Even Rouault <even.rouault at spatialys.com>
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 2015, Even Rouault <even.rouault at spatialys.com>
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining a
00012  * copy of this software and associated documentation files (the "Software"),
00013  * to deal in the Software without restriction, including without limitation
00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00015  * and/or sell copies of the Software, and to permit persons to whom the
00016  * Software is furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included
00019  * in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00027  * DEALINGS IN THE SOFTWARE.
00028  ****************************************************************************/
00029 
00030 #ifndef OGREDITABLELAYER_H_INCLUDED
00031 #define OGREDITABLELAYER_H_INCLUDED
00032 
00033 #include "ogrlayerdecorator.h"
00034 #include <set>
00035 
00036 class CPL_DLL IOGREditableLayerSynchronizer
00037 {
00038     public:
00039         virtual ~IOGREditableLayerSynchronizer();
00040 
00041         virtual OGRErr EditableSyncToDisk(OGRLayer* poEditableLayer,
00042                                           OGRLayer** ppoDecoratedLayer) = 0;
00043 };
00044 
00045 class CPL_DLL OGREditableLayer : public OGRLayerDecorator
00046 {
00047   protected:
00048 
00049     IOGREditableLayerSynchronizer *m_poSynchronizer;
00050     bool                           m_bTakeOwnershipSynchronizer;
00051     OGRFeatureDefn                *m_poEditableFeatureDefn;
00052     GIntBig                        m_nNextFID;
00053     std::set<GIntBig>              m_oSetCreated;
00054     std::set<GIntBig>              m_oSetEdited;
00055     std::set<GIntBig>              m_oSetDeleted;
00056     std::set<GIntBig>::iterator    m_oIter;
00057     std::set<CPLString>            m_oSetDeletedFields;
00058     OGRLayer                      *m_poMemLayer;
00059     bool                           m_bStructureModified;
00060     bool                           m_bSupportsCreateGeomField;
00061     bool                           m_bSupportsCurveGeometries;
00062 
00063     OGRFeature                    *Translate(OGRFeatureDefn* poTargetDefn,
00064                                              OGRFeature* poSrcFeature,
00065                                              bool bCanStealSrcFeature,
00066                                              bool bHideDeletedFields);
00067     void                           DetectNextFID();
00068     int                            GetSrcGeomFieldIndex(int iGeomField);
00069 
00070   public:
00071 
00072                        OGREditableLayer(OGRLayer* poDecoratedLayer,
00073                                         bool bTakeOwnershipDecoratedLayer,
00074                                         IOGREditableLayerSynchronizer* poSynchronizer,
00075                                         bool bTakeOwnershipSynchronizer);
00076     virtual           ~OGREditableLayer();
00077 
00078     void                SetNextFID(GIntBig nNextFID);
00079     void                SetSupportsCreateGeomField(bool SupportsCreateGeomField);
00080     void                SetSupportsCurveGeometries(bool bSupportsCurveGeometries);
00081 
00082     virtual OGRGeometry *GetSpatialFilter();
00083     virtual void        SetSpatialFilter( OGRGeometry * );
00084     virtual void        SetSpatialFilterRect( double dfMinX, double dfMinY,
00085                                               double dfMaxX, double dfMaxY );
00086     virtual void        SetSpatialFilter( int iGeomField, OGRGeometry * );
00087     virtual void        SetSpatialFilterRect( int iGeomField, double dfMinX, double dfMinY,
00088                                               double dfMaxX, double dfMaxY );
00089 
00090     virtual OGRErr      SetAttributeFilter( const char * );
00091 
00092     virtual void        ResetReading();
00093     virtual OGRFeature *GetNextFeature();
00094     virtual OGRErr      SetNextByIndex( GIntBig nIndex );
00095     virtual OGRFeature *GetFeature( GIntBig nFID );
00096     virtual OGRErr      ISetFeature( OGRFeature *poFeature );
00097     virtual OGRErr      ICreateFeature( OGRFeature *poFeature );
00098     virtual OGRErr      DeleteFeature( GIntBig nFID );
00099 
00100     virtual OGRwkbGeometryType GetGeomType();
00101     virtual OGRFeatureDefn *GetLayerDefn();
00102 
00103     virtual OGRSpatialReference *GetSpatialRef();
00104 
00105     virtual GIntBig     GetFeatureCount( int bForce = TRUE );
00106     virtual OGRErr      GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce = TRUE);
00107     virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
00108 
00109     virtual int         TestCapability( const char * );
00110 
00111     virtual OGRErr      CreateField( OGRFieldDefn *poField,
00112                                      int bApproxOK = TRUE );
00113     virtual OGRErr      DeleteField( int iField );
00114     virtual OGRErr      ReorderFields( int* panMap );
00115     virtual OGRErr      AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
00116 
00117     virtual OGRErr      CreateGeomField( OGRGeomFieldDefn *poField,
00118                                          int bApproxOK = TRUE );
00119 
00120     virtual OGRErr      SyncToDisk();
00121 
00122     virtual OGRErr      StartTransaction();
00123     virtual OGRErr      CommitTransaction();
00124     virtual OGRErr      RollbackTransaction();
00125 
00126     virtual const char *GetGeometryColumn();
00127 };
00128 
00129 #endif // OGREDITABLELAYER_H_INCLUDED

Generated for GDAL by doxygen 1.6.1.