LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/generic - ogrlayerpool.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 4 4 100.0 %
Date: 2025-01-18 12:42:00 Functions: 2 2 100.0 %

          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 OGRLAYERPOOL_H_INCLUDED
      14             : #define OGRLAYERPOOL_H_INCLUDED
      15             : 
      16             : #ifndef DOXYGEN_SKIP
      17             : 
      18             : #include "ogrsf_frmts.h"
      19             : 
      20             : typedef OGRLayer *(*OpenLayerFunc)(void *user_data);
      21             : typedef void (*FreeUserDataFunc)(void *user_data);
      22             : 
      23             : class OGRLayerPool;
      24             : 
      25             : /************************************************************************/
      26             : /*                      OGRAbstractProxiedLayer                         */
      27             : /************************************************************************/
      28             : 
      29             : class CPL_DLL OGRAbstractProxiedLayer : public OGRLayer
      30             : {
      31             :     CPL_DISALLOW_COPY_ASSIGN(OGRAbstractProxiedLayer)
      32             : 
      33             :     friend class OGRLayerPool;
      34             : 
      35             :     OGRAbstractProxiedLayer
      36             :         *poPrevLayer; /* Chain to a layer that was used more recently */
      37             :     OGRAbstractProxiedLayer
      38             :         *poNextLayer; /* Chain to a layer that was used less recently */
      39             : 
      40             :   protected:
      41             :     OGRLayerPool *poPool;
      42             : 
      43             :     virtual void CloseUnderlyingLayer() = 0;
      44             : 
      45             :   public:
      46             :     explicit OGRAbstractProxiedLayer(OGRLayerPool *poPool);
      47             :     virtual ~OGRAbstractProxiedLayer();
      48             : };
      49             : 
      50             : /************************************************************************/
      51             : /*                             OGRLayerPool                             */
      52             : /************************************************************************/
      53             : 
      54             : class CPL_DLL OGRLayerPool
      55             : {
      56             :     CPL_DISALLOW_COPY_ASSIGN(OGRLayerPool)
      57             : 
      58             :   protected:
      59             :     OGRAbstractProxiedLayer *poMRULayer; /* the most recently used layer */
      60             :     OGRAbstractProxiedLayer
      61             :         *poLRULayer;  /* the least recently used layer (still opened) */
      62             :     int nMRUListSize; /* the size of the list */
      63             :     int nMaxSimultaneouslyOpened;
      64             : 
      65             :   public:
      66             :     explicit OGRLayerPool(int nMaxSimultaneouslyOpened = 100);
      67             :     ~OGRLayerPool();
      68             : 
      69             :     void SetLastUsedLayer(OGRAbstractProxiedLayer *poProxiedLayer);
      70             :     void UnchainLayer(OGRAbstractProxiedLayer *poProxiedLayer);
      71             : 
      72      223266 :     int GetMaxSimultaneouslyOpened() const
      73             :     {
      74      223266 :         return nMaxSimultaneouslyOpened;
      75             :     }
      76             : 
      77           5 :     int GetSize() const
      78             :     {
      79           5 :         return nMRUListSize;
      80             :     }
      81             : };
      82             : 
      83             : /************************************************************************/
      84             : /*                           OGRProxiedLayer                            */
      85             : /************************************************************************/
      86             : 
      87             : class CPL_DLL OGRProxiedLayer : public OGRAbstractProxiedLayer
      88             : {
      89             :     CPL_DISALLOW_COPY_ASSIGN(OGRProxiedLayer)
      90             : 
      91             :     OpenLayerFunc pfnOpenLayer;
      92             :     FreeUserDataFunc pfnFreeUserData;
      93             :     void *pUserData;
      94             :     OGRLayer *poUnderlyingLayer;
      95             :     OGRFeatureDefn *poFeatureDefn;
      96             :     OGRSpatialReference *poSRS;
      97             : 
      98             :     int OpenUnderlyingLayer();
      99             : 
     100             :   protected:
     101             :     virtual void CloseUnderlyingLayer() override;
     102             : 
     103             :   public:
     104             :     OGRProxiedLayer(OGRLayerPool *poPool, OpenLayerFunc pfnOpenLayer,
     105             :                     FreeUserDataFunc pfnFreeUserData, void *pUserData);
     106             :     virtual ~OGRProxiedLayer();
     107             : 
     108             :     OGRLayer *GetUnderlyingLayer();
     109             : 
     110             :     virtual OGRGeometry *GetSpatialFilter() override;
     111             :     virtual void SetSpatialFilter(OGRGeometry *) override;
     112             :     virtual void SetSpatialFilter(int iGeomField, OGRGeometry *) override;
     113             : 
     114             :     virtual OGRErr SetAttributeFilter(const char *) override;
     115             : 
     116             :     virtual void ResetReading() override;
     117             :     virtual OGRFeature *GetNextFeature() override;
     118             :     virtual OGRErr SetNextByIndex(GIntBig nIndex) override;
     119             :     virtual OGRFeature *GetFeature(GIntBig nFID) override;
     120             :     virtual OGRErr ISetFeature(OGRFeature *poFeature) override;
     121             :     virtual OGRErr ICreateFeature(OGRFeature *poFeature) override;
     122             :     virtual OGRErr IUpsertFeature(OGRFeature *poFeature) override;
     123             :     OGRErr IUpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
     124             :                           const int *panUpdatedFieldsIdx,
     125             :                           int nUpdatedGeomFieldsCount,
     126             :                           const int *panUpdatedGeomFieldsIdx,
     127             :                           bool bUpdateStyleString) override;
     128             :     virtual OGRErr DeleteFeature(GIntBig nFID) override;
     129             : 
     130             :     virtual GDALDataset *GetDataset() override;
     131             :     virtual bool GetArrowStream(struct ArrowArrayStream *out_stream,
     132             :                                 CSLConstList papszOptions = nullptr) override;
     133             : 
     134             :     virtual const char *GetName() override;
     135             :     virtual OGRwkbGeometryType GetGeomType() override;
     136             :     virtual OGRFeatureDefn *GetLayerDefn() override;
     137             : 
     138             :     virtual OGRSpatialReference *GetSpatialRef() override;
     139             : 
     140             :     virtual GIntBig GetFeatureCount(int bForce = TRUE) override;
     141             :     virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent,
     142             :                              int bForce = TRUE) override;
     143             :     virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) override;
     144             : 
     145             :     virtual int TestCapability(const char *) override;
     146             : 
     147             :     virtual OGRErr CreateField(const OGRFieldDefn *poField,
     148             :                                int bApproxOK = TRUE) override;
     149             :     virtual OGRErr DeleteField(int iField) override;
     150             :     virtual OGRErr ReorderFields(int *panMap) override;
     151             :     virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn,
     152             :                                   int nFlags) override;
     153             :     virtual OGRErr
     154             :     AlterGeomFieldDefn(int iGeomField,
     155             :                        const OGRGeomFieldDefn *poNewGeomFieldDefn,
     156             :                        int nFlags) override;
     157             : 
     158             :     virtual OGRErr SyncToDisk() override;
     159             : 
     160             :     virtual OGRStyleTable *GetStyleTable() override;
     161             :     virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable) override;
     162             : 
     163             :     virtual void SetStyleTable(OGRStyleTable *poStyleTable) override;
     164             : 
     165             :     virtual OGRErr StartTransaction() override;
     166             :     virtual OGRErr CommitTransaction() override;
     167             :     virtual OGRErr RollbackTransaction() override;
     168             : 
     169             :     virtual const char *GetFIDColumn() override;
     170             :     virtual const char *GetGeometryColumn() override;
     171             : 
     172             :     virtual OGRErr SetIgnoredFields(CSLConstList papszFields) override;
     173             : 
     174             :     virtual OGRErr Rename(const char *pszNewName) override;
     175             : };
     176             : 
     177             : #endif /* #ifndef DOXYGEN_SKIP */
     178             : 
     179             : #endif  // OGRLAYERPOOL_H_INCLUDED

Generated by: LCOV version 1.14