1 /******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: Implements OGRMutexedLayer class
5 * Author: Even Rouault, even dot rouault at spatialys.com
6 *
7 ******************************************************************************
8 * Copyright (c) 2013, Even Rouault <even dot rouault at spatialys.com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ****************************************************************************/
28
29 #ifndef DOXYGEN_SKIP
30
31 #include "ogrmutexedlayer.h"
32 #include "cpl_multiproc.h"
33
34 CPL_CVSID("$Id: ogrmutexedlayer.cpp 355b41831cd2685c85d1aabe5b95665a2c6e99b7 2019-06-19 17:07:04 +0200 Even Rouault $")
35
OGRMutexedLayer(OGRLayer * poDecoratedLayer,int bTakeOwnership,CPLMutex * hMutex)36 OGRMutexedLayer::OGRMutexedLayer( OGRLayer* poDecoratedLayer,
37 int bTakeOwnership,
38 CPLMutex* hMutex ) :
39 OGRLayerDecorator(poDecoratedLayer, bTakeOwnership), m_hMutex(hMutex)
40 {
41 SetDescription( poDecoratedLayer->GetDescription() );
42 }
43
~OGRMutexedLayer()44 OGRMutexedLayer::~OGRMutexedLayer() {}
45
GetSpatialFilter()46 OGRGeometry *OGRMutexedLayer::GetSpatialFilter()
47 {
48 CPLMutexHolderOptionalLockD(m_hMutex);
49 return OGRLayerDecorator::GetSpatialFilter();
50 }
51
SetSpatialFilter(OGRGeometry * poGeom)52 void OGRMutexedLayer::SetSpatialFilter( OGRGeometry * poGeom )
53 {
54 CPLMutexHolderOptionalLockD(m_hMutex);
55 OGRLayerDecorator::SetSpatialFilter(poGeom);
56 }
57
SetSpatialFilterRect(double dfMinX,double dfMinY,double dfMaxX,double dfMaxY)58 void OGRMutexedLayer::SetSpatialFilterRect( double dfMinX, double dfMinY,
59 double dfMaxX, double dfMaxY )
60 {
61 CPLMutexHolderOptionalLockD(m_hMutex);
62 OGRLayerDecorator::SetSpatialFilterRect(dfMinX, dfMinY, dfMaxX, dfMaxY);
63 }
64
SetSpatialFilter(int iGeomField,OGRGeometry * poGeom)65 void OGRMutexedLayer::SetSpatialFilter( int iGeomField, OGRGeometry * poGeom )
66 {
67 CPLMutexHolderOptionalLockD(m_hMutex);
68 OGRLayerDecorator::SetSpatialFilter(iGeomField, poGeom);
69 }
70
SetSpatialFilterRect(int iGeomField,double dfMinX,double dfMinY,double dfMaxX,double dfMaxY)71 void OGRMutexedLayer::SetSpatialFilterRect( int iGeomField, double dfMinX, double dfMinY,
72 double dfMaxX, double dfMaxY )
73 {
74 CPLMutexHolderOptionalLockD(m_hMutex);
75 OGRLayerDecorator::SetSpatialFilterRect(iGeomField, dfMinX, dfMinY, dfMaxX, dfMaxY);
76 }
77
SetAttributeFilter(const char * poAttrFilter)78 OGRErr OGRMutexedLayer::SetAttributeFilter( const char * poAttrFilter )
79 {
80 CPLMutexHolderOptionalLockD(m_hMutex);
81 return OGRLayerDecorator::SetAttributeFilter(poAttrFilter);
82 }
83
ResetReading()84 void OGRMutexedLayer::ResetReading()
85 {
86 CPLMutexHolderOptionalLockD(m_hMutex);
87 OGRLayerDecorator::ResetReading();
88 }
89
GetNextFeature()90 OGRFeature *OGRMutexedLayer::GetNextFeature()
91 {
92 CPLMutexHolderOptionalLockD(m_hMutex);
93 return OGRLayerDecorator::GetNextFeature();
94 }
95
SetNextByIndex(GIntBig nIndex)96 OGRErr OGRMutexedLayer::SetNextByIndex( GIntBig nIndex )
97 {
98 CPLMutexHolderOptionalLockD(m_hMutex);
99 return OGRLayerDecorator::SetNextByIndex(nIndex);
100 }
101
GetFeature(GIntBig nFID)102 OGRFeature *OGRMutexedLayer::GetFeature( GIntBig nFID )
103 {
104 CPLMutexHolderOptionalLockD(m_hMutex);
105 return OGRLayerDecorator::GetFeature(nFID);
106 }
107
ISetFeature(OGRFeature * poFeature)108 OGRErr OGRMutexedLayer::ISetFeature( OGRFeature *poFeature )
109 {
110 CPLMutexHolderOptionalLockD(m_hMutex);
111 return OGRLayerDecorator::ISetFeature(poFeature);
112 }
113
ICreateFeature(OGRFeature * poFeature)114 OGRErr OGRMutexedLayer::ICreateFeature( OGRFeature *poFeature )
115 {
116 CPLMutexHolderOptionalLockD(m_hMutex);
117 return OGRLayerDecorator::ICreateFeature(poFeature);
118 }
119
DeleteFeature(GIntBig nFID)120 OGRErr OGRMutexedLayer::DeleteFeature( GIntBig nFID )
121 {
122 CPLMutexHolderOptionalLockD(m_hMutex);
123 return OGRLayerDecorator::DeleteFeature(nFID);
124 }
125
GetName()126 const char *OGRMutexedLayer::GetName()
127 {
128 CPLMutexHolderOptionalLockD(m_hMutex);
129 return OGRLayerDecorator::GetName();
130 }
131
GetGeomType()132 OGRwkbGeometryType OGRMutexedLayer::GetGeomType()
133 {
134 CPLMutexHolderOptionalLockD(m_hMutex);
135 return OGRLayerDecorator::GetGeomType();
136 }
137
GetLayerDefn()138 OGRFeatureDefn *OGRMutexedLayer::GetLayerDefn()
139 {
140 CPLMutexHolderOptionalLockD(m_hMutex);
141 return OGRLayerDecorator::GetLayerDefn();
142 }
143
GetSpatialRef()144 OGRSpatialReference *OGRMutexedLayer::GetSpatialRef()
145 {
146 CPLMutexHolderOptionalLockD(m_hMutex);
147 return OGRLayerDecorator::GetSpatialRef();
148 }
149
GetFeatureCount(int bForce)150 GIntBig OGRMutexedLayer::GetFeatureCount( int bForce )
151 {
152 CPLMutexHolderOptionalLockD(m_hMutex);
153 return OGRLayerDecorator::GetFeatureCount(bForce);
154 }
155
GetExtent(int iGeomField,OGREnvelope * psExtent,int bForce)156 OGRErr OGRMutexedLayer::GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce)
157 {
158 CPLMutexHolderOptionalLockD(m_hMutex);
159 return OGRLayerDecorator::GetExtent(iGeomField, psExtent, bForce);
160 }
161
GetExtent(OGREnvelope * psExtent,int bForce)162 OGRErr OGRMutexedLayer::GetExtent(OGREnvelope *psExtent, int bForce)
163 {
164 CPLMutexHolderOptionalLockD(m_hMutex);
165 return OGRLayerDecorator::GetExtent(psExtent, bForce);
166 }
167
TestCapability(const char * pszCapability)168 int OGRMutexedLayer::TestCapability( const char * pszCapability )
169 {
170 CPLMutexHolderOptionalLockD(m_hMutex);
171 return OGRLayerDecorator::TestCapability(pszCapability);
172 }
173
CreateField(OGRFieldDefn * poField,int bApproxOK)174 OGRErr OGRMutexedLayer::CreateField( OGRFieldDefn *poField,
175 int bApproxOK )
176 {
177 CPLMutexHolderOptionalLockD(m_hMutex);
178 return OGRLayerDecorator::CreateField(poField, bApproxOK);
179 }
180
DeleteField(int iField)181 OGRErr OGRMutexedLayer::DeleteField( int iField )
182 {
183 CPLMutexHolderOptionalLockD(m_hMutex);
184 return OGRLayerDecorator::DeleteField(iField);
185 }
186
ReorderFields(int * panMap)187 OGRErr OGRMutexedLayer::ReorderFields( int* panMap )
188 {
189 CPLMutexHolderOptionalLockD(m_hMutex);
190 return OGRLayerDecorator::ReorderFields(panMap);
191 }
192
AlterFieldDefn(int iField,OGRFieldDefn * poNewFieldDefn,int nFlagsIn)193 OGRErr OGRMutexedLayer::AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlagsIn )
194 {
195 CPLMutexHolderOptionalLockD(m_hMutex);
196 return OGRLayerDecorator::AlterFieldDefn(iField, poNewFieldDefn, nFlagsIn);
197 }
198
SyncToDisk()199 OGRErr OGRMutexedLayer::SyncToDisk()
200 {
201 CPLMutexHolderOptionalLockD(m_hMutex);
202 return OGRLayerDecorator::SyncToDisk();
203 }
204
GetStyleTable()205 OGRStyleTable *OGRMutexedLayer::GetStyleTable()
206 {
207 CPLMutexHolderOptionalLockD(m_hMutex);
208 return OGRLayerDecorator::GetStyleTable();
209 }
210
SetStyleTableDirectly(OGRStyleTable * poStyleTable)211 void OGRMutexedLayer::SetStyleTableDirectly( OGRStyleTable *poStyleTable )
212 {
213 CPLMutexHolderOptionalLockD(m_hMutex);
214 return OGRLayerDecorator::SetStyleTableDirectly(poStyleTable);
215 }
216
SetStyleTable(OGRStyleTable * poStyleTable)217 void OGRMutexedLayer::SetStyleTable(OGRStyleTable *poStyleTable)
218 {
219 CPLMutexHolderOptionalLockD(m_hMutex);
220 return OGRLayerDecorator::SetStyleTable(poStyleTable);
221 }
222
StartTransaction()223 OGRErr OGRMutexedLayer::StartTransaction()
224 {
225 CPLMutexHolderOptionalLockD(m_hMutex);
226 return OGRLayerDecorator::StartTransaction();
227 }
228
CommitTransaction()229 OGRErr OGRMutexedLayer::CommitTransaction()
230 {
231 CPLMutexHolderOptionalLockD(m_hMutex);
232 return OGRLayerDecorator::CommitTransaction();
233 }
234
RollbackTransaction()235 OGRErr OGRMutexedLayer::RollbackTransaction()
236 {
237 CPLMutexHolderOptionalLockD(m_hMutex);
238 return OGRLayerDecorator::RollbackTransaction();
239 }
240
GetFIDColumn()241 const char *OGRMutexedLayer::GetFIDColumn()
242 {
243 CPLMutexHolderOptionalLockD(m_hMutex);
244 return OGRLayerDecorator::GetFIDColumn();
245 }
246
GetGeometryColumn()247 const char *OGRMutexedLayer::GetGeometryColumn()
248 {
249 CPLMutexHolderOptionalLockD(m_hMutex);
250 return OGRLayerDecorator::GetGeometryColumn();
251 }
252
SetIgnoredFields(const char ** papszFields)253 OGRErr OGRMutexedLayer::SetIgnoredFields( const char **papszFields )
254 {
255 CPLMutexHolderOptionalLockD(m_hMutex);
256 return OGRLayerDecorator::SetIgnoredFields(papszFields);
257 }
258
GetMetadata(const char * pszDomain)259 char **OGRMutexedLayer::GetMetadata( const char * pszDomain )
260 {
261 CPLMutexHolderOptionalLockD(m_hMutex);
262 return OGRLayerDecorator::GetMetadata(pszDomain);
263 }
264
SetMetadata(char ** papszMetadata,const char * pszDomain)265 CPLErr OGRMutexedLayer::SetMetadata( char ** papszMetadata,
266 const char * pszDomain )
267 {
268 CPLMutexHolderOptionalLockD(m_hMutex);
269 return OGRLayerDecorator::SetMetadata(papszMetadata, pszDomain);
270 }
271
GetMetadataItem(const char * pszName,const char * pszDomain)272 const char *OGRMutexedLayer::GetMetadataItem( const char * pszName,
273 const char * pszDomain )
274 {
275 CPLMutexHolderOptionalLockD(m_hMutex);
276 return OGRLayerDecorator::GetMetadataItem(pszName, pszDomain);
277 }
278
SetMetadataItem(const char * pszName,const char * pszValue,const char * pszDomain)279 CPLErr OGRMutexedLayer::SetMetadataItem( const char * pszName,
280 const char * pszValue,
281 const char * pszDomain )
282 {
283 CPLMutexHolderOptionalLockD(m_hMutex);
284 return OGRLayerDecorator::SetMetadataItem(pszName, pszValue, pszDomain);
285 }
286
287 #if defined(WIN32) && defined(_MSC_VER)
288 // Horrible hack: for some reason MSVC doesn't export the class
289 // if it is not referenced from the DLL itself
290 void OGRRegisterMutexedLayer();
OGRRegisterMutexedLayer()291 void OGRRegisterMutexedLayer()
292 {
293 CPLAssert(false); // Never call this function: it will segfault
294 delete new OGRMutexedLayer(NULL, FALSE, NULL);
295 }
296 #endif
297
298 #endif /* #ifndef DOXYGEN_SKIP */
299