ogrsf_frmts.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogrsf_frmts.h 10646 2007-01-18 02:38:10Z warmerdam $
00003  *
00004  * Project:  OpenGIS Simple Features Reference Implementation
00005  * Purpose:  Classes related to format registration, and file opening.
00006  * Author:   Frank Warmerdam, warmerda@home.com
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 1999,  Les Technologies SoftMap Inc.
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 _OGRSF_FRMTS_H_INCLUDED
00031 #define _OGRSF_FRMTS_H_INCLUDED
00032 
00033 #include "ogr_feature.h"
00034 #include "ogr_featurestyle.h"
00035 
00042 class OGRLayerAttrIndex;
00043 class OGRSFDriver;
00044 
00045 /************************************************************************/
00046 /*                               OGRLayer                               */
00047 /************************************************************************/
00048 
00054 class CPL_DLL OGRLayer
00055 {
00056   protected:
00057     int          m_bFilterIsEnvelope;
00058     OGRGeometry  *m_poFilterGeom;
00059     OGREnvelope  m_sFilterEnvelope;
00060 
00061     int          FilterGeometry( OGRGeometry * );
00062     int          InstallFilter( OGRGeometry * );
00063 
00064   public:
00065     OGRLayer();
00066     virtual     ~OGRLayer();
00067 
00068     virtual OGRGeometry *GetSpatialFilter();
00069     virtual void        SetSpatialFilter( OGRGeometry * );
00070     virtual void        SetSpatialFilterRect( double dfMinX, double dfMinY,
00071                                               double dfMaxX, double dfMaxY );
00072 
00073     virtual OGRErr      SetAttributeFilter( const char * );
00074 
00075     virtual void        ResetReading() = 0;
00076     virtual OGRFeature *GetNextFeature() = 0;
00077     virtual OGRErr      SetNextByIndex( long nIndex );
00078     virtual OGRFeature *GetFeature( long nFID );
00079     virtual OGRErr      SetFeature( OGRFeature *poFeature );
00080     virtual OGRErr      CreateFeature( OGRFeature *poFeature );
00081     virtual OGRErr      DeleteFeature( long nFID );
00082 
00083     virtual OGRFeatureDefn *GetLayerDefn() = 0;
00084 
00085     virtual OGRSpatialReference *GetSpatialRef() { return NULL; }
00086 
00087     virtual int         GetFeatureCount( int bForce = TRUE );
00088     virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
00089 
00090     virtual int         TestCapability( const char * ) = 0;
00091 
00092     virtual const char *GetInfo( const char * );
00093 
00094     virtual OGRErr      CreateField( OGRFieldDefn *poField,
00095                                      int bApproxOK = TRUE );
00096 
00097     virtual OGRErr      SyncToDisk();
00098 
00099     OGRStyleTable       *GetStyleTable(){ return m_poStyleTable; }
00100     void                SetStyleTableDirectly( OGRStyleTable *poStyleTable )
00101                             { if ( m_poStyleTable ) delete m_poStyleTable;
00102                               m_poStyleTable = poStyleTable; }
00103     void                SetStyleTable(OGRStyleTable *poStyleTable)
00104                             {
00105                                 if ( m_poStyleTable ) delete m_poStyleTable;
00106                                 if ( poStyleTable )
00107                                     m_poStyleTable = poStyleTable->Clone();
00108                             }
00109 
00110     virtual OGRErr      StartTransaction();
00111     virtual OGRErr      CommitTransaction();
00112     virtual OGRErr      RollbackTransaction();
00113 
00114     virtual const char *GetFIDColumn();
00115     virtual const char *GetGeometryColumn();
00116 
00117     int                 Reference();
00118     int                 Dereference();
00119     int                 GetRefCount() const;
00120 
00121     GIntBig             GetFeaturesRead();
00122     
00123     /* consider these private */
00124     OGRErr               InitializeIndexSupport( const char * );
00125     OGRLayerAttrIndex   *GetIndex() { return m_poAttrIndex; }
00126 
00127  protected:
00128     OGRStyleTable       *m_poStyleTable;
00129     OGRFeatureQuery     *m_poAttrQuery;
00130     OGRLayerAttrIndex   *m_poAttrIndex;
00131 
00132     int                  m_nRefCount;
00133 
00134     GIntBig              m_nFeaturesRead;
00135 };
00136 
00137 
00138 /************************************************************************/
00139 /*                            OGRDataSource                             */
00140 /************************************************************************/
00141 
00152 class CPL_DLL OGRDataSource
00153 {
00154     friend class OGRSFDriverRegistrar;
00155 
00156   public:
00157 
00158     OGRDataSource();
00159     virtual     ~OGRDataSource();
00160     static void         DestroyDataSource( OGRDataSource * );
00161 
00162     virtual const char  *GetName() = 0;
00163 
00164     virtual int         GetLayerCount() = 0;
00165     virtual OGRLayer    *GetLayer(int) = 0;
00166     virtual OGRLayer    *GetLayerByName(const char *);
00167     virtual OGRErr      DeleteLayer(int);
00168 
00169     virtual int         TestCapability( const char * ) = 0;
00170 
00171     virtual OGRLayer   *CreateLayer( const char *pszName, 
00172                                      OGRSpatialReference *poSpatialRef = NULL,
00173                                      OGRwkbGeometryType eGType = wkbUnknown,
00174                                      char ** papszOptions = NULL );
00175     virtual OGRLayer   *CopyLayer( OGRLayer *poSrcLayer, 
00176                                    const char *pszNewName, 
00177                                    char **papszOptions = NULL );
00178 
00179     OGRStyleTable       *GetStyleTable(){ return m_poStyleTable; }
00180     void                SetStyleTableDirectly( OGRStyleTable *poStyleTable )
00181                             { if ( m_poStyleTable ) delete m_poStyleTable;
00182                               m_poStyleTable = poStyleTable; }
00183     void                SetStyleTable(OGRStyleTable *poStyleTable)
00184                             {
00185                                 if ( m_poStyleTable ) delete m_poStyleTable;
00186                                 if ( poStyleTable )
00187                                     m_poStyleTable = poStyleTable->Clone();
00188                             }
00189 
00190     virtual OGRLayer *  ExecuteSQL( const char *pszStatement,
00191                                     OGRGeometry *poSpatialFilter,
00192                                     const char *pszDialect );
00193     virtual void        ReleaseResultSet( OGRLayer * poResultsSet );
00194 
00195     virtual OGRErr      SyncToDisk();
00196 
00197     int                 Reference();
00198     int                 Dereference();
00199     int                 GetRefCount() const;
00200     int                 GetSummaryRefCount() const;
00201     OGRErr              Release();
00202 
00203     OGRSFDriver        *GetDriver() const;
00204 
00205   protected:
00206 
00207     OGRErr              ProcessSQLCreateIndex( const char * );
00208     OGRErr              ProcessSQLDropIndex( const char * );
00209 
00210     OGRStyleTable      *m_poStyleTable;
00211     int                 m_nRefCount;
00212     OGRSFDriver        *m_poDriver;
00213 };
00214 
00215 /************************************************************************/
00216 /*                             OGRSFDriver                              */
00217 /************************************************************************/
00218 
00228 class CPL_DLL OGRSFDriver
00229 {
00230   public:
00231     virtual     ~OGRSFDriver();
00232 
00233     virtual const char  *GetName() = 0;
00234 
00235     virtual OGRDataSource *Open( const char *pszName, int bUpdate=FALSE ) = 0;
00236 
00237     virtual int         TestCapability( const char * ) = 0;
00238 
00239     virtual OGRDataSource *CreateDataSource( const char *pszName,
00240                                              char ** = NULL );
00241     virtual OGRErr      DeleteDataSource( const char *pszName );
00242 
00243     virtual OGRDataSource *CopyDataSource( OGRDataSource *poSrcDS, 
00244                                            const char *pszNewName, 
00245                                            char **papszOptions = NULL );
00246 };
00247 
00248 
00249 /************************************************************************/
00250 /*                         OGRSFDriverRegistrar                         */
00251 /************************************************************************/
00252 
00258 class CPL_DLL OGRSFDriverRegistrar
00259 {
00260     int         nDrivers;
00261     OGRSFDriver **papoDrivers;
00262 
00263                 OGRSFDriverRegistrar();
00264 
00265     int         nOpenDSCount;
00266     char        **papszOpenDSRawName;
00267     OGRDataSource **papoOpenDS;
00268     OGRSFDriver **papoOpenDSDriver;
00269 
00270   public:
00271 
00272                 ~OGRSFDriverRegistrar();
00273 
00274     static OGRSFDriverRegistrar *GetRegistrar();
00275     static OGRDataSource *Open( const char *pszName, int bUpdate=FALSE,
00276                                 OGRSFDriver ** ppoDriver = NULL );
00277 
00278     OGRDataSource *OpenShared( const char *pszName, int bUpdate=FALSE,
00279                                OGRSFDriver ** ppoDriver = NULL );
00280     OGRErr      ReleaseDataSource( OGRDataSource * );
00281 
00282     void        RegisterDriver( OGRSFDriver * poDriver );
00283 
00284     int         GetDriverCount( void );
00285     OGRSFDriver *GetDriver( int iDriver );
00286     OGRSFDriver *GetDriverByName( const char * );
00287 
00288     int         GetOpenDSCount() { return nOpenDSCount; } 
00289     OGRDataSource *GetOpenDS( int );
00290 
00291     void        AutoLoadDrivers();
00292 };
00293 
00294 /* -------------------------------------------------------------------- */
00295 /*      Various available registration methods.                         */
00296 /* -------------------------------------------------------------------- */
00297 CPL_C_START
00298 void CPL_DLL OGRRegisterAll();
00299 
00300 void CPL_DLL RegisterOGRShape();
00301 void CPL_DLL RegisterOGRNTF();
00302 void CPL_DLL RegisterOGRFME();
00303 void CPL_DLL RegisterOGRSDTS();
00304 void CPL_DLL RegisterOGRTiger();
00305 void CPL_DLL RegisterOGRS57();
00306 void CPL_DLL RegisterOGRTAB();
00307 void CPL_DLL RegisterOGRMIF();
00308 void CPL_DLL RegisterOGROGDI();
00309 void CPL_DLL RegisterOGRODBC();
00310 void CPL_DLL RegisterOGRPG();
00311 void CPL_DLL RegisterOGRMySQL();
00312 void CPL_DLL RegisterOGROCI();
00313 void CPL_DLL RegisterOGRGML();
00314 void CPL_DLL RegisterOGRKML();
00315 void CPL_DLL RegisterOGRAVCBin();
00316 void CPL_DLL RegisterOGRAVCE00();
00317 void CPL_DLL RegisterOGRREC();
00318 void CPL_DLL RegisterOGRMEM();
00319 void CPL_DLL RegisterOGRVRT();
00320 void CPL_DLL RegisterOGRDODS();
00321 void CPL_DLL RegisterOGRSQLite();
00322 void CPL_DLL RegisterOGRCSV();
00323 void CPL_DLL RegisterOGRGRASS();
00324 void CPL_DLL RegisterOGRPGeo();
00325 void CPL_DLL RegisterOGRDXFDWG();
00326 void CPL_DLL RegisterOGRSDE();
00327 void CPL_DLL RegisterOGRIDB();
00328 
00329 CPL_C_END
00330 
00331 
00332 #endif /* ndef _OGRSF_FRMTS_H_INCLUDED */

Generated for GDAL by doxygen 1.5.1.