[geos-devel] initGEOS/finishGEOS and multiple subsystems
Mateusz Loskot
mateusz at loskot.net
Fri Jun 30 17:21:52 EDT 2006
Frank Warmerdam wrote:
> Mateusz Loskot wrote:
>> strk at refractions.net wrote:
>>> With GEOS-3.0.0 initGEOS/finishGEOS do not instantiate/delete a
>>> GeometryFactory anymore. Rather the default GeometryFactory is
>>> used. This should fix the problem.
>>
>> What about backport to 2.2.x with ref-counted proposal? Such
>> changes could would not affect existing code.
>>
>> I'd like to repeat that in general, global factory should be
>> replaced with shared object (e.g. managed by shared_ptr from Boost
>> or our own home-made shared smart pointer). static factory can
>> cause problems too:
>> http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12
>
> Mateusz,
>
> I personally hate static objects of any complexity because I don't
> like a lot of randomly ordered stuff happening before main() even
> starts.
Frank,
yes, that's the problem.
> I would much prefer the referenced counted implementation in 2.2.x
> and in head. I'm not sure how smart pointers would help since the
> functions don't return a handle for the caller to hold.
Yes, you mean initGEOS does not return any pointer/handle.
but I had in mind global static factory, recently replaced with lazy
initialized one:
const GeometryFactory*
GeometryFactory::getDefaultInstance()
{
static GeometryFactory defInstance;
return &defInstance;
}
BTW, boost::smart_ptr is implemented as ref-counted:
http://www.boost.org/libs/smart_ptr/shared_ptr.htm
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the geos-devel
mailing list