[geos-devel] GeometryCollection constructor

Norman Vine nhv at cape.com
Wed Oct 8 09:15:24 EDT 2003


strk writes:
> nhv wrote:
> > strk writes:
> > > 
> > > but my question is: should memory copy go further copying each
> > > object in the vector instead of just the vector itself ?
> > 
> > Ack...
> > 
> > I thought we were going to use reference counted pointers
> > just so we could *safely* pass pointers instead of objects around
> > and not have to worry about objects being prematurely deleted
> > or conversely needlessly left on the heap !!
> 
> Sometimes you really want a copy, because you are going to modify it,
> while sometimes a pointer would be just fine ... 

Indeed we need 'deep' and 'shallow' copy methods

> You might make a copy when needed, but it would be better to make
> it *MANDATORY* for developers willing to modify returned objects
> (would a 'const'  work for that?). 

this should work by passing a 'const pointer' when that is what is wanted

> Alternatively every change to an object
> should be done using public methods that in turn should check ownership
> of the object (caller object address? is that available?) and transparently
> make a copy of it when needed ... 

Or just use the 'deep' copy method when appropriate.
But we certainlly don't want to be copying every data structure every operation
or GEOS will return to a 'crawl' as it was with it's initial 'naive' Java Translation

> wouldn't be easier to use directly Java for it ? ;)

Well there is JTS if that is your language of choice :-)
 
Norman



More information about the geos-devel mailing list