Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoAutoMap< T > Class Template Reference

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

#include <Inventor/devices/SoAutoMap.h>

Public Member Functions

 SoAutoMap (SoBufferObject *bufferObject, SoBufferObject::AccessMode accessMode)
 Constructor.
 
 ~SoAutoMap ()
 Destructor.
 
T & operator[] (const size_t i)
 accessor to T element at index i
 
const T & operator[] (const size_t i) const
 const accessor to T element at index i
 
size_t getSize () const
 return the number of T element in the mapped array
 

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);
{
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);
}
3D vector class.
Definition SbVec.h:932
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> buffer object ma...
Definition SoAutoMap.h:50
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
@ SET
The target buffer contents are initially undefined (although they may be the same as the source buffe...
virtual void * map(AccessMode accessMode, size_t offset=0, size_t count=SO_BUFFER_SIZE_ALL)
Map the buffer to a system memory address and allows the mapping of a sub part of the buffer object i...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> CPU buffer objec...
Smart pointer for any class inheriting SoRefCounter.
Definition SoRef.h:90

Definition at line 49 of file SoAutoMap.h.

Constructor & Destructor Documentation

◆ SoAutoMap()

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

Constructor.

In charge of setting mapping

Definition at line 54 of file SoAutoMap.h.

◆ ~SoAutoMap()

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

Destructor.

In charge of releasing mapping

Definition at line 63 of file SoAutoMap.h.

Member Function Documentation

◆ getSize()

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

return the number of T element in the mapped array

Definition at line 84 of file SoAutoMap.h.

◆ operator[]() [1/2]

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

accessor to T element at index i

Definition at line 70 of file SoAutoMap.h.

◆ operator[]() [2/2]

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

const accessor to T element at index i

Definition at line 77 of file SoAutoMap.h.


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