SoAutoMap< T > Class Template Reference
[CPU device]

VSG extension buffer object mapping helper class. More...

#include <Inventor/devices/SoAutoMap.h>

List of all members.

Public Member Functions

 SoAutoMap (SoBufferObject *bufferObject, SoBufferObject::AccessMode accessMode)
 ~SoAutoMap ()
T & operator[] (const size_t i)
const T & operator[] (const size_t i) const
size_t getSize () const

Detailed Description

template<typename T>
class SoAutoMap< T >

VSG extension buffer object mapping helper class.

This class provides an safe and simplified way to access data through typed a cpu array. It allows to use the following syntax while app wants to read or write some data from an SoBufferObject. Example:

    void updateABufferObject(SoBufferObject* bufferObject);
    {
      SoAutoMap<SbVec3f> vec3array(bufferObject,SoBufferObject::SET);
      for (int i=0;i<vec3array.getSize();++i)
        vec3array[i] = SbVec3f(0.f,0.f,0.f);
    }

    // which replace and add safety to the follwoing code
    void updateABufferObject(SoBufferObject* bufferObject);
    {
      SoRef<SoCpuBufferObject> cpuBufferObject = new SoCpuBufferObject;
      bufferObject->map(cpuBufferObject,SoBufferObject::SET);
      SbVec3f* vec3array = static_cast<SbVec3f*>(cpuBufferObject->map(SoBufferObject::SET));
      size_t arraySize=cpuBufferObject.getSize()/sizeof(SbVec3f);
      for (int i=0;i<arraySize;++i)
        vec3array[i] = SbVec3f(0.f,0.f,0.f);
      cpuBufferObject->unmap();
      bufferObject->unmap(cpuBufferObject);
    }

Constructor & Destructor Documentation

template<typename T>
SoAutoMap< T >::SoAutoMap ( SoBufferObject bufferObject,
SoBufferObject::AccessMode  accessMode 
) [inline]

Constructor.

In charge of setting mapping

template<typename T>
SoAutoMap< T >::~SoAutoMap (  )  [inline]

Destructor.

In charge of releasing mapping


Member Function Documentation

template<typename T>
size_t SoAutoMap< T >::getSize (  )  const [inline]

return the number of T element in the mapped array

template<typename T>
const T& SoAutoMap< T >::operator[] ( const size_t  i  )  const [inline]

const accessor to T element at index i

template<typename T>
T& SoAutoMap< T >::operator[] ( const size_t  i  )  [inline]

accessor to T element at index i


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 15 Mar 2023
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/