1 : /******************************************************************************
2 : * $Id: ogr_mem.h 25311 2012-12-15 12:48:14Z 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 : int bUpdatable;
52 : int bAdvertizeUTF8;
53 :
54 : int bHasHoles;
55 :
56 : public:
57 : OGRMemLayer( const char * pszName,
58 : OGRSpatialReference *poSRS,
59 : OGRwkbGeometryType eGeomType );
60 : ~OGRMemLayer();
61 :
62 : void ResetReading();
63 : OGRFeature * GetNextFeature();
64 : virtual OGRErr SetNextByIndex( long nIndex );
65 :
66 : OGRFeature *GetFeature( long nFeatureId );
67 : OGRErr SetFeature( OGRFeature *poFeature );
68 : OGRErr CreateFeature( OGRFeature *poFeature );
69 : virtual OGRErr DeleteFeature( long nFID );
70 :
71 0 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
72 :
73 : int GetFeatureCount( int );
74 :
75 : virtual OGRErr CreateField( OGRFieldDefn *poField,
76 : int bApproxOK = TRUE );
77 : virtual OGRErr DeleteField( int iField );
78 : virtual OGRErr ReorderFields( int* panMap );
79 : virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
80 :
81 : virtual OGRSpatialReference *GetSpatialRef();
82 :
83 : int TestCapability( const char * );
84 :
85 : void SetUpdatable(int bUpdatableIn) { bUpdatable = bUpdatableIn; }
86 : void SetAdvertizeUTF8(int bAdvertizeUTF8In) { bAdvertizeUTF8 = bAdvertizeUTF8In; }
87 :
88 : int GetNextReadFID() { return iNextReadFID; }
89 : };
90 :
91 : /************************************************************************/
92 : /* OGRMemDataSource */
93 : /************************************************************************/
94 :
95 : class OGRMemDataSource : public OGRDataSource
96 : {
97 : OGRMemLayer **papoLayers;
98 : int nLayers;
99 :
100 : char *pszName;
101 :
102 : public:
103 : OGRMemDataSource( const char *, char ** );
104 : ~OGRMemDataSource();
105 :
106 43 : const char *GetName() { return pszName; }
107 841 : int GetLayerCount() { return nLayers; }
108 : OGRLayer *GetLayer( int );
109 :
110 : virtual OGRLayer *CreateLayer( const char *,
111 : OGRSpatialReference * = NULL,
112 : OGRwkbGeometryType = wkbUnknown,
113 : char ** = NULL );
114 : OGRErr DeleteLayer( int iLayer );
115 :
116 : int TestCapability( const char * );
117 : };
118 :
119 : /************************************************************************/
120 : /* OGRMemDriver */
121 : /************************************************************************/
122 :
123 : class OGRMemDriver : public OGRSFDriver
124 226 : {
125 : public:
126 : ~OGRMemDriver();
127 :
128 : const char *GetName();
129 : OGRDataSource *Open( const char *, int );
130 :
131 : virtual OGRDataSource *CreateDataSource( const char *pszName,
132 : char ** = NULL );
133 :
134 : int TestCapability( const char * );
135 : };
136 :
137 :
138 : #endif /* ndef _OGRMEM_H_INCLUDED */
|