-1 for the middle ground (template internal, float external).   It
will make the internal implementations harder to read, harder to
write, and harder to maintain.   My preference is that we're going to
only expose float in the API, let's just keep it simple interally and
write it assuming float. If and when we need to cross the type bridge
(and my bet is it never ends up happening), we can update the
implementations.

-- Jeremy

On Sat, Jun 30, 2012 at 1:36 AM, Chris Foster <[email protected]> wrote:
> On Sat, Jun 30, 2012 at 9:54 AM, Larry Gritz <[email protected]> wrote:
>> Another possibility: write the functions as templates (as we have),
>> call them only for <float> variations, leave them where they are (not
>> a separate header), but then they are "shovel ready" if we ever want
>> to expose them in some other way, or for people to copy into their own
>> code.
>
> I like this plan.
>
>> So functionality like "over" would look like this:
> ...
>>   // Type-neutral wrapper, exposed in public API:
>>   bool ImageBufAlgo::over (ImageBuf &R, const ImageBuf &A, const ImageBuf 
>> &B, ROI roi,
>>                            int nthreads)
>>   {
>>       if (R.spec.format != FLOAT || A.spec.format != FLOAT || B.spec.format 
>> != FLOAT)
>>          return false;   // only work on float bufs
>
> Let's have the type consistency check inside the templated version:
>
> // Fully type-specialized version of over -- internal to imagebufalgo.cpp
> template<class Rtype, class Atype, class Btype>
> void over (ImageBuf &R, const ImageBuf &A, const ImageBuf &B, ROI roi)
> {
>     if (R.spec.format != BaseTypeFromC<Rtype>::value ||
>         A.spec.format != BaseTypeFromC<Atype>::value ||
>         B.spec.format != BaseTypeFromC<Btype>::value)
>         return false; // type mismatch
>     ...
> }
>
> ~Chris
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to