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