[XOP] C++ Wrapper for MDAccessNumericWaveData

The function getWaveDataPtr(waveHandle) can be used as a convenient wrapper for MDAccessNumericWaveData(...).
Examples:
<br />
// waveH points to a double/NT_FP64 wave<br />
double *dbl = getWaveDataPtr<double>(waveH)<br />
// float/NT_FP32<br />
float *flt = getWaveDataPtr<float>(waveH)<br />
// int/NT_I32<br />
int *integer = getWaveDataPtr<int>(waveH)<br />


In case you pass a textwave or the wave layout has changed at some point in the future the return value is null.

Be sure to place the template function into a header file.
<br />
// check the return value for NULL<br />
template <class T> T* getWaveDataPtr(waveHndl waveH){<br />
    int accessMode = kMDWaveAccessMode0;<br />
    int ret=-1;<br />
    BCInt dataOffset;<br />
    T *dataPtr;<br />
<br />
    ret = MDAccessNumericWaveData(waveH, accessMode, &dataOffset);<br />
    if(ret != 0 ){<br />
        // throw here someting if you want to have it more C++-ish<br />
        return NULL;<br />
    }<br />
<br />
    dataPtr = reinterpret_cast<T*>( reinterpret_cast<char*>(*waveH) + dataOffset );<br />
    return dataPtr;<br />
}<br />

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More