On 30/11/10 16:57, Howard Butler wrote:
On Nov 30, 2010, at 9:50 AM, Michael Gerlek wrote:

2. Auto_ptr is used for ReaderImpl and some others.  What is the
intent here?

I hope Mateusz can chime in on this one.  I never fully understood
the intent here, but I'm kind of a dolt on these things.

Are you asking why the auto_ptr in particular or why smart
pointer at all?

Initially, the Reader and ReaderImpl were designed based
on the PIMPL (handle-body) idiom. It is still true,
but handle has lost it's lightweight and become a semi-body now.

The reason is simple: RAII and no need for managing lifetime of the body
object. It doesn't have to be auto_ptr, but any scope-friendly smart
pointer. auto_ptr is available in the standard library and
works very well, so I use it.

One could imagine (and Howard suggested) a factory which spits out
 ReaderI's based on given inputs (based on file extensions or magic
 numbers or whathaveyou, see next question).

Mateusz had taken on some of this effort, but backed off after it
became apparent that it would require tearing apart a number of
things.  I hope he can explain what he thinks might be needed to
pick this back up.

My idea was to the make the Reader a ref-counted handle, thus
copyable and assignable. Then factory returns this lightweight handle.
However, the Reader has become fat, then this idea is more or less blocked.

A poor solution could be to employ boost::shared_ptr<Reader> to provide the ref-counted lightweight object returned from factory and passed around, but I don't like such "handle to handle to body" stack at all, so I've given up.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.org
_______________________________________________
Liblas-devel mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/liblas-devel

Reply via email to