Line data Source code
1 : /******************************************************************************
2 : *
3 : * Project: OpenGIS Simple Features Reference Implementation
4 : * Purpose: Defines OGRLayerPool and OGRProxiedLayer class
5 : * Author: Even Rouault, even dot rouault at spatialys.com
6 : *
7 : ******************************************************************************
8 : * Copyright (c) 2012-2013, Even Rouault <even dot rouault at spatialys.com>
9 : *
10 : * SPDX-License-Identifier: MIT
11 : ****************************************************************************/
12 :
13 : #ifndef DOXYGEN_SKIP
14 :
15 : #include "ogrlayerpool.h"
16 : #include "ogr_recordbatch.h"
17 :
18 : /************************************************************************/
19 : /* OGRAbstractProxiedLayer() */
20 : /************************************************************************/
21 :
22 7787 : OGRAbstractProxiedLayer::OGRAbstractProxiedLayer(OGRLayerPool *poPoolIn)
23 7787 : : poPrevLayer(nullptr), poNextLayer(nullptr), poPool(poPoolIn)
24 : {
25 7787 : CPLAssert(poPoolIn != nullptr);
26 7787 : }
27 :
28 : /************************************************************************/
29 : /* ~OGRAbstractProxiedLayer() */
30 : /************************************************************************/
31 :
32 7780 : OGRAbstractProxiedLayer::~OGRAbstractProxiedLayer()
33 : {
34 : /* Remove us from the list of LRU layers if necessary */
35 7780 : poPool->UnchainLayer(this);
36 7780 : }
37 :
38 : /************************************************************************/
39 : /* OGRLayerPool() */
40 : /************************************************************************/
41 :
42 4031 : OGRLayerPool::OGRLayerPool(int nMaxSimultaneouslyOpenedIn)
43 : : poMRULayer(nullptr), poLRULayer(nullptr), nMRUListSize(0),
44 4031 : nMaxSimultaneouslyOpened(nMaxSimultaneouslyOpenedIn)
45 : {
46 4031 : }
47 :
48 : /************************************************************************/
49 : /* ~OGRLayerPool() */
50 : /************************************************************************/
51 :
52 8048 : OGRLayerPool::~OGRLayerPool()
53 : {
54 4024 : CPLAssert(poMRULayer == nullptr);
55 4024 : CPLAssert(poLRULayer == nullptr);
56 4024 : CPLAssert(nMRUListSize == 0);
57 4024 : }
58 :
59 : /************************************************************************/
60 : /* SetLastUsedLayer() */
61 : /************************************************************************/
62 :
63 15451 : void OGRLayerPool::SetLastUsedLayer(OGRAbstractProxiedLayer *poLayer)
64 : {
65 : /* If we are already the MRU layer, nothing to do */
66 15451 : if (poLayer == poMRULayer)
67 8777 : return;
68 :
69 : // CPLDebug("OGR", "SetLastUsedLayer(%s)", poLayer->GetName());
70 :
71 6674 : if (poLayer->poPrevLayer != nullptr || poLayer->poNextLayer != nullptr)
72 : {
73 : /* Remove current layer from its current place in the list */
74 13 : UnchainLayer(poLayer);
75 : }
76 6661 : else if (nMRUListSize == nMaxSimultaneouslyOpened)
77 : {
78 : /* If we have reached the maximum allowed number of layers */
79 : /* simultaneously opened, then close the LRU one that */
80 : /* was still active until now */
81 5926 : CPLAssert(poLRULayer != nullptr);
82 :
83 5926 : poLRULayer->CloseUnderlyingLayer();
84 5926 : UnchainLayer(poLRULayer);
85 : }
86 :
87 : /* Put current layer on top of MRU list */
88 6674 : CPLAssert(poLayer->poPrevLayer == nullptr);
89 6674 : CPLAssert(poLayer->poNextLayer == nullptr);
90 6674 : poLayer->poNextLayer = poMRULayer;
91 6674 : if (poMRULayer != nullptr)
92 : {
93 6515 : CPLAssert(poMRULayer->poPrevLayer == nullptr);
94 6515 : poMRULayer->poPrevLayer = poLayer;
95 : }
96 6674 : poMRULayer = poLayer;
97 6674 : if (poLRULayer == nullptr)
98 159 : poLRULayer = poLayer;
99 6674 : nMRUListSize++;
100 : }
101 :
102 : /************************************************************************/
103 : /* UnchainLayer() */
104 : /************************************************************************/
105 :
106 13719 : void OGRLayerPool::UnchainLayer(OGRAbstractProxiedLayer *poLayer)
107 : {
108 13719 : OGRAbstractProxiedLayer *poPrevLayer = poLayer->poPrevLayer;
109 13719 : OGRAbstractProxiedLayer *poNextLayer = poLayer->poNextLayer;
110 :
111 13719 : CPLAssert(poPrevLayer == nullptr || poPrevLayer->poNextLayer == poLayer);
112 13719 : CPLAssert(poNextLayer == nullptr || poNextLayer->poPrevLayer == poLayer);
113 :
114 13719 : if (poPrevLayer != nullptr || poNextLayer != nullptr ||
115 7204 : poLayer == poMRULayer)
116 6674 : nMRUListSize--;
117 :
118 13719 : if (poLayer == poMRULayer)
119 159 : poMRULayer = poNextLayer;
120 13719 : if (poLayer == poLRULayer)
121 6667 : poLRULayer = poPrevLayer;
122 13719 : if (poPrevLayer != nullptr)
123 6515 : poPrevLayer->poNextLayer = poNextLayer;
124 13719 : if (poNextLayer != nullptr)
125 7 : poNextLayer->poPrevLayer = poPrevLayer;
126 13719 : poLayer->poPrevLayer = nullptr;
127 13719 : poLayer->poNextLayer = nullptr;
128 13719 : }
129 :
130 : /************************************************************************/
131 : /* OGRProxiedLayer() */
132 : /************************************************************************/
133 :
134 114 : static void ReleaseDelete(OGRLayer *poLayer, void *)
135 : {
136 114 : delete poLayer;
137 114 : }
138 :
139 4 : OGRProxiedLayer::OGRProxiedLayer(OGRLayerPool *poPoolIn,
140 : OpenLayerFunc pfnOpenLayerIn,
141 : FreeUserDataFunc pfnFreeUserDataIn,
142 4 : void *pUserDataIn)
143 : : OGRAbstractProxiedLayer(poPoolIn), pfnOpenLayer(pfnOpenLayerIn),
144 : pfnReleaseLayer(ReleaseDelete), pfnFreeUserData(pfnFreeUserDataIn),
145 : pUserData(pUserDataIn), poUnderlyingLayer(nullptr),
146 4 : poFeatureDefn(nullptr), poSRS(nullptr)
147 : {
148 4 : CPLAssert(pfnOpenLayerIn != nullptr);
149 4 : }
150 :
151 : /************************************************************************/
152 : /* OGRProxiedLayer() */
153 : /************************************************************************/
154 :
155 6 : OGRProxiedLayer::OGRProxiedLayer(OGRLayerPool *poPoolIn,
156 : OpenLayerFunc pfnOpenLayerIn,
157 : ReleaseLayerFunc pfnReleaseLayerIn,
158 : FreeUserDataFunc pfnFreeUserDataIn,
159 6 : void *pUserDataIn)
160 : : OGRAbstractProxiedLayer(poPoolIn), pfnOpenLayer(pfnOpenLayerIn),
161 : pfnReleaseLayer(pfnReleaseLayerIn), pfnFreeUserData(pfnFreeUserDataIn),
162 : pUserData(pUserDataIn), poUnderlyingLayer(nullptr),
163 6 : poFeatureDefn(nullptr), poSRS(nullptr)
164 : {
165 6 : CPLAssert(pfnOpenLayerIn != nullptr);
166 6 : }
167 :
168 : /************************************************************************/
169 : /* ~OGRProxiedLayer() */
170 : /************************************************************************/
171 :
172 16 : OGRProxiedLayer::~OGRProxiedLayer()
173 : {
174 10 : OGRProxiedLayer::CloseUnderlyingLayer();
175 :
176 10 : if (poSRS)
177 6 : poSRS->Release();
178 :
179 10 : if (poFeatureDefn)
180 8 : poFeatureDefn->Release();
181 :
182 10 : if (pfnFreeUserData != nullptr)
183 10 : pfnFreeUserData(pUserData);
184 16 : }
185 :
186 : /************************************************************************/
187 : /* OpenUnderlyingLayer() */
188 : /************************************************************************/
189 :
190 126 : int OGRProxiedLayer::OpenUnderlyingLayer() const
191 : {
192 126 : std::lock_guard oLock(m_oMutex);
193 126 : if (poUnderlyingLayer == nullptr)
194 : {
195 126 : CPLDebug("OGR", "OpenUnderlyingLayer(%p)", this);
196 126 : poPool->SetLastUsedLayer(const_cast<OGRProxiedLayer *>(this));
197 126 : poUnderlyingLayer = pfnOpenLayer(pUserData);
198 126 : if (poUnderlyingLayer == nullptr)
199 : {
200 0 : CPLError(CE_Failure, CPLE_FileIO, "Cannot open underlying layer");
201 : }
202 : }
203 252 : return poUnderlyingLayer != nullptr;
204 : }
205 :
206 : /************************************************************************/
207 : /* CloseUnderlyingLayer() */
208 : /************************************************************************/
209 :
210 132 : void OGRProxiedLayer::CloseUnderlyingLayer()
211 : {
212 132 : CPLDebug("OGR", "CloseUnderlyingLayer(%p)", this);
213 132 : if (poUnderlyingLayer)
214 : {
215 126 : pfnReleaseLayer(poUnderlyingLayer, pUserData);
216 : }
217 132 : poUnderlyingLayer = nullptr;
218 132 : }
219 :
220 : /************************************************************************/
221 : /* GetUnderlyingLayer() */
222 : /************************************************************************/
223 :
224 0 : OGRLayer *OGRProxiedLayer::GetUnderlyingLayer()
225 : {
226 0 : if (poUnderlyingLayer == nullptr)
227 : {
228 : // If the open fails, poUnderlyingLayer will still be a nullptr
229 : // and the user will be warned by the open call.
230 0 : CPL_IGNORE_RET_VAL(OpenUnderlyingLayer());
231 : }
232 0 : return poUnderlyingLayer;
233 : }
234 :
235 : /************************************************************************/
236 : /* GetSpatialFilter() */
237 : /************************************************************************/
238 :
239 0 : OGRGeometry *OGRProxiedLayer::GetSpatialFilter()
240 : {
241 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
242 0 : return nullptr;
243 0 : return poUnderlyingLayer->GetSpatialFilter();
244 : }
245 :
246 : /************************************************************************/
247 : /* ISetSpatialFilter() */
248 : /************************************************************************/
249 :
250 102 : OGRErr OGRProxiedLayer::ISetSpatialFilter(int iGeomField,
251 : const OGRGeometry *poGeom)
252 : {
253 102 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
254 0 : return OGRERR_FAILURE;
255 102 : return poUnderlyingLayer->SetSpatialFilter(iGeomField, poGeom);
256 : }
257 :
258 : /************************************************************************/
259 : /* SetAttributeFilter() */
260 : /************************************************************************/
261 :
262 102 : OGRErr OGRProxiedLayer::SetAttributeFilter(const char *poAttrFilter)
263 : {
264 102 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
265 0 : return OGRERR_FAILURE;
266 102 : return poUnderlyingLayer->SetAttributeFilter(poAttrFilter);
267 : }
268 :
269 : /************************************************************************/
270 : /* ResetReading() */
271 : /************************************************************************/
272 :
273 80 : void OGRProxiedLayer::ResetReading()
274 : {
275 80 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
276 0 : return;
277 80 : poUnderlyingLayer->ResetReading();
278 : }
279 :
280 : /************************************************************************/
281 : /* GetNextFeature() */
282 : /************************************************************************/
283 :
284 1129 : OGRFeature *OGRProxiedLayer::GetNextFeature()
285 : {
286 1129 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
287 0 : return nullptr;
288 1129 : return poUnderlyingLayer->GetNextFeature();
289 : }
290 :
291 : /************************************************************************/
292 : /* GDALDataset() */
293 : /************************************************************************/
294 :
295 0 : GDALDataset *OGRProxiedLayer::GetDataset()
296 : {
297 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
298 0 : return nullptr;
299 0 : return poUnderlyingLayer->GetDataset();
300 : }
301 :
302 : /************************************************************************/
303 : /* GetArrowStream() */
304 : /************************************************************************/
305 :
306 0 : bool OGRProxiedLayer::GetArrowStream(struct ArrowArrayStream *out_stream,
307 : CSLConstList papszOptions)
308 : {
309 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
310 : {
311 0 : memset(out_stream, 0, sizeof(*out_stream));
312 0 : return false;
313 : }
314 0 : return poUnderlyingLayer->GetArrowStream(out_stream, papszOptions);
315 : }
316 :
317 : /************************************************************************/
318 : /* SetNextByIndex() */
319 : /************************************************************************/
320 :
321 0 : OGRErr OGRProxiedLayer::SetNextByIndex(GIntBig nIndex)
322 : {
323 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
324 0 : return OGRERR_FAILURE;
325 0 : return poUnderlyingLayer->SetNextByIndex(nIndex);
326 : }
327 :
328 : /************************************************************************/
329 : /* GetFeature() */
330 : /************************************************************************/
331 :
332 0 : OGRFeature *OGRProxiedLayer::GetFeature(GIntBig nFID)
333 : {
334 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
335 0 : return nullptr;
336 0 : return poUnderlyingLayer->GetFeature(nFID);
337 : }
338 :
339 : /************************************************************************/
340 : /* ISetFeature() */
341 : /************************************************************************/
342 :
343 0 : OGRErr OGRProxiedLayer::ISetFeature(OGRFeature *poFeature)
344 : {
345 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
346 0 : return OGRERR_FAILURE;
347 0 : return poUnderlyingLayer->SetFeature(poFeature);
348 : }
349 :
350 : /************************************************************************/
351 : /* ISetFeatureUniqPtr() */
352 : /************************************************************************/
353 :
354 : OGRErr
355 0 : OGRProxiedLayer::ISetFeatureUniqPtr(std::unique_ptr<OGRFeature> poFeature)
356 : {
357 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
358 0 : return OGRERR_FAILURE;
359 0 : return poUnderlyingLayer->SetFeature(std::move(poFeature));
360 : }
361 :
362 : /************************************************************************/
363 : /* ICreateFeature() */
364 : /************************************************************************/
365 :
366 0 : OGRErr OGRProxiedLayer::ICreateFeature(OGRFeature *poFeature)
367 : {
368 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
369 0 : return OGRERR_FAILURE;
370 0 : return poUnderlyingLayer->CreateFeature(poFeature);
371 : }
372 :
373 : /************************************************************************/
374 : /* ICreateFeatureUniqPtr() */
375 : /************************************************************************/
376 :
377 : OGRErr
378 0 : OGRProxiedLayer::ICreateFeatureUniqPtr(std::unique_ptr<OGRFeature> poFeature,
379 : GIntBig *pnFID)
380 : {
381 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
382 0 : return OGRERR_FAILURE;
383 0 : return poUnderlyingLayer->CreateFeature(std::move(poFeature), pnFID);
384 : }
385 :
386 : /************************************************************************/
387 : /* IUpsertFeature() */
388 : /************************************************************************/
389 :
390 0 : OGRErr OGRProxiedLayer::IUpsertFeature(OGRFeature *poFeature)
391 : {
392 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
393 0 : return OGRERR_FAILURE;
394 0 : return poUnderlyingLayer->UpsertFeature(poFeature);
395 : }
396 :
397 : /************************************************************************/
398 : /* IUpdateFeature() */
399 : /************************************************************************/
400 :
401 0 : OGRErr OGRProxiedLayer::IUpdateFeature(OGRFeature *poFeature,
402 : int nUpdatedFieldsCount,
403 : const int *panUpdatedFieldsIdx,
404 : int nUpdatedGeomFieldsCount,
405 : const int *panUpdatedGeomFieldsIdx,
406 : bool bUpdateStyleString)
407 : {
408 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
409 0 : return OGRERR_FAILURE;
410 0 : return poUnderlyingLayer->UpdateFeature(
411 : poFeature, nUpdatedFieldsCount, panUpdatedFieldsIdx,
412 0 : nUpdatedGeomFieldsCount, panUpdatedGeomFieldsIdx, bUpdateStyleString);
413 : }
414 :
415 : /************************************************************************/
416 : /* DeleteFeature() */
417 : /************************************************************************/
418 :
419 0 : OGRErr OGRProxiedLayer::DeleteFeature(GIntBig nFID)
420 : {
421 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
422 0 : return OGRERR_FAILURE;
423 0 : return poUnderlyingLayer->DeleteFeature(nFID);
424 : }
425 :
426 : /************************************************************************/
427 : /* GetName() */
428 : /************************************************************************/
429 :
430 0 : const char *OGRProxiedLayer::GetName() const
431 : {
432 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
433 0 : return "";
434 0 : return poUnderlyingLayer->GetName();
435 : }
436 :
437 : /************************************************************************/
438 : /* GetGeomType() */
439 : /************************************************************************/
440 :
441 0 : OGRwkbGeometryType OGRProxiedLayer::GetGeomType() const
442 : {
443 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
444 0 : return wkbUnknown;
445 0 : return poUnderlyingLayer->GetGeomType();
446 : }
447 :
448 : /************************************************************************/
449 : /* GetLayerDefn() */
450 : /************************************************************************/
451 :
452 258 : const OGRFeatureDefn *OGRProxiedLayer::GetLayerDefn() const
453 : {
454 516 : std::lock_guard oLock(m_oMutex);
455 258 : if (poFeatureDefn != nullptr)
456 250 : return poFeatureDefn;
457 :
458 8 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
459 : {
460 0 : poFeatureDefn = new OGRFeatureDefn("");
461 : }
462 : else
463 : {
464 8 : poFeatureDefn = poUnderlyingLayer->GetLayerDefn();
465 : }
466 :
467 8 : poFeatureDefn->Reference();
468 :
469 8 : return poFeatureDefn;
470 : }
471 :
472 : /************************************************************************/
473 : /* GetSpatialRef() */
474 : /************************************************************************/
475 :
476 14 : const OGRSpatialReference *OGRProxiedLayer::GetSpatialRef() const
477 : {
478 28 : std::lock_guard oLock(m_oMutex);
479 14 : if (poSRS != nullptr)
480 8 : return poSRS;
481 6 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
482 0 : return nullptr;
483 : OGRSpatialReference *l_poSRS =
484 6 : const_cast<OGRSpatialReference *>(poUnderlyingLayer->GetSpatialRef());
485 6 : if (l_poSRS != nullptr)
486 : {
487 6 : l_poSRS->Reference();
488 6 : poSRS = l_poSRS;
489 : }
490 6 : return poSRS;
491 : }
492 :
493 : /************************************************************************/
494 : /* GetFeatureCount() */
495 : /************************************************************************/
496 :
497 24 : GIntBig OGRProxiedLayer::GetFeatureCount(int bForce)
498 : {
499 24 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
500 0 : return 0;
501 24 : return poUnderlyingLayer->GetFeatureCount(bForce);
502 : }
503 :
504 : /************************************************************************/
505 : /* IGetExtent() */
506 : /************************************************************************/
507 :
508 8 : OGRErr OGRProxiedLayer::IGetExtent(int iGeomField, OGREnvelope *psExtent,
509 : bool bForce)
510 : {
511 8 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
512 0 : return OGRERR_FAILURE;
513 8 : return poUnderlyingLayer->GetExtent(iGeomField, psExtent, bForce);
514 : }
515 :
516 : /************************************************************************/
517 : /* TestCapability() */
518 : /************************************************************************/
519 :
520 110 : int OGRProxiedLayer::TestCapability(const char *pszCapability) const
521 : {
522 110 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
523 0 : return FALSE;
524 110 : return poUnderlyingLayer->TestCapability(pszCapability);
525 : }
526 :
527 : /************************************************************************/
528 : /* CreateField() */
529 : /************************************************************************/
530 :
531 0 : OGRErr OGRProxiedLayer::CreateField(const OGRFieldDefn *poField, int bApproxOK)
532 : {
533 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
534 0 : return OGRERR_FAILURE;
535 0 : return poUnderlyingLayer->CreateField(poField, bApproxOK);
536 : }
537 :
538 : /************************************************************************/
539 : /* DeleteField() */
540 : /************************************************************************/
541 :
542 0 : OGRErr OGRProxiedLayer::DeleteField(int iField)
543 : {
544 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
545 0 : return OGRERR_FAILURE;
546 0 : return poUnderlyingLayer->DeleteField(iField);
547 : }
548 :
549 : /************************************************************************/
550 : /* ReorderFields() */
551 : /************************************************************************/
552 :
553 0 : OGRErr OGRProxiedLayer::ReorderFields(int *panMap)
554 : {
555 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
556 0 : return OGRERR_FAILURE;
557 0 : return poUnderlyingLayer->ReorderFields(panMap);
558 : }
559 :
560 : /************************************************************************/
561 : /* AlterFieldDefn() */
562 : /************************************************************************/
563 :
564 0 : OGRErr OGRProxiedLayer::AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn,
565 : int nFlagsIn)
566 : {
567 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
568 0 : return OGRERR_FAILURE;
569 0 : return poUnderlyingLayer->AlterFieldDefn(iField, poNewFieldDefn, nFlagsIn);
570 : }
571 :
572 : /************************************************************************/
573 : /* AlterGeomFieldDefn() */
574 : /************************************************************************/
575 :
576 0 : OGRErr OGRProxiedLayer::AlterGeomFieldDefn(
577 : int iGeomField, const OGRGeomFieldDefn *poNewGeomFieldDefn, int nFlagsIn)
578 : {
579 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
580 0 : return OGRERR_FAILURE;
581 0 : return poUnderlyingLayer->AlterGeomFieldDefn(iGeomField, poNewGeomFieldDefn,
582 0 : nFlagsIn);
583 : }
584 :
585 : /************************************************************************/
586 : /* SyncToDisk() */
587 : /************************************************************************/
588 :
589 0 : OGRErr OGRProxiedLayer::SyncToDisk()
590 : {
591 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
592 0 : return OGRERR_FAILURE;
593 0 : return poUnderlyingLayer->SyncToDisk();
594 : }
595 :
596 : /************************************************************************/
597 : /* GetStyleTable() */
598 : /************************************************************************/
599 :
600 4 : OGRStyleTable *OGRProxiedLayer::GetStyleTable()
601 : {
602 4 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
603 0 : return nullptr;
604 4 : return poUnderlyingLayer->GetStyleTable();
605 : }
606 :
607 : /************************************************************************/
608 : /* SetStyleTableDirectly() */
609 : /************************************************************************/
610 :
611 0 : void OGRProxiedLayer::SetStyleTableDirectly(OGRStyleTable *poStyleTable)
612 : {
613 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
614 0 : return;
615 0 : return poUnderlyingLayer->SetStyleTableDirectly(poStyleTable);
616 : }
617 :
618 : /************************************************************************/
619 : /* SetStyleTable() */
620 : /************************************************************************/
621 :
622 0 : void OGRProxiedLayer::SetStyleTable(OGRStyleTable *poStyleTable)
623 : {
624 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
625 0 : return;
626 0 : return poUnderlyingLayer->SetStyleTable(poStyleTable);
627 : }
628 :
629 : /************************************************************************/
630 : /* StartTransaction() */
631 : /************************************************************************/
632 :
633 0 : OGRErr OGRProxiedLayer::StartTransaction()
634 : {
635 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
636 0 : return OGRERR_FAILURE;
637 0 : return poUnderlyingLayer->StartTransaction();
638 : }
639 :
640 : /************************************************************************/
641 : /* CommitTransaction() */
642 : /************************************************************************/
643 :
644 0 : OGRErr OGRProxiedLayer::CommitTransaction()
645 : {
646 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
647 0 : return OGRERR_FAILURE;
648 0 : return poUnderlyingLayer->CommitTransaction();
649 : }
650 :
651 : /************************************************************************/
652 : /* RollbackTransaction() */
653 : /************************************************************************/
654 :
655 0 : OGRErr OGRProxiedLayer::RollbackTransaction()
656 : {
657 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
658 0 : return OGRERR_FAILURE;
659 0 : return poUnderlyingLayer->RollbackTransaction();
660 : }
661 :
662 : /************************************************************************/
663 : /* GetFIDColumn() */
664 : /************************************************************************/
665 :
666 8 : const char *OGRProxiedLayer::GetFIDColumn() const
667 : {
668 8 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
669 0 : return "";
670 8 : return poUnderlyingLayer->GetFIDColumn();
671 : }
672 :
673 : /************************************************************************/
674 : /* GetGeometryColumn() */
675 : /************************************************************************/
676 :
677 0 : const char *OGRProxiedLayer::GetGeometryColumn() const
678 : {
679 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
680 0 : return "";
681 0 : return poUnderlyingLayer->GetGeometryColumn();
682 : }
683 :
684 : /************************************************************************/
685 : /* SetIgnoredFields() */
686 : /************************************************************************/
687 :
688 76 : OGRErr OGRProxiedLayer::SetIgnoredFields(CSLConstList papszFields)
689 : {
690 76 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
691 0 : return OGRERR_FAILURE;
692 76 : return poUnderlyingLayer->SetIgnoredFields(papszFields);
693 : }
694 :
695 : /************************************************************************/
696 : /* Rename() */
697 : /************************************************************************/
698 :
699 0 : OGRErr OGRProxiedLayer::Rename(const char *pszNewName)
700 : {
701 0 : if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer())
702 0 : return OGRERR_FAILURE;
703 0 : return poUnderlyingLayer->Rename(pszNewName);
704 : }
705 :
706 : #endif /* #ifndef DOXYGEN_SKIP */
|