Skip to content

Commit 4f8a414

Browse files
authored
Make virtual methods OGRLayer::GetFIDColumn()/GetGeometryColumn() (impacts out-of-tree drivers) (OSGeo#13018)
2 parents a0eb37e + 530a46e commit 4f8a414

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+102
-98
lines changed

MIGRATION_GUIDE.TXT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ MIGRATION GUIDE FROM GDAL 3.11 to GDAL 3.12
2121
* OGRLayer::GetName() is now a const method
2222
* OGRLayer::GetGeomType() is now a const method
2323
* OGRLayer::GetLayerDefn() is now a const method that returns a const OGRFeatureDefn*
24+
* OGRLayer::GetFIDColumn() is now a const method
25+
* OGRLayer::GetGeometryColumn() is now a const method
2426
* OGRLayer::GetSpatialRef() is now a const method that returns a const OGRSpatialReference*
2527
* OGRLayer::TestCapacility() is now a const method
2628

frmts/mem/memdataset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class CPL_DLL OGRMemLayer CPL_NON_FINAL : public OGRLayer
303303

304304
int TestCapability(const char *) const override;
305305

306-
const char *GetFIDColumn() override
306+
const char *GetFIDColumn() const override
307307
{
308308
return m_osFIDColumn.c_str();
309309
}

frmts/tiledb/tiledbheaders.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ class OGRTileDBLayer final : public OGRLayer,
488488
OGRErr IGetExtent(int iGeomField, OGREnvelope *psExtent,
489489
bool bForce) override;
490490

491-
const char *GetFIDColumn() override
491+
const char *GetFIDColumn() const override
492492
{
493493
return m_osFIDColumn.c_str();
494494
}

gcore/gdalpythondriverloader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ class PythonPluginLayer final : public OGRLayer
299299
mutable PyObject *m_poLayer = nullptr;
300300
mutable OGRFeatureDefn *m_poFeatureDefn = nullptr;
301301
mutable CPLString m_osName{};
302-
CPLString m_osFIDColumn{};
303-
bool m_bHasFIDColumn = false;
302+
mutable CPLString m_osFIDColumn{};
303+
mutable bool m_bHasFIDColumn = false;
304304
std::map<CPLString, CPLStringList> m_oMapMD{};
305305
PyObject *m_pyFeatureByIdMethod = nullptr;
306306
bool m_bIteratorHonourSpatialFilter = false;
@@ -332,7 +332,7 @@ class PythonPluginLayer final : public OGRLayer
332332
const OGRFeatureDefn *GetLayerDefn() const override;
333333

334334
GIntBig GetFeatureCount(int bForce) override;
335-
const char *GetFIDColumn() override;
335+
const char *GetFIDColumn() const override;
336336
OGRErr SetAttributeFilter(const char *) override;
337337

338338
OGRErr ISetSpatialFilter(int iGeomField, const OGRGeometry *) override;
@@ -582,7 +582,7 @@ int PythonPluginLayer::TestCapability(const char *pszCap) const
582582
/* GetFIDColumn() */
583583
/************************************************************************/
584584

585-
const char *PythonPluginLayer::GetFIDColumn()
585+
const char *PythonPluginLayer::GetFIDColumn() const
586586
{
587587
if (!m_bHasFIDColumn)
588588
{

gnm/gnm.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ class GNMGenericLayer : public OGRLayer
569569
virtual OGRErr CommitTransaction() override;
570570
virtual OGRErr RollbackTransaction() override;
571571

572-
virtual const char *GetFIDColumn() override;
573-
virtual const char *GetGeometryColumn() override;
572+
const char *GetFIDColumn() const override;
573+
const char *GetGeometryColumn() const override;
574574

575575
virtual OGRErr SetIgnoredFields(CSLConstList papszFields) override;
576576

@@ -753,8 +753,8 @@ class OGRGNMWrappedResultLayer : public OGRLayer
753753
int bApproxOK = TRUE) override;
754754
virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField,
755755
int bApproxOK = TRUE) override;
756-
virtual const char *GetFIDColumn() override;
757-
virtual const char *GetGeometryColumn() override;
756+
const char *GetFIDColumn() const override;
757+
const char *GetGeometryColumn() const override;
758758
virtual const OGRSpatialReference *GetSpatialRef() const override;
759759

760760
// OGRGNMWrappedResultLayer

gnm/gnmlayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ GNMGenericLayer::GNMGenericLayer(OGRLayer *poLayer,
4545
*/
4646
GNMGenericLayer::~GNMGenericLayer() = default;
4747

48-
const char *GNMGenericLayer::GetFIDColumn()
48+
const char *GNMGenericLayer::GetFIDColumn() const
4949
{
5050
return GNM_SYSFIELD_GFID;
5151
}
5252

53-
const char *GNMGenericLayer::GetGeometryColumn()
53+
const char *GNMGenericLayer::GetGeometryColumn() const
5454
{
5555
return m_poLayer->GetGeometryColumn();
5656
}

gnm/gnmresultlayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ OGRGNMWrappedResultLayer::CreateGeomField(const OGRGeomFieldDefn *poField,
106106
return poLayer->CreateGeomField(poField, bApproxOK);
107107
}
108108

109-
const char *OGRGNMWrappedResultLayer::GetFIDColumn()
109+
const char *OGRGNMWrappedResultLayer::GetFIDColumn() const
110110
{
111111
return poLayer->GetFIDColumn();
112112
}
113113

114-
const char *OGRGNMWrappedResultLayer::GetGeometryColumn()
114+
const char *OGRGNMWrappedResultLayer::GetGeometryColumn() const
115115
{
116116
return poLayer->GetGeometryColumn();
117117
}

ogr/ogrsf_frmts/adbc/ogr_adbc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class OGRADBCLayer /* non final */ : public OGRLayer,
187187
OGRErr IGetExtent3D(int iGeomField, OGREnvelope3D *psExtent,
188188
bool bForce) override;
189189

190-
const char *GetFIDColumn() override;
190+
const char *GetFIDColumn() const override;
191191
};
192192

193193
/************************************************************************/

ogr/ogrsf_frmts/adbc/ogradbclayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ const OGRFeatureDefn *OGRADBCLayer::GetLayerDefn() const
8989
/* GetFIDColumn() */
9090
/************************************************************************/
9191

92-
const char *OGRADBCLayer::GetFIDColumn()
92+
const char *OGRADBCLayer::GetFIDColumn() const
9393
{
9494
if (!m_poAdapterLayer)
95-
BuildLayerDefn();
95+
const_cast<OGRADBCLayer *>(this)->BuildLayerDefn();
9696
return m_osFIDColName.c_str();
9797
}
9898

ogr/ogrsf_frmts/amigocloud/ogr_amigocloud.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class OGRAmigoCloudLayer CPL_NON_FINAL : public OGRLayer
109109
virtual OGRFeatureDefn *GetLayerDefnInternal(json_object *poObjIn) = 0;
110110
virtual json_object *FetchNewFeatures(GIntBig iNext);
111111

112-
virtual const char *GetFIDColumn() override
112+
const char *GetFIDColumn() const override
113113
{
114114
return osFIDColName.c_str();
115115
}

0 commit comments

Comments
 (0)