Design of LibVob C++ Vob templates

Design of LibVob Design of the C Design of LibVob C Design of LibVob Design of the C Design of LibVob C design_navigation

The Vob templates were not an easy design: the previous approach in Gzz's gfx/librenderables/ was not at all optimal, due to the syntactic complexities and the single point of generation.

The ideal requirements for the template design were:

To my surprise, there was a solution. The basic Vob definition would be

struct SomeVob {
    float someParam;
    vector<float> otherParam;

    template<class T> void render(const T &t0, const T &t1) const {

where the template is used to allow later optimizations to the coordinate system types.

The way to obtain, for code generation, the types of the parameters, is to add a single method to the class:

template<class F> void params(F &f) {

Now, the caller simply gives as parameter an object with a generic operator(), and that operator gets as parameters the types.

The same function can be used to get references to all members in the JNI code, allowing copyless assignments.