daeTArray<T> programming tip


Lately I’ve encountered some problem and haven’t found any good solution yet.

What I’m trying to do is to use some structure that cointains pointers to daeTArrays for easier use:

struct Buffers
daeTArray<int>* indexBuf;
daeTArray<float>* vertexBuf;
//and so on…

So the problem is that those template types are created during compile time just to generate code. I examine the type of data in <source… elements (in <mesh> element):

    &lt;source id="geom-Plane1-positions"&gt;
      &lt;float_array id="geom-Plane1-positions-array" count="18"&gt;-0.19685 -0.19685 0 0 -0.19685 0 0.19685 -0.19685 0 -0.19685 0.19685 0 0 0.19685 0 0.19685 0.19685 0&lt;/float_array&gt;
        &lt;accessor source="#geom-Plane1-positions-array" count="6" stride="3"&gt;
          &lt;param name="X" type="float"/&gt;
          &lt;param name="Y" type="float"/&gt;
          &lt;param name="Z" type="float"/&gt;

As we can see source can have float_array or maybe sometime int_array (can I consider that it always will be a float_array?)? So do I need to generate two structures (or two pointers to different types in one) staticaly one with vertexBuf of type daeTArray<float> and another with daeTArray<int> then using switch/if? or can I change it dynamically in run time somehow having just one pointer ?
I’m using COLLADA DOM 2.1 (c++) (1.4.1 schema)

Caching array pointers isn’t going to be sufficient to let you read values from a <source> if that’s what you’re trying to do. The <source> element can contain (0 or 1 of) many types of arrays and an <accessor> that describes the output data stream.