SOFA API  6a688117
Open source framework for multi-physics simuation
sofa::helper::vectorData< T > Class Template Reference

#include <vectorData.h>

Inheritance diagram for sofa::helper::vectorData< T >:

Detailed Description

template<class T>
class sofa::helper::vectorData< T >

A helper class which implements a vector of a variable number of Data

When the owner component is a DataEngine, the Data can be automatically added as inputs or outputs

Warning
The first index is 1 in the Data name
Author
Thomas Lemaire
Date
2014

Protected Attributes

core::objectmodel::Basem_component
 
std::string m_name
 
std::string m_help
 
DataEngineDataType m_dataEngineDataType
 only valid if m_component is a DataEngine More...
 
m_defaultValue
 
- Protected Attributes inherited from sofa::helper::vector< core::objectmodel::Data< T > * >
size_type vectorSize
 Current size of the vector. More...
 
size_type allocSize
 Allocated size on host. More...
 
size_type deviceVectorSize [MemoryManager::MAX_DEVICES]
 Initialized size on each device. More...
 
size_type deviceAllocSize [MemoryManager::MAX_DEVICES]
 Allocated size on each device. More...
 
device_pointer devicePointer [MemoryManager::MAX_DEVICES]
 Pointer to the data on the GPU side. More...
 
size_type clearSize
 when initializing missing device data, up to where entries should be set to zero ? More...
 
core::objectmodel::Data< T > ** hostPointer
 Pointer to the data on the CPU side. More...
 
int deviceIsValid
 True if the data on the GPU is currently valid (up to the given deviceVectorSize of each device, i.e. additionnal space may need to be allocated and/or initialized) More...
 
bool hostIsValid
 True if the data on the CPU is currently valid. More...
 
bool bufferIsRegistered
 True if the OpenGL buffer is registered with CUDA. More...
 
GLuint bufferObject
 Optionnal associated OpenGL buffer ID. More...
 

Public Member Functions

 vectorData (core::objectmodel::Base *component, std::string const &name, std::string const &help, DataEngineDataType dataEngineDataType=DataEngineNothing, const T &defaultValue=T())
 'dataEngineInOut' is only valid if 'component' is a DataEngine More...
 
 ~vectorData ()
 
void parseSizeData (sofa::core::objectmodel::BaseObjectDescription *arg, Data< unsigned int > &size)
 
void parseFieldsSizeData (const std::map< std::string, std::string * > &str, Data< unsigned int > &size)
 
void resize (const unsigned int size)
 
- Public Member Functions inherited from sofa::helper::vector< core::objectmodel::Data< T > * >
 vector ()
 
 vector (size_type n)
 
 vector (const vector< core::objectmodel::Data< T > *, MemoryManager > &v)
 
bool isHostValid () const
 
bool isDeviceValid (unsigned gpu) const
 
void clear ()
 
void operator= (const vector< core::objectmodel::Data< T > *, MemoryManager > &v)
 
 ~vector ()
 
size_type size () const
 
size_type capacity () const
 
bool empty () const
 
void reserve (size_type s, size_type WARP_SIZE=MemoryManager::BSIZE)
 
void fastResize (size_type s, size_type WARP_SIZE=MemoryManager::BSIZE)
 resize the vector without calling constructors or destructors, and without synchronizing the device and host copy More...
 
void recreate (size_type s, size_type WARP_SIZE=MemoryManager::BSIZE)
 resize the vector discarding any old values, without calling constructors or destructors, and without synchronizing the device and host copy More...
 
void invalidateDevice ()
 
void invalidateHost ()
 
void memsetDevice (int v=0)
 
void memsetHost (int v=0)
 
void resize (size_type s, size_type WARP_SIZE=MemoryManager::BSIZE)
 
void swap (vector< core::objectmodel::Data< T > *, MemoryManager > &v)
 
const device_pointer deviceReadAt (int i, int gpu=MemoryManager::getBufferDevice()) const
 
const device_pointer deviceRead (int gpu=MemoryManager::getBufferDevice()) const
 
device_pointer deviceWriteAt (int i, int gpu=MemoryManager::getBufferDevice())
 
device_pointer deviceWrite (int gpu=MemoryManager::getBufferDevice())
 
const core::objectmodel::Data< T > ** hostRead () const
 
core::objectmodel::Data< T > ** hostWrite ()
 
const core::objectmodel::Data< T > ** hostReadAt (int i) const
 
core::objectmodel::Data< T > ** hostWriteAt (int i)
 
GLuint bufferRead (bool create=false)
 Get the OpenGL Buffer Object ID for reading. More...
 
GLuint bufferWrite (bool create=false)
 Get the OpenGL Buffer Object ID for writing. More...
 
void push_back (const core::objectmodel::Data< T > *&t)
 
void pop_back ()
 
const core::objectmodel::Data< T > *& operator[] (size_type i) const
 
core::objectmodel::Data< T > *& operator[] (size_type i)
 
const core::objectmodel::Data< T > ** data () const
 
core::objectmodel::Data< T > ** data ()
 
const core::objectmodel::Data< T > *& getCached (size_type i) const
 
const core::objectmodel::Data< T > *& getSingle (size_type i) const
 
const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
iterator erase (iterator position)
 
iterator insert (iterator position, const core::objectmodel::Data< T > *&x)
 

Static Public Member Functions

static void merge (Data< T > &outputData, const vectorData< T > &vectorData)
 merging several Data from a VectorData into a large Data (of the same type) More...
 

Additional Inherited Members

- Protected Member Functions inherited from sofa::helper::vector< core::objectmodel::Data< T > * >
void allocate (int d) const
 
void copyToHost () const
 
void copyToDevice (int d=0) const
 
void copyToHostSingle (size_type i) const
 
void checkIndex (size_type i) const
 
void registerBuffer () const
 
void mapBuffer () const
 
void unmapBuffer () const
 
void unregisterBuffer () const
 
void createBuffer ()
 

Attribute details

template<class T>
core::objectmodel::Base* sofa::helper::vectorData< T >::m_component
protected
template<class T>
DataEngineDataType sofa::helper::vectorData< T >::m_dataEngineDataType
protected

only valid if m_component is a DataEngine

template<class T>
T sofa::helper::vectorData< T >::m_defaultValue
protected
template<class T>
std::string sofa::helper::vectorData< T >::m_help
protected
template<class T>
std::string sofa::helper::vectorData< T >::m_name
protected

Constructor details

template<class T>
sofa::helper::vectorData< T >::vectorData ( core::objectmodel::Base component,
std::string const &  name,
std::string const &  help,
DataEngineDataType  dataEngineDataType = DataEngineNothing,
const T &  defaultValue = T() 
)
inline

'dataEngineInOut' is only valid if 'component' is a DataEngine

template<class T>
sofa::helper::vectorData< T >::~vectorData ( )
inline

Function details

template<class T>
static void sofa::helper::vectorData< T >::merge ( Data< T > &  outputData,
const vectorData< T > &  vectorData 
)
inlinestatic

merging several Data from a VectorData into a large Data (of the same type)

template<class T>
void sofa::helper::vectorData< T >::parseFieldsSizeData ( const std::map< std::string, std::string * > &  str,
Data< unsigned int > &  size 
)
inline
template<class T>
void sofa::helper::vectorData< T >::parseSizeData ( sofa::core::objectmodel::BaseObjectDescription arg,
Data< unsigned int > &  size 
)
inline
template<class T>
void sofa::helper::vectorData< T >::resize ( const unsigned int  size)
inline