VuoType in the API

Hello!

Is it possible to in a VuoGenericType situation filter the type so that we can use boolean operators to decide whether there is an y/z/w value using an if statement?

Not exactly.

What you can do is write (or find already written) different versions of a function that apply to each type. For example, if adding two points, you could call VuoGenericType1_add which will call VuoPoint2d_add or VuoPoint3d_add or VuoPoint4d_add depending on the type substituted in for VuoGenericType1.

I guess you could even write a group of functions like this to check the data type you’re working with:

static bool VuoPoint2d_hasZCoord(VuoPoint2d p) { return false; }
static bool VuoPoint3d_hasZCoord(VuoPoint3d p) { return true; }
static bool VuoPoint4d_hasZCoord(VuoPoint4d p) { return true; }

Although then what do you do with that information? The following would not work:

VuoGenericType1 p;
if (VuoGenericType1_hasZCoord(p))
   p.z = 1;   // compile error

So you’re probably better off writing/using higher-level functions like VuoPoint*d_add that don’t just check for the existence of a certain coordinate, but actually accomplish whatever you need to do based on that check.

Or another option would be to eschew generic types and instead implement a separate version of the node class for each data type, like vuo.point.get.VuoPoint2d and vuo.point.get.VuoPoint3d and vuo.point.get.VuoPoint4d.