[Clam-devel] Re: Patch for Steps of LoadFrom
David García Garzón
dgarcia at iua.upf.edu
Mon Jun 16 02:23:46 PDT 2008
> > Once we turned the constructor into a templateless one, lets
> > do an 'Extract method' refactoring from the constructor for
> > the data filling part. So, for each Segmentation add the
> > following method:
> > void takeArray(TData * begin, TData * iterator end)
> > {
> > // copy here the filling code from the constructor
> > }
> > Then substitute the copied code at the constructor by a call
> > to such method. All the test should be working.
>
> The patch is of the step above.
> Notice that to make the test pass, I made a forced type change
> (Iterator->TData), and changed the related type (double->float) of the
> unittests. That is ugly and requires the "Iterator" datatype must be
> consistent with "TData".
Notice that such cast is not safe (it works but it should not). Just make the
constructor not a template but a using a TData *.
If we want to allow both float and double we could just overload both, the
constructor and the takeArray method, with both, float* and double*
parameters. But doing such a cas is dangerous as you cold feed float* and it
would not work as the stride (gap in bytes between elements) for float and
doubles is different. So let's adhere to TData*.
--
David García Garzón
(Work) dgarcia at iua dot upf anotherdot es
http://www.iua.upf.edu/~dgarcia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20080616/86d193eb/attachment-0001.sig>
More information about the clam-devel
mailing list