1 : /******************************************************************************
2 : * $Id: ogr_mem.h 17807 2009-10-13 18:18:09Z 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 284 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
69 :
70 : int GetFeatureCount( int );
71 :
72 : virtual OGRErr CreateField( OGRFieldDefn *poField,
73 : int bApproxOK = TRUE );
74 :
75 : virtual OGRSpatialReference *GetSpatialRef();
76 :
77 : int TestCapability( const char * );
78 : };
79 :
80 : /************************************************************************/
81 : /* OGRMemDataSource */
82 : /************************************************************************/
83 :
84 : class OGRMemDataSource : public OGRDataSource
85 : {
86 : OGRMemLayer **papoLayers;
87 : int nLayers;
88 :
89 : char *pszName;
90 :
91 : public:
92 : OGRMemDataSource( const char *, char ** );
93 : ~OGRMemDataSource();
94 :
95 12 : const char *GetName() { return pszName; }
96 22 : int GetLayerCount() { return nLayers; }
97 : OGRLayer *GetLayer( int );
98 :
99 : virtual OGRLayer *CreateLayer( const char *,
100 : OGRSpatialReference * = NULL,
101 : OGRwkbGeometryType = wkbUnknown,
102 : char ** = NULL );
103 : OGRErr DeleteLayer( int iLayer );
104 :
105 : int TestCapability( const char * );
106 : };
107 :
108 : /************************************************************************/
109 : /* OGRMemDriver */
110 : /************************************************************************/
111 :
112 : class OGRMemDriver : public OGRSFDriver
113 64 : {
114 : public:
115 : ~OGRMemDriver();
116 :
117 : const char *GetName();
118 : OGRDataSource *Open( const char *, int );
119 :
120 : virtual OGRDataSource *CreateDataSource( const char *pszName,
121 : char ** = NULL );
122 :
123 : int TestCapability( const char * );
124 : };
125 :
126 :
127 : #endif /* ndef _OGRMEM_H_INCLUDED */
|