1 : /******************************************************************************
2 : * $Id: ogr_mem.h 22369 2011-05-13 18:00:27Z rouault $
3 : *
4 : * Project: OpenGIS Simple Features Reference Implementation
5 : * Purpose: Private definitions within the OGR Memory driver.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2003, Frank Warmerdam <warmerdam@pobox.com>
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 _OGRMEM_H_INCLUDED
31 : #define _OGRMEM_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 :
35 : /************************************************************************/
36 : /* OGRMemLayer */
37 : /************************************************************************/
38 :
39 : class OGRMemLayer : public OGRLayer
40 : {
41 : OGRSpatialReference *poSRS;
42 : OGRFeatureDefn *poFeatureDefn;
43 :
44 : int nFeatureCount;
45 : int nMaxFeatureCount;
46 : OGRFeature **papoFeatures;
47 :
48 : int iNextReadFID;
49 : int iNextCreateFID;
50 :
51 : OGRwkbGeometryType eWkbType;
52 :
53 : public:
54 : OGRMemLayer( const char * pszName,
55 : OGRSpatialReference *poSRS,
56 : OGRwkbGeometryType eGeomType );
57 : ~OGRMemLayer();
58 :
59 : void ResetReading();
60 : OGRFeature * GetNextFeature();
61 : virtual OGRErr SetNextByIndex( long nIndex );
62 :
63 : OGRFeature *GetFeature( long nFeatureId );
64 : OGRErr SetFeature( OGRFeature *poFeature );
65 : OGRErr CreateFeature( OGRFeature *poFeature );
66 : virtual OGRErr DeleteFeature( long nFID );
67 :
68 1121 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
69 :
70 : int GetFeatureCount( int );
71 :
72 : virtual OGRErr CreateField( OGRFieldDefn *poField,
73 : int bApproxOK = TRUE );
74 : virtual OGRErr DeleteField( int iField );
75 : virtual OGRErr ReorderFields( int* panMap );
76 : virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
77 :
78 : virtual OGRSpatialReference *GetSpatialRef();
79 :
80 : int TestCapability( const char * );
81 : };
82 :
83 : /************************************************************************/
84 : /* OGRMemDataSource */
85 : /************************************************************************/
86 :
87 : class OGRMemDataSource : public OGRDataSource
88 : {
89 : OGRMemLayer **papoLayers;
90 : int nLayers;
91 :
92 : char *pszName;
93 :
94 : public:
95 : OGRMemDataSource( const char *, char ** );
96 : ~OGRMemDataSource();
97 :
98 30 : const char *GetName() { return pszName; }
99 169 : int GetLayerCount() { return nLayers; }
100 : OGRLayer *GetLayer( int );
101 :
102 : virtual OGRLayer *CreateLayer( const char *,
103 : OGRSpatialReference * = NULL,
104 : OGRwkbGeometryType = wkbUnknown,
105 : char ** = NULL );
106 : OGRErr DeleteLayer( int iLayer );
107 :
108 : int TestCapability( const char * );
109 : };
110 :
111 : /************************************************************************/
112 : /* OGRMemDriver */
113 : /************************************************************************/
114 :
115 : class OGRMemDriver : public OGRSFDriver
116 178 : {
117 : public:
118 : ~OGRMemDriver();
119 :
120 : const char *GetName();
121 : OGRDataSource *Open( const char *, int );
122 :
123 : virtual OGRDataSource *CreateDataSource( const char *pszName,
124 : char ** = NULL );
125 :
126 : int TestCapability( const char * );
127 : };
128 :
129 :
130 : #endif /* ndef _OGRMEM_H_INCLUDED */
|