SOFA API  cba138a4
Open source framework for multi-physics simuation
sofa::helper::SVector< T > Class Template Reference

#include <SVector.h>

Same as helper::vector, + delimitors on serialization. More...

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

Detailed Description

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

Same as helper::vector, + delimitors on serialization.

Public Member Functions

 SVector ()
 reference to a value (read-write) More...
 
 SVector (size_type n, const T &value)
 Constructor. More...
 
 SVector (int n, const T &value)
 Constructor. More...
 
 SVector (long n, const T &value)
 Constructor. More...
 
 SVector (size_type n)
 Constructor. More...
 
 SVector (const helper::vector< T, Alloc > &x)
 Constructor. More...
 
 SVector (helper::vector< T, Alloc > &&v)
 Move constructor. More...
 
SVector< T > & operator= (const helper::vector< T, Alloc > &x)
 Copy operator. More...
 
SVector< T > & operator= (helper::vector< T, Alloc > &&v)
 Move assignment operator. More...
 
 SVector (typename SVector< T >::const_iterator first, typename SVector< T >::const_iterator last)
 Constructor. More...
 
std::ostream & write (std::ostream &os) const
 
std::istream & read (std::istream &in)
 
template<>
SOFA_HELPER_API std::istream & read (std::istream &in)
 
template<>
SOFA_HELPER_API std::ostream & write (std::ostream &os) const
 
template<>
std::istream & read (std::istream &in)
 
template<>
std::ostream & write (std::ostream &os) const
 
- Public Member Functions inherited from sofa::helper::vector< T, helper::CPUMemoryManager< T > >
 vector ()
 
 vector (size_type n)
 
 vector (const vector< T, helper::CPUMemoryManager< T > > &v)
 
bool isHostValid () const
 
bool isDeviceValid (unsigned gpu) const
 
void clear ()
 
void operator= (const vector< T, helper::CPUMemoryManager< T > > &v)
 
 ~vector ()
 
size_type size () const
 
size_type capacity () const
 
bool empty () const
 
void reserve (size_type s, size_type WARP_SIZE=helper::CPUMemoryManager< T >::BSIZE)
 
void fastResize (size_type s, size_type WARP_SIZE=helper::CPUMemoryManager< T >::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=helper::CPUMemoryManager< T >::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=helper::CPUMemoryManager< T >::BSIZE)
 
void swap (vector< T, helper::CPUMemoryManager< T > > &v)
 
const device_pointer deviceReadAt (int i, int gpu=helper::CPUMemoryManager< T >::getBufferDevice()) const
 
const device_pointer deviceRead (int gpu=helper::CPUMemoryManager< T >::getBufferDevice()) const
 
device_pointer deviceWriteAt (int i, int gpu=helper::CPUMemoryManager< T >::getBufferDevice())
 
device_pointer deviceWrite (int gpu=helper::CPUMemoryManager< T >::getBufferDevice())
 
const T * hostRead () const
 
T * hostWrite ()
 
const T * hostReadAt (int i) const
 
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 T &t)
 
void pop_back ()
 
const T & operator[] (size_type i) const
 
T & operator[] (size_type i)
 
const T * data () const
 
T * data ()
 
const T & getCached (size_type i) const
 
const 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 T &x)
 

Friends

std::ostream & operator<< (std::ostream &os, const SVector< T > &vec)
 Output stream. More...
 
std::istream & operator>> (std::istream &in, SVector< T > &vec)
 Input stream. More...
 

Additional Inherited Members

- Protected Attributes inherited from sofa::helper::vector< T, helper::CPUMemoryManager< T > >
size_type vectorSize
 Current size of the vector. More...
 
size_type allocSize
 Allocated size on host. More...
 
size_type deviceVectorSize [helper::CPUMemoryManager< T >::MAX_DEVICES]
 Initialized size on each device. More...
 
size_type deviceAllocSize [helper::CPUMemoryManager< T >::MAX_DEVICES]
 Allocated size on each device. More...
 
device_pointer devicePointer [helper::CPUMemoryManager< T >::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...
 
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...
 
- Protected Member Functions inherited from sofa::helper::vector< T, helper::CPUMemoryManager< 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 ()
 

Constructor details

template<class T>
sofa::helper::SVector< T >::SVector ( )
inline

reference to a value (read-write)

const reference to a value (read only) Basic onstructor

template<class T>
sofa::helper::SVector< T >::SVector ( size_type  n,
const T &  value 
)
inline

Constructor.

template<class T>
sofa::helper::SVector< T >::SVector ( int  n,
const T &  value 
)
inline

Constructor.

template<class T>
sofa::helper::SVector< T >::SVector ( long  n,
const T &  value 
)
inline

Constructor.

template<class T>
sofa::helper::SVector< T >::SVector ( size_type  n)
inlineexplicit

Constructor.

template<class T>
sofa::helper::SVector< T >::SVector ( const helper::vector< T, Alloc > &  x)
inline

Constructor.

template<class T>
sofa::helper::SVector< T >::SVector ( helper::vector< T, Alloc > &&  v)
inline

Move constructor.

template<class T>
sofa::helper::SVector< T >::SVector ( typename SVector< T >::const_iterator  first,
typename SVector< T >::const_iterator  last 
)
inline

Constructor.

Function details

template<class T>
SVector<T>& sofa::helper::SVector< T >::operator= ( const helper::vector< T, Alloc > &  x)
inline

Copy operator.

template<class T>
SVector<T>& sofa::helper::SVector< T >::operator= ( helper::vector< T, Alloc > &&  v)
inline

Move assignment operator.

template<>
SOFA_HELPER_API std::istream & sofa::helper::SVector< std::string >::read ( std::istream &  in)

reading specialization for std::string SVector begins by [, ends by ] and separates elements with , string elements must be delimited by ' or " (like a list of strings in python).

Note this is a quick&dirty implementation and it could be improved

template<class T>
std::istream& sofa::helper::SVector< T >::read ( std::istream &  in)
inline
template<>
std::istream & sofa::helper::SVector< std::string >::read ( std::istream &  in)

reading specialization for std::string SVector begins by [, ends by ] and separates elements with , string elements must be delimited by ' or " (like a list of strings in python). example: ['string1' , "string 2 ",'etc...' ]

template<class T>
std::ostream& sofa::helper::SVector< T >::write ( std::ostream &  os) const
inline
template<>
SOFA_HELPER_API std::ostream & sofa::helper::SVector< std::string >::write ( std::ostream &  os) const
template<>
std::ostream & sofa::helper::SVector< std::string >::write ( std::ostream &  os) const

Related details

template<class T>
std::ostream& operator<< ( std::ostream &  os,
const SVector< T > &  vec 
)
friend

Output stream.

template<class T>
std::istream& operator>> ( std::istream &  in,
SVector< T > &  vec 
)
friend

Input stream.