[Gdal-dev] Re: Adding const to OGR geometry classes?

Marcus Barnes marcus at keyholecorp.com
Wed May 14 13:26:24 EDT 2003


Const correctness is often very difficult to retrofit into an existing
framework. Plus const-volatile qualifiers is another thing that can
break link compatibility depending on the implementation.

Regards.
---
Marcus Barnes mailto:marcus at keyholecorp.com 
Keyhole Inc. Mt View, CA http://www.earthviewer.com
 

-----Original Message-----
From: gdal-dev-admin at remotesensing.org
[mailto:gdal-dev-admin at remotesensing.org] On Behalf Of Frank Warmerdam
Sent: Wednesday, May 14, 2003 5:59 AM
To: Ben Discoe
Cc: Roger James; gdal-dev
Subject: [Gdal-dev] Re: Adding const to OGR geometry classes?


Ben Discoe wrote:
> Hi Frank,
> 
> I have been forging ahead with the plan to make heavier use of the OGR

> geometry classes as replacements for the old, simple geometry classes 
> the VTP currently uses.
> 
> This means i've been starting to use classes like OGRPolygon directly 
> for my own storage and methods, rather than just as a means to use OGR

> as a format reader.
> 
> Here is one thing i've encountered.  How would you feel about adding 
> 'const' as appropriate in methods that won't modify what they're
passed.
> 	e.g.
> << OGRLinearRing::OGRLinearRing( OGRLinearRing * );
> 
>>>OGRLinearRing::OGRLinearRing( const OGRLinearRing * );
> 
> 
> <<    void   OGRPolygon::addRing( OGRLinearRing * );
> 
>>>   void   OGRPolygon::addRing( const OGRLinearRing * );
> 
> 
> If you have no objections, i'd be happy to make the changes and submit

> them to you.  I can play it conservatively, only using const where 
> it's entirely unambiguous.

Ben,

I realize this would be a good idea for a clean C++ interface.  However,
any constness changes alter the C++ signatures and this gives me no end
of headaches from OGR uses trying to use slightly updated OGR shared
libraries with precompiled applications using OGR.  After getting burned
painfully with previous const correctness changes you suggested in
OGRSpatialReference, I have been hesitant to apply more.

Recently I have actually been encouraging applications to use the OGR C
API to reduce the tie-age to a specific GDAL/OGR build.

I am cc:ing this to the gdal-dev list to collect other opinions on
whether const correctness changes are worth the pain.  I realize it
isn't clean, but the issue is just whether you need to cast away the
constness in your application level code, right?

Best regards,

-- 
---------------------------------------+--------------------------------
---------------------------------------+------
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent


_______________________________________________
Gdal-dev mailing list
Gdal-dev at remotesensing.org
http://remotesensing.org/mailman/listinfo/gdal-dev




More information about the Gdal-dev mailing list